-
Notifications
You must be signed in to change notification settings - Fork 132
Attribute generation #100
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
Attribute generation #100
Conversation
*Special contexts* | ||
|
||
For treating the values as a list - eg for interating using mustach, | ||
use the .values sub-context For instance to synthesize all fist-last |
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.
all first-last
|
||
from .base import ResponseMicroService | ||
|
||
def _config(f, requester, provider): |
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.
Do you want to update your code to use the util function added in #99?
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 was planning to do that in a later refactor - dunno if I can cherry-pick that function
|
||
@property | ||
def value(self): | ||
if 1 == len(self._values): |
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.
Just picky but I really find len(self._values) == 1 is much easier to read.
recipes = _config(self.synthetic_attributes, requester, provider) | ||
print(context) | ||
for attr_name, fmt in recipes: | ||
print(fmt) |
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.
Rogue print statement
for attr_name, fmt in recipes: | ||
print(fmt) | ||
syn_attributes[attr_name] = [v.strip().strip(';') for v in re.split("[;\n]+", pystache.render(fmt, context))] | ||
print(syn_attributes) |
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.
Rogue print statement
context[attr_name] = MustachAttrValue(attr_name, values) | ||
|
||
recipes = _config(self.synthetic_attributes, requester, provider) | ||
print(context) |
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.
Rogue print statement
pushed fixes for all review comments except the one that requires merging of #99 |
finished the refactor too |
This one is "clean"... I think