Download:
child 48:9b37d0f08f1c
parent 46:0f45e02848a1
47:5633f9a8dc95
Anton Shestakov <av6@dwimlabs.net>, Sun, 19 Jun 2016 22:03:36 +0800
incoming: use dicts instead of tuples for Check.lines

2 файлов изменено, 14 вставок(+), 14 удалений(-) [+]
incoming.py file | annotate | diff | comparison | revisions
templates/check.html file | annotate | diff | comparison | revisions
--- a/incoming.py Sun Jun 19 16:22:28 2016 +0800
+++ b/incoming.py Sun Jun 19 22:03:36 2016 +0800
@@ -56,17 +56,17 @@
finished = None
for line in lines:
- cls = None
+ item = {'text': line}
if line.startswith(meta_prefix):
- cls = 'meta'
+ item['cls'] = 'meta'
rest = line[len(meta_prefix):]
m = re.match('^task: (\w+)$', rest)
if m is not None:
state = m.group(1)
- cls = 'task'
+ item['cls'] = 'task'
m = re.match('^job failed$', rest)
if m is not None:
@@ -110,27 +110,27 @@
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes
if re.match(r'^E9\d{2}', rest) is not None:
errors += 1
- cls = 'error'
+ item['cls'] = 'error'
elif re.match(r'^[EWFCN]\d{3}', rest) is not None:
warnings += 1
- cls = 'warning'
+ item['cls'] = 'warning'
elif re.match(r'^\[error\]', rest) is not None:
errors += 1
- cls = 'error'
+ item['cls'] = 'error'
elif re.match(r'^\[warning\]', rest) is not None:
warnings += 1
- cls = 'warning'
+ item['cls'] = 'warning'
elif re.match(r'^\(E\d{3}\)', rest) is not None:
errors += 1
- cls = 'error'
+ item['cls'] = 'error'
elif re.match(r'^\(W\d{3}\)', rest) is not None:
warnings += 1
- cls = 'warning'
+ item['cls'] = 'warning'
else:
warnings += 1
- cls = 'warning'
+ item['cls'] = 'warning'
- result.append((cls, line))
+ result.append(item)
domain, user, name = parse_project_url(url)
--- a/templates/check.html Sun Jun 19 16:22:28 2016 +0800
+++ b/templates/check.html Sun Jun 19 22:03:36 2016 +0800
@@ -42,10 +42,10 @@
</div>
</div>
<pre class="check-log">{#
- #}{% for number, (cls, line) in enumerate(lines, 1) %}{#
- #}<div id="l{{ number }}"{% if cls %} class="{{ cls }}"{% end %}>{#
+ #}{% for number, line in enumerate(lines, 1) %}{#
+ #}<div id="l{{ number }}"{% if 'cls' in line %} class="{{ line['cls'] }}"{% end %}>{#
#}<a href="#l{{ number }}" class="lineno" data-line-number="{{ number }}"></a>{#
- #}{{ line }}{#
+ #}{{ line['text'] }}{#
#}</div>{#
#}{% end %}{#
#}</pre>