diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 6680a0ee178..9fa30292f0a 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -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:
~~~~~~~~~~~~~~~~~~~~
diff --git a/src/formattedcode/output_html.py b/src/formattedcode/output_html.py
index 8af9dfac74b..d3187092c6e 100644
--- a/src/formattedcode/output_html.py
+++ b/src/formattedcode/output_html.py
@@ -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:
@@ -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
diff --git a/src/formattedcode/templates/html/template.html b/src/formattedcode/templates/html/template.html
index 484dddffa99..6f97e1dc726 100644
--- a/src/formattedcode/templates/html/template.html
+++ b/src/formattedcode/templates/html/template.html
@@ -131,6 +131,106 @@
{% endfor %}
+
+ Holders
+
+
+ path
+ holder
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.holders %}
+ {% for data in row.holders %}
+
+ {{ path }}
+ {{ data.value }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Authors
+
+
+ path
+ Author
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.authors %}
+ {% for data in row.authors %}
+
+ {{ path }}
+ {{ data.value }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Emails
+
+
+ path
+ email
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.emails %}
+ {% for data in row.emails %}
+
+ {{ path }}
+ {{ data.email |urlize(target='_blank') }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Urls
+
+
+ path
+ url
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.urls %}
+ {% for data in row.urls %}
+
+ {{ path }}
+ {{ data.url |urlize(target='_blank') }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
{% endif %}
{% if files.packages %}
diff --git a/tests/formattedcode/data/templated/sample-template.html b/tests/formattedcode/data/templated/sample-template.html
index a8c53d7b3fc..a0c2bc5d96e 100644
--- a/tests/formattedcode/data/templated/sample-template.html
+++ b/tests/formattedcode/data/templated/sample-template.html
@@ -62,7 +62,7 @@
- Scanned with ScanCode version {{ version }}
+ Scanned with ScanCode
{% if files.license_copyright %}
Copyrights and Licenses Information
@@ -104,7 +104,6 @@
type
name
extension
- date
size
sha1
md5
@@ -127,7 +126,6 @@
{{ row.type }}
{{ row.name }}
{{ row.extension }}
- {{ row.date }}
{{ row.size }}
{{ row.sha1 }}
{{ row.md5 }}
@@ -145,6 +143,106 @@
{% endfor %}
+
+ Holders
+
+
+ path
+ holder
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.holders %}
+ {% for data in row.holders %}
+
+ {{ path }}
+ {{ data.value }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Authors
+
+
+ path
+ Author
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.authors %}
+ {% for data in row.authors %}
+
+ {{ path }}
+ {{ data.value }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Emails
+
+
+ path
+ email
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.emails %}
+ {% for data in row.emails %}
+
+ {{ path }}
+ {{ data.email |urlize(target='_blank') }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
+
+ Urls
+
+
+ path
+ url
+ start
+ end
+
+
+
+ {% for path, row in files.infos.items() %}
+ {% if row.urls %}
+ {% for data in row.urls %}
+
+ {{ path }}
+ {{ data.url |urlize(target='_blank') }}
+ {{ data.start_line }}
+ {{ data.end_line }}
+
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+
+
{% endif %}
{% if files.packages %}
diff --git a/tests/formattedcode/data/templated/simple-expected.html b/tests/formattedcode/data/templated/simple-expected.html
new file mode 100644
index 00000000000..85d5e54aea0
--- /dev/null
+++ b/tests/formattedcode/data/templated/simple-expected.html
@@ -0,0 +1,251 @@
+
+
+
+
+
+
+ Custom Template
+
+
+
+ Scanned with ScanCode
+
+
+ Copyrights and Licenses Information
+
+
+ path
+ start
+ end
+ what
+ value
+
+
+
+
+
+
+ simple/copyright_acme_c-c.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+
+
+
+
+ File Information
+
+
+ path
+ type
+ name
+ extension
+ size
+ sha1
+ md5
+ files_count
+ mime_type
+ file_type
+ programming_language
+ is_binary
+ is_text
+ is_archive
+ is_media
+ is_source
+ is_script
+
+
+
+
+
+ simple
+ directory
+ simple
+
+ 0
+ None
+ None
+
+ None
+ None
+ None
+ False
+ False
+ False
+ False
+ False
+ False
+
+
+
+ simple/copyright_acme_c-c.c
+ file
+ copyright_acme_c-c.c
+ .c
+ 55
+ e2466d5b764d27fb301ceb439ffb5da22e43ab1d
+ bdf7c572beb4094c2059508fa73c05a4
+
+ text/plain
+ UTF-8 Unicode text, with no line terminators
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ Holders
+
+
+ path
+ holder
+ start
+ end
+
+
+
+
+
+
+
+
+
+ simple/copyright_acme_c-c.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ Authors
+
+
+ path
+ Author
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+ Emails
+
+
+ path
+ email
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+ Urls
+
+
+ path
+ url
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Package Information
+
+
+ path
+ type
+ packaging
+ primary_language
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ No content created from ScanCode should be considered or used as legal advice. Consult an Attorney for any legal advice.
+ ScanCode is a free software code scanning tool from nexB Inc. and others.
+ Visit http://www.nexb.com and https://github.com/nexB/scancode-toolkit/ for support and download.
+
+
\ No newline at end of file
diff --git a/tests/formattedcode/data/templated/tree/expected.html b/tests/formattedcode/data/templated/tree/expected.html
new file mode 100644
index 00000000000..6a79da819f0
--- /dev/null
+++ b/tests/formattedcode/data/templated/tree/expected.html
@@ -0,0 +1,557 @@
+
+
+
+
+
+
+ Custom Template
+
+
+
+ Scanned with ScanCode
+
+
+ Copyrights and Licenses Information
+
+
+ path
+ start
+ end
+ what
+ value
+
+
+
+
+
+
+ copy1.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ copy2.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ copy3.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ subdir/copy1.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ subdir/copy2.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ subdir/copy3.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+ subdir/copy4.c
+ 1
+ 1
+ copyright
+
+ Copyright (c) 2000 ACME, Inc.
+
+
+
+
+
+
+
+
+
+
+ File Information
+
+
+ path
+ type
+ name
+ extension
+ size
+ sha1
+ md5
+ files_count
+ mime_type
+ file_type
+ programming_language
+ is_binary
+ is_text
+ is_archive
+ is_media
+ is_source
+ is_script
+
+
+
+
+
+ copy1.c
+ file
+ copy1.c
+ .c
+ 91
+ 3922760d8492eb8f853c10a627f5a73f9eaec6ff
+ fc7f53659b7a9db8b6dff0638641778e
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ copy2.c
+ file
+ copy2.c
+ .c
+ 91
+ 3922760d8492eb8f853c10a627f5a73f9eaec6ff
+ fc7f53659b7a9db8b6dff0638641778e
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ copy3.c
+ file
+ copy3.c
+ .c
+ 91
+ c91811eb5fdc7ab440355f9f8d1580e1518b0c2f
+ e999e21c9d7de4d0f943aefbb6f21b99
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ subdir
+ directory
+ subdir
+
+ 0
+ None
+ None
+
+ None
+ None
+ None
+ False
+ False
+ False
+ False
+ False
+ False
+
+
+
+ subdir/copy1.c
+ file
+ copy1.c
+ .c
+ 91
+ 3922760d8492eb8f853c10a627f5a73f9eaec6ff
+ fc7f53659b7a9db8b6dff0638641778e
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ subdir/copy2.c
+ file
+ copy2.c
+ .c
+ 91
+ 3922760d8492eb8f853c10a627f5a73f9eaec6ff
+ fc7f53659b7a9db8b6dff0638641778e
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ subdir/copy3.c
+ file
+ copy3.c
+ .c
+ 84
+ 389af7e629a9853056e42b262d5e30bf4579a74f
+ 290627a1387288ef77ae7e07946f3ecf
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+ subdir/copy4.c
+ file
+ copy4.c
+ .c
+ 95
+ 58748872d25374160692f1ed7075d0fe80a544b1
+ 88e46475db9b1a68f415f6a3544eeb16
+
+ text/plain
+ UTF-8 Unicode text
+ C
+ False
+ True
+ False
+ False
+ True
+ False
+
+
+
+
+
+ Holders
+
+
+ path
+ holder
+ start
+ end
+
+
+
+
+
+
+
+ copy1.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ copy2.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ copy3.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+ subdir/copy1.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ subdir/copy2.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ subdir/copy3.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ subdir/copy4.c
+ ACME, Inc.
+ 1
+ 1
+
+
+
+
+
+
+
+ Authors
+
+
+ path
+ Author
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Emails
+
+
+ path
+ email
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Urls
+
+
+ path
+ url
+ start
+ end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Package Information
+
+
+ path
+ type
+ packaging
+ primary_language
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ No content created from ScanCode should be considered or used as legal advice. Consult an Attorney for any legal advice.
+ ScanCode is a free software code scanning tool from nexB Inc. and others.
+ Visit http://www.nexb.com and https://github.com/nexB/scancode-toolkit/ for support and download.
+
+
\ No newline at end of file
diff --git a/tests/formattedcode/test_output_templated.py b/tests/formattedcode/test_output_templated.py
index 6d752941baa..e2a13d881f4 100644
--- a/tests/formattedcode/test_output_templated.py
+++ b/tests/formattedcode/test_output_templated.py
@@ -114,17 +114,29 @@ def test_custom_format_with_custom_filename_fails_for_directory():
def normalize_quotes(s):
return s.replace("'", '"')
+@pytest.mark.scanslow
+def test_scan_custom_html_output_for_a_directory():
+ test_dir = test_env.get_test_loc('templated/tree/scan/')
+ custom_template = test_env.get_test_loc('templated/sample-template.html')
+ expected_file = test_env.get_test_loc('templated/tree/expected.html')
+ result_file = test_env.get_temp_file('html')
+ args = ['-clip', '--strip-root', '--custom-template', custom_template, '--custom-output', result_file, test_dir]
+ run_scan_click(args)
+ results = open(result_file).read()
+ expected = open(expected_file).read()
+ assert expected == results
@pytest.mark.scanslow
def test_custom_format_with_custom_filename():
test_dir = test_env.get_test_loc('templated/simple')
custom_template = test_env.get_test_loc('templated/sample-template.html')
+ expected_file = test_env.get_test_loc('templated/simple-expected.html')
result_file = test_env.get_temp_file('html')
- args = ['--info', '--custom-template', custom_template, '--custom-output', result_file, test_dir]
+ args = ['-clip', '--custom-template', custom_template, '--custom-output', result_file, test_dir]
run_scan_click(args)
results = open(result_file).read()
- assert 'Custom Template' in results
- assert __version__ in results
+ expected = open(expected_file).read()
+ assert expected == results
@pytest.mark.scanslow