Skip to content

Commit 57dc745

Browse files
committed
Fixed #397 - Log version used
* Add which version of TK was used to generated ABOUT files and attribution Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 4d1a4c7 commit 57dc745

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

src/attributecode/attrib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf8 -*-
33

44
# ============================================================================
5-
# Copyright (c) 2013-2018 nexB Inc. http://www.nexb.com/ - All rights reserved.
5+
# Copyright (c) 2013-2019 nexB Inc. http://www.nexb.com/ - All rights reserved.
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
88
# You may obtain a copy of the License at
@@ -25,6 +25,7 @@
2525

2626
import jinja2
2727

28+
from attributecode import __version__
2829
from attributecode import CRITICAL
2930
from attributecode import ERROR
3031
from attributecode import Error
@@ -124,6 +125,7 @@ def generate(abouts, template=None, variables=None):
124125
license_key_to_license_name=license_key_to_license_name,
125126
license_name_to_license_key=license_name_to_license_key,
126127
utcnow=utcnow,
128+
tkversion=__version__,
127129
variables=variables
128130
)
129131
except Exception as e:

src/attributecode/model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf8 -*-
33
# ============================================================================
4-
# Copyright (c) 2013-2018 nexB Inc. http://www.nexb.com/ - All rights reserved.
4+
# Copyright (c) 2013-2019 nexB Inc. http://www.nexb.com/ - All rights reserved.
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
@@ -51,6 +51,7 @@
5151

5252
from license_expression import Licensing
5353

54+
from attributecode import __version__
5455
from attributecode import CRITICAL
5556
from attributecode import ERROR
5657
from attributecode import INFO
@@ -69,6 +70,7 @@
6970
from attributecode.util import ungroup_licenses
7071
from attributecode.util import unique
7172

73+
genereated_tk_version = "# Generated with AboutCode Toolkit Version %s \n\n" % __version__
7274

7375
class Field(object):
7476
"""
@@ -1068,6 +1070,7 @@ def dump(self, location):
10681070
about_file_path = add_unc(about_file_path)
10691071

10701072
with io.open(about_file_path, mode='w', encoding='utf-8') as dumped:
1073+
dumped.write(genereated_tk_version)
10711074
dumped.write(self.dumps())
10721075

10731076
def dump_lic(self, location, license_dict):

src/attributecode/templates/default_html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
{% endfor %}
8282

8383
<h3><a id="End">End</a></h3>
84-
<i>This file was generated on: {{ utcnow }} (UTC)</i>
84+
<i>This file was generated with AboutCode Toolkit version: {{ tkversion }} on: {{ utcnow }} (UTC)</i>
8585
</body>
8686
</html>
8787

tests/test_model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,12 @@ def test_load_dump_is_idempotent(self):
752752

753753
expected = get_unicode_content(test_file).splitlines()
754754
result = get_unicode_content(dumped_file).splitlines()
755-
assert expected == result
755+
# Ignore comment and empty line
756+
filtered_result = []
757+
for line in result:
758+
if not line.startswith('#') and not line == '':
759+
filtered_result.append(line)
760+
assert expected == filtered_result
756761

757762
def test_load_can_load_unicode(self):
758763
test_file = get_test_loc('test_model/unicode/nose-selecttests.ABOUT')

0 commit comments

Comments
 (0)