Skip to content

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

Merged
merged 9 commits into from
May 30, 2017
Merged

Conversation

leifj
Copy link
Contributor

@leifj leifj commented May 30, 2017

This one is "clean"... I think

@leifj leifj requested a review from johanlundberg May 30, 2017 12:57
*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
Copy link
Contributor

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):
Copy link
Contributor

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?

Copy link
Contributor Author

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):
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rogue print statement

@leifj
Copy link
Contributor Author

leifj commented May 30, 2017

pushed fixes for all review comments except the one that requires merging of #99

@leifj
Copy link
Contributor Author

leifj commented May 30, 2017

finished the refactor too

@johanlundberg johanlundberg merged commit fe93173 into IdentityPython:master May 30, 2017
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