Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves Warning messaging #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Improves Warning messaging #11

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 18, 2016

Improves on the original warning.warn message (for when an envfile wasn't found) by including the search path used for a given file.

Improves on the original warning.warn message (for when an envfile wasn't
found) by including the search path used for a given file.
@@ -183,6 +199,8 @@ def read_envfile(path=None, **overrides):
with open(path, 'r') as f:
content = f.read()
except getattr(__builtins__, 'FileNotFoundError', IOError):
# Append the path we tried (and failed) to find to a tracking table
traversed_paths = Env.track_path(path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but Env can be cls here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where it's used inside a static method, so there's no cls binding param AFAIK.

@rconradharris
Copy link
Owner

Looks useful.

Think an additional function for this is probably overkill, just adding a list of paths we've traversed to read_envfile should be good enough.

Instead of implementing the (missing path) logging on the class level,
 instead just track as a list in the read_envfile params.
@ghost
Copy link
Author

ghost commented Apr 19, 2016

Thanks for saying that it looks useful and for quickly responding to the PR (👍 ).

I think the last commit is what you had in mind, but let me know if I misunderstood and I can modify it.

@ghost
Copy link
Author

ghost commented Apr 19, 2016

It is worth noting that the change to only use a list in that fashion means that the UserWarning will contain all failed path lookups (i.e. read_envfile('a'); read_envfile('b') will show warnings on 'b' that contain paths from 'a'). Let me know if you want me to write in the "only show warnings for filename" behavior.

@MichaelCurrie
Copy link

@rconradharris are you still maintaining this repo? The last commit is 7 years ago. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants