Skip to content

Commit 9135a47

Browse files
committed
#76: added package and file information to html output
1 parent 0014561 commit 9135a47

File tree

2 files changed

+98
-3
lines changed

2 files changed

+98
-3
lines changed

src/scancode/format.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def as_html(detected_data):
132132
template = get_html_template('html')
133133

134134
converted = OrderedDict()
135+
converted_infos = OrderedDict()
136+
converted_packages = OrderedDict()
135137
licenses = {}
136138

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

159161
if entry['key'] not in licenses:
160162
licenses[entry['key']] = entry
161-
162163
if results:
163164
converted[location] = sorted(results, key=itemgetter('start'))
164165

166+
if 'infos' in scan_result:
167+
converted_infos[location] = scan_result['infos']
168+
169+
if 'packages' in scan_result:
170+
converted_packages[location] = scan_result['packages']
171+
165172
licenses = OrderedDict(sorted(licenses.items()))
166173

167-
return template.render(results=converted, licenses=licenses)
174+
results = {
175+
"license_copyright": converted,
176+
"infos": converted_infos,
177+
"packages": converted_packages
178+
}
179+
180+
return template.render(results=results, licenses=licenses)
168181

src/scancode/templates/html/template.html

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
</style>
6565
</head>
6666
<body>
67+
{% if results.license_copyright %}
6768
<table>
6869
<thead>
6970
<tr>
@@ -75,7 +76,7 @@
7576
</tr>
7677
</thead>
7778
<tbody>
78-
{% for location, data in results.items() %}
79+
{% for location, data in results.license_copyright.items() %}
7980
{% for row in data %}
8081
<tr>
8182
<td>{{ location }}</td>
@@ -92,6 +93,87 @@
9293
{% endfor %}
9394
</tbody>
9495
</table>
96+
{% endif %}
97+
98+
{% if results.infos %}
99+
<table>
100+
<caption>File Information</caption>
101+
<thead>
102+
<tr>
103+
<th>location</th>
104+
<th>type</th>
105+
<th>name</th>
106+
<th>extension</th>
107+
<th>date</th>
108+
<th>size</th>
109+
<th>sha1</th>
110+
<th>md5</th>
111+
<th>files_count</th>
112+
<th>mime_type</th>
113+
<th>file_type</th>
114+
<th>programming_language</th>
115+
<th>is_binary</th>
116+
<th>is_text</th>
117+
<th>is_archive</th>
118+
<th>is_media</th>
119+
<th>is_source</th>
120+
<th>is_script</th>
121+
</tr>
122+
</thead>
123+
<tbody>
124+
{% for location, data in results.infos.items() %}
125+
{% for row in data %}
126+
<tr>
127+
<td>{{ location }}</td>
128+
<td>{{ row.type }}</td>
129+
<td>{{ row.name }}</td>
130+
<td>{{ row.extension }}</td>
131+
<td>{{ row.date }}</td>
132+
<td>{{ row.size }}</td>
133+
<td>{{ row.sha1 }}</td>
134+
<td>{{ row.md5 }}</td>
135+
<td>{{ row.file_count }}</td>
136+
<td>{{ row.mime_type }}</td>
137+
<td>{{ row.file_type }}</td>
138+
<td>{{ row.programming_language }}</td>
139+
<td>{{ row.is_binary }}</td>
140+
<td>{{ row.is_text }}</td>
141+
<td>{{ row.is_archive }}</td>
142+
<td>{{ row.is_media }}</td>
143+
<td>{{ row.is_source }}</td>
144+
<td>{{ row.is_script }}</td>
145+
</tr>
146+
{% endfor %}
147+
{% endfor %}
148+
</tbody>
149+
</table>
150+
{% endif %}
151+
152+
{% if results.packages %}
153+
<table>
154+
<caption>Package Information</caption>
155+
<thead>
156+
<tr>
157+
<th>location</th>
158+
<th>type</th>
159+
<th>packaging</th>
160+
<th>primary_language</th>
161+
</tr>
162+
</thead>
163+
<tbody>
164+
{% for location, data in results.packages.items() %}
165+
{% for row in data %}
166+
<tr>
167+
<td>{{ location }}</td>
168+
<td>{{ row.type }}</td>
169+
<td>{{ row.packaging }}</td>
170+
<td>{{ row.primary_language }}</td>
171+
</tr>
172+
{% endfor %}
173+
{% endfor %}
174+
</tbody>
175+
</table>
176+
{% endif %}
95177

96178
{% if licenses %}
97179
<table>

0 commit comments

Comments
 (0)