395: api: Accept empty line in diffs, fix issue57 by Benoit Allard
api: Accept empty line in diffs, fix issue57
No changeset-level comments yet…
Add a comment on this changeset
Signoffs
No signoffs yet…
Files
cmV2aWV3L2FwaS5weQ==
review/api.py ↓
| … skipped 612 lines … | ||
| 612 | |
|
| 613 | def _filter_diff(d): |
|
| 614 | for n, line in enumerate(d): |
|
| 615 | start = n - context if n > context else 0 |
|
| 616 | end = n + context + 1 |
|
| 617 | - | if any(filter(lambda l: l[0] in '+-', d[start:end])): |
| 618 | + | if any(filter(lambda l: l and l[0] in '+-', d[start:end])): |
| 619 | yield (n, line) |
|
| 620 | |
|
| 621 | for filename, content in ds.iteritems(): |
|
| 622 | if content: |
|
| 623 | content = content.splitlines() |
|
| … skipped 366 lines … | ||
cmV2aWV3L3dlYi5weQ==
review/web.py ↓
| … skipped 45 lines … | ||
| 45 | |
|
| 46 | def _cset_gravatar(cset, size=30): |
|
| 47 | return 'http://www.gravatar.com/avatar/%s?s=%d' % (md5(email(cset.user())).hexdigest(), size) |
|
| 48 | |
|
| 49 | def _line_type(line): |
|
| 50 | - | return 'rem' if line[0] == '-' else 'add' if line[0] == '+' else 'con' |
| 51 | + | try: |
| 52 | + | return {'+': 'add', '-':'rem'}[line[0]] |
| 53 | + | except (IndexError, KeyError): |
| 54 | + | return 'con' |
| 55 | |
|
| 56 | def _categorize_signoffs(signoffs): |
|
| 57 | return { 'yes': len(filter(lambda s: s.opinion == 'yes', signoffs)), |
|
| 58 | 'no': len(filter(lambda s: s.opinion == 'no', signoffs)), |
|
| 59 | 'neutral': len(filter(lambda s: s.opinion == '', signoffs)),} |
|
| … skipped 200 lines … | ||