Skip to content

Commit

Permalink
#76: added package and file information to html output
Browse files Browse the repository at this point in the history
  • Loading branch information
jdaguil committed Nov 11, 2015
1 parent e243767 commit 6b6d0d9
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/scancode/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def as_html(detected_data):
template = get_html_template('html')

converted = OrderedDict()
converted_infos = OrderedDict()
converted_packages = OrderedDict()
licenses = {}

# Create a dict keyed by location
Expand All @@ -158,11 +160,22 @@ def as_html(detected_data):

if entry['key'] not in licenses:
licenses[entry['key']] = entry

if results:
converted[location] = sorted(results, key=itemgetter('start'))

if 'infos' in scan_result:
converted_infos[location] = scan_result['infos']

if 'packages' in scan_result:
converted_packages[location] = scan_result['packages']

licenses = OrderedDict(sorted(licenses.items()))

return template.render(results=converted, licenses=licenses)
results = {
"license_copyright": converted,
"infos": converted_infos,
"packages": converted_packages
}

return template.render(results=results, licenses=licenses)

84 changes: 83 additions & 1 deletion src/scancode/templates/html/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
</style>
</head>
<body>
{% if results.license_copyright %}
<table>
<thead>
<tr>
Expand All @@ -75,7 +76,7 @@
</tr>
</thead>
<tbody>
{% for location, data in results.items() %}
{% for location, data in results.license_copyright.items() %}
{% for row in data %}
<tr>
<td>{{ location }}</td>
Expand All @@ -92,6 +93,87 @@
{% endfor %}
</tbody>
</table>
{% endif %}

{% if results.infos %}
<table>
<caption>File Information</caption>
<thead>
<tr>
<th>location</th>
<th>type</th>
<th>name</th>
<th>extension</th>
<th>date</th>
<th>size</th>
<th>sha1</th>
<th>md5</th>
<th>files_count</th>
<th>mime_type</th>
<th>file_type</th>
<th>programming_language</th>
<th>is_binary</th>
<th>is_text</th>
<th>is_archive</th>
<th>is_media</th>
<th>is_source</th>
<th>is_script</th>
</tr>
</thead>
<tbody>
{% for location, data in results.infos.items() %}
{% for row in data %}
<tr>
<td>{{ location }}</td>
<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>
<td>{{ row.file_count }}</td>
<td>{{ row.mime_type }}</td>
<td>{{ row.file_type }}</td>
<td>{{ row.programming_language }}</td>
<td>{{ row.is_binary }}</td>
<td>{{ row.is_text }}</td>
<td>{{ row.is_archive }}</td>
<td>{{ row.is_media }}</td>
<td>{{ row.is_source }}</td>
<td>{{ row.is_script }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endif %}

{% if results.packages %}
<table>
<caption>Package Information</caption>
<thead>
<tr>
<th>location</th>
<th>type</th>
<th>packaging</th>
<th>primary_language</th>
</tr>
</thead>
<tbody>
{% for location, data in results.packages.items() %}
{% for row in data %}
<tr>
<td>{{ location }}</td>
<td>{{ row.type }}</td>
<td>{{ row.packaging }}</td>
<td>{{ row.primary_language }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endif %}

{% if licenses %}
<table>
Expand Down

0 comments on commit 6b6d0d9

Please sign in to comment.