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: Updated patch by Wladimir #2 Created March 20, 2015, 4:47 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 find(sequence, value, attribute=None): 1 from jinja2 import environmentfilter
2
3 @environmentfilter
4 def find(environment, sequence, value, attribute=None):
2 for item in sequence: 5 for item in sequence:
3 if ((attribute is None and item == value) or 6 if (item if attribute is None else environment.getitem(item, attribute)) == value:
4 (attribute is not None and item[attribute] == value)):
Sebastian Noack 2015/03/20 17:50:28 If you insist on keeping this weird filter, can we
Wladimir Palant 2015/03/20 18:22:40 Not that much simpler but fine with me.
Sebastian Noack 2015/03/21 12:34:44 Moreover, you should use environment.getitem(). Ot
saroyanm 2015/03/21 17:27:10 Done.
Wladimir Palant 2015/03/22 22:06:42 I doubt that this is a good idea. Environment.geti
saroyanm 2015/03/22 23:40:51 Done.
5 return item 7 return item
6 return None 8 return None
LEFTRIGHT

Powered by Google App Engine
This is Rietveld