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
butler-specific policy class #6
Conversation
- yaml: read and write is supported. | ||
- pex policy: read is supported, although this is deprecated and will at some point be removed. | ||
""" | ||
|
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.
It's usual to have an __init__()
method, even if all it does is set self.data
to something sensible. You might also want to be able to create a Policy
directly from a yaml
or pex_policy
file.
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.
I could add one, but it would just call the base class init. is that desirable?
There are methods to create Policy from yaml, and pex_policy, but it's explicit. I was thinking about creating a version of init that accepts a var and then implements overloading behavior (i.e. dispatch) based on var type. does that seem desirable?
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.
re. explicit methods, now I've seen your comment below. I'll work the ctor.
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.
so there's a polymorphic init now. I suspect the pythonistas will ding me on this as type checking tends to be discouraged in python (as opposed to duck typing) but I think in this case it's justifiable. I'm happy to discuss it though.
a00fea5
to
cbae7d5
Compare
:param name: | ||
:return: the value for the given name. | ||
""" | ||
warnings.warn_explicit("Deprecated. Use []", DeprecationWarning) |
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.
if there's a better way to mark methods as deprecated I'd like to know about it. These don't actually do anything; the DeprecationWarning is ignored by default. But it's more than nothing at least.
cbae7d5
to
76079f4
Compare
class Policy(UserDict.UserDict): | ||
"""Policy implements a datatype that is used by Butler for configuration parameters. | ||
It is essentially a dict with key/value pairs, including nested dicts (as values). In fact, it can be | ||
initialized with a dict. The only caviat is that keys may NOT contain dots ('.'). This is explained next: |
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.
"caveat"
adds a pure python butler policy class. basically nested dicts, but implemented as a class that adds some functionality to support policy-ish api, such as dot delimited hierarchical access.
76079f4
to
327198b
Compare
adds a pure python butler policy class. basically nested dicts,
but implemented as a class that adds some functionality to
support policy-ish api, such as dot delimited hierarchical
access.