Minors template improvements

If CVE is 'Requested' then it's not used in reporters and mitre reference.
Adds wordwrap to notes and errata text.
Remove a trailing space.

Change-Id: I5c649aea967868ce0726eac9e374f4f4f83d2cb6
This commit is contained in:
Tristan Cacqueray
2015-01-15 14:49:24 +00:00
parent eb2776f714
commit 3ddd6ef25c
3 changed files with 9 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ Description
Errata
~~~~~~
{{ errata_text }}
{{ errata }}
{% endif %}
@@ -42,7 +42,8 @@ Credits
~~~~~~~
{% for reporter in reporters %}
{% if 'affiliation' in reporter and reporter['affiliation'] and reporter['affiliation'] != 'UNKNOWN' %}
- {{ reporter['name'] | trim | indent }} from {{ reporter ['affiliation'] }} ({{ reporter['reported'] | csv_list }})
- {{ reporter['name'] | trim | indent }} from {{ reporter ['affiliation'] }}{% if 'reported' in reporter %} ({{ reporter['reported'] | csv_list }}){% endif %}
{% else %}
- {{ reporter['name'] | trim | indent }} ({{ reporter['reported'] | csv_list }})
{% endif %}
@@ -54,16 +55,16 @@ References
{% for link in issues['links'] %}
- {{ link }}
{% endfor %}
{% for vuln in vulnerabilities %}
{% for vuln in vulnerabilities %}{% if vuln['cve-id'] != 'Requested' %}
- http://cve.mitre.org/cgi-bin/cvename.cgi?name={{ vuln['cve-id'] }}
{% endfor %}
{% endif %}{% endfor %}
{% if notes %}
Notes
~~~~~
{% for note in notes %}
- {{ note }}
- {{ note | wordwrap(width=77, break_long_words=False, wrapstring='\n ') }}
{% endfor %}
{% endif %}
{% if errata %}

View File

@@ -29,7 +29,7 @@ def to_snake_case(d):
def to_paragraphs(d, *args):
for k in args:
if type(d[k]) == str:
if k in d and type(d[k]) == str:
d[k] = '\n'.join(textwrap.wrap(d[k]))
@@ -59,7 +59,7 @@ def render_template(template, data, **kwargs):
def render(source, template, **kwargs):
vals = yaml.safe_load(open(source).read())
to_snake_case(vals)
to_paragraphs(vals, 'description')
to_paragraphs(vals, 'description', 'errata')
return render_template(template, vals, **kwargs)