Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Important API changes:
that contains each package instance that can be aggregating data from
multiple manifests for a single package instance.

- The data structure for HTML output has been changed to include emails and urls under the
"infos" object. Now HTML template will output holders, authors, emails, and
urls into separate tables like "licenses" and "copyrights".

Copyright detection:
~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 1 addition & 3 deletions src/formattedcode/output_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ def generate_output(results, version, template):
LICENSES = 'licenses'
COPYRIGHTS = 'copyrights'
PACKAGES = 'packages'
URLS = 'urls'
EMAILS = 'emails'

# Create a flattened data dict keyed by path
for scanned_file in results:
Expand Down Expand Up @@ -197,7 +195,7 @@ def generate_output(results, version, template):
# denormalizing the list here??
converted_infos[path] = {}
for name, value in scanned_file.items():
if name in (LICENSES, PACKAGES, COPYRIGHTS, EMAILS, URLS):
if name in (LICENSES, PACKAGES, COPYRIGHTS):
continue
converted_infos[path][name] = value

Expand Down
100 changes: 100 additions & 0 deletions src/formattedcode/templates/html/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,106 @@
{% endfor %}
</tbody>
</table>
<table>
<caption>Holders</caption>
<thead>
<tr>
<th>path</th>
<th>holder</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.holders %}
{% for data in row.holders %}
<tr>
<td>{{ path }}</td>
<td>{{ data.value }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Authors</caption>
<thead>
<tr>
<th>path</th>
<th>Author</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.authors %}
{% for data in row.authors %}
<tr>
<td>{{ path }}</td>
<td>{{ data.value }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Emails</caption>
<thead>
<tr>
<th>path</th>
<th>email</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.emails %}
{% for data in row.emails %}
<tr>
<td>{{ path }}</td>
<td>{{ data.email |urlize(target='_blank') }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Urls</caption>
<thead>
<tr>
<th>path</th>
<th>url</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.urls %}
{% for data in row.urls %}
<tr>
<td>{{ path }}</td>
<td>{{ data.url |urlize(target='_blank') }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif %}

{% if files.packages %}
Expand Down
104 changes: 101 additions & 3 deletions tests/formattedcode/data/templated/sample-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</style>
</head>
<body>
<p> Scanned with ScanCode version {{ version }} </p>
<p> Scanned with ScanCode </p>
{% if files.license_copyright %}
<table>
<caption>Copyrights and Licenses Information</caption>
Expand Down Expand Up @@ -104,7 +104,6 @@
<th>type</th>
<th>name</th>
<th>extension</th>
<th>date</th>
<th>size</th>
<th>sha1</th>
<th>md5</th>
Expand All @@ -127,7 +126,6 @@
<td>{{ row.type }}</td>
<td>{{ row.name }}</td>
<td>{{ row.extension }}</td>
<td>{{ row.date }}</td>
<td>{{ row.size }}</td>
<td>{{ row.sha1 }}</td>
<td>{{ row.md5 }}</td>
Expand All @@ -145,6 +143,106 @@
{% endfor %}
</tbody>
</table>
<table>
<caption>Holders</caption>
<thead>
<tr>
<th>path</th>
<th>holder</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.holders %}
{% for data in row.holders %}
<tr>
<td>{{ path }}</td>
<td>{{ data.value }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Authors</caption>
<thead>
<tr>
<th>path</th>
<th>Author</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.authors %}
{% for data in row.authors %}
<tr>
<td>{{ path }}</td>
<td>{{ data.value }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Emails</caption>
<thead>
<tr>
<th>path</th>
<th>email</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.emails %}
{% for data in row.emails %}
<tr>
<td>{{ path }}</td>
<td>{{ data.email |urlize(target='_blank') }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
<table>
<caption>Urls</caption>
<thead>
<tr>
<th>path</th>
<th>url</th>
<th>start</th>
<th>end</th>
</tr>
</thead>
<tbody>
{% for path, row in files.infos.items() %}
{% if row.urls %}
{% for data in row.urls %}
<tr>
<td>{{ path }}</td>
<td>{{ data.url |urlize(target='_blank') }}</td>
<td>{{ data.start_line }}</td>
<td>{{ data.end_line }}</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif %}

{% if files.packages %}
Expand Down
Loading