-
-
Notifications
You must be signed in to change notification settings - Fork 102
Config: add a dict-like getter #1964
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
Conversation
makes the access to optional configuration options much easier
Introduces a new optional configuration parameter to specify any instance-specific extensions for the markdown parser based on moinwiki#1964 implements moinwiki#1957
| def get(self, item, default=None): | ||
| """Dict-like get method. | ||
| Return the value for key if key is in the dictionary, else default. | ||
| If default is not given, it defaults to None, so that this method never raises a KeyError.""" | ||
| try: | ||
| return getattr(self, item) | ||
| except AttributeError: | ||
| return default | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the idea of the DefaultConfig is that it has defaults for all supported attributes, so one would never get this AttributeError.
Having it in this class is also useful because it is one place where settings and their default can be looked up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Introduces a new optional configuration parameter to specify any instance-specific extensions for the markdown parser based on moinwiki#1964 implements moinwiki#1957
Introduces a new optional configuration parameter to specify any instance-specific extensions for the markdown parser based on moinwiki#1964 implements moinwiki#1957
Introduces a new optional configuration parameter to specify any instance-specific extensions for the markdown parser based on moinwiki#1964 implements moinwiki#1957
Introduces a new optional configuration parameter to specify any instance-specific extensions for the markdown parser based on moinwiki#1964 implements moinwiki#1957
makes the access to optional configuration options much easier