Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: filters/find.py

Issue 5994668214976512: Issue 662 - Job links shouldn't use anchors (Closed)
Left Patch Set: Created March 22, 2015, 11:44 p.m.
Right Patch Set: Created March 23, 2015, 1:04 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | includes/jobs/footer.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 def getattribute(obj, attribute): 1 from jinja2 import environmentfilter
Sebastian Noack 2015/03/23 10:45:21 Why don't you use environment.getitem() anymore?
saroyanm 2015/03/23 10:59:13 I've changed according to the last Reply here: htt
Sebastian Noack 2015/03/23 11:19:59 Sorry, I missed that comment. However, I don't agr
Sebastian Noack 2015/03/23 12:31:14 For reference: 13:15:01 <snoack> mitsuhiko: Is En
saroyanm 2015/03/23 13:07:50 Done.
2 try:
3 return getattr(obj, str(attribute))
4 except AttributeError:
5 return obj[attribute]
6 2
7 def find(sequence, value, attribute=None): 3 @environmentfilter
4 def find(environment, sequence, value, attribute=None):
8 for item in sequence: 5 for item in sequence:
9 if (item if attribute is None else getattribute(item, attribute)) == value: 6 if (item if attribute is None else environment.getitem(item, attribute)) == value:
10 return item 7 return item
11 return None 8 return None
LEFTRIGHT

Powered by Google App Engine
This is Rietveld