Skip to content

Commit 9acae9b

Browse files
committed
Remove unused import
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent f545353 commit 9acae9b

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

src/attributecode/attrib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
# limitations under the License.
1515
# ============================================================================
1616

17-
import collections
1817
import datetime
19-
import io
2018
import os
2119

2220
import jinja2

src/attributecode/cmd.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# ============================================================================
1616

1717
from attributecode.util import write_licenses
18-
from attributecode.util import get_file_text
1918
from attributecode.util import get_temp_dir
2019
from attributecode.util import filter_errors
2120
from attributecode.util import extract_zip
@@ -34,7 +33,7 @@
3433
from attributecode.model import collect_inventory, collect_abouts_license_expression, collect_inventory_license_expression
3534
from attributecode.gen import generate as generate_about_files, load_inventory
3635
from attributecode.attrib import generate_and_save as generate_attribution_doc
37-
from attributecode.attrib import DEFAULT_TEMPLATE_FILE, DEFAULT_LICENSE_SCORE
36+
from attributecode.attrib import DEFAULT_LICENSE_SCORE
3837
from attributecode.attrib import check_template
3938
from attributecode import severities
4039
from attributecode import __version__
@@ -45,8 +44,6 @@
4544
from collections import defaultdict
4645
from functools import partial
4746

48-
import io
49-
import logging
5047
import os
5148
import sys
5249

src/attributecode/gen.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
# limitations under the License.
1515
# ============================================================================
1616

17-
import codecs
18-
1917
from posixpath import basename
2018
from posixpath import dirname
2119
from posixpath import exists
@@ -34,7 +32,6 @@
3432
from attributecode.util import invalid_chars
3533
from attributecode.util import to_posix
3634
from attributecode.util import UNC_PREFIX_POSIX
37-
from attributecode.util import unique
3835
from attributecode.util import load_scancode_json, load_csv, load_json, load_excel
3936

4037

src/attributecode/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
components inventories.
2525
"""
2626

27-
import io
2827
import json
2928
import os
3029
import posixpath
@@ -66,7 +65,6 @@
6665
from attributecode.util import UNC_PREFIX
6766
from attributecode.util import ungroup_licenses
6867
from attributecode.util import ungroup_licenses_from_sctk
69-
from attributecode.util import unique
7068

7169
genereated_tk_version = "# Generated with AboutCode Toolkit Version %s \n\n" % __version__
7270

src/attributecode/util.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
on_windows = 'win32' in sys.platform
3737

3838
# boolean field name
39-
boolean_fields = ['redistribute', 'attribute', 'track_change', 'modified', 'internal_use_only']
40-
file_fields = ['about_resource', 'notice_file', 'changelog_file', 'author_file']
39+
boolean_fields = ['redistribute', 'attribute',
40+
'track_change', 'modified', 'internal_use_only']
41+
file_fields = ['about_resource', 'notice_file',
42+
'changelog_file', 'author_file']
4143

4244

4345
def to_posix(path):
@@ -56,7 +58,8 @@ def to_posix(path):
5658
UNC_PREFIXES = (UNC_PREFIX_POSIX, UNC_PREFIX,)
5759

5860
valid_file_chars = '_-.+()~[]{}@%!$,'
59-
invalid_file_chars = string.punctuation.translate(str.maketrans("", "", valid_file_chars))
61+
invalid_file_chars = string.punctuation.translate(
62+
str.maketrans("", "", valid_file_chars))
6063

6164

6265
def invalid_chars(path):
@@ -260,13 +263,15 @@ def load_csv(location):
260263
"""
261264
results = []
262265
with open(location, mode='r', encoding='utf-8-sig',
263-
errors='replace') as csvfile:
266+
errors='replace') as csvfile:
264267
for row in csv.DictReader(csvfile):
265268
# convert all the column keys to lower case
266-
updated_row = {key.lower().strip(): value for key, value in row.items()}
269+
updated_row = {key.lower().strip(): value for key,
270+
value in row.items()}
267271
results.append(updated_row)
268272
return results
269273

274+
270275
def load_json(location):
271276
"""
272277
Read JSON file at `location` and return a list of ordered dicts, one for
@@ -394,9 +399,11 @@ def copy_license_notice_files(fields, base_dir, reference_dir, afp):
394399
continue
395400

396401
for copy_file_name in file_list:
397-
from_lic_path = posixpath.join(to_posix(reference_dir), copy_file_name)
402+
from_lic_path = posixpath.join(
403+
to_posix(reference_dir), copy_file_name)
398404
about_file_dir = os.path.dirname(to_posix(afp)).lstrip('/')
399-
to_lic_path = posixpath.join(to_posix(base_dir), about_file_dir)
405+
to_lic_path = posixpath.join(
406+
to_posix(base_dir), about_file_dir)
400407
if not os.path.exists(posixpath.join(to_lic_path, copy_file_name)):
401408
err = copy_file(from_lic_path, to_lic_path)
402409
if err:
@@ -449,6 +456,7 @@ def copy_file(from_path, to_path):
449456
error = Error(CRITICAL, msg)
450457
return error
451458

459+
452460
def ungroup_licenses_from_sctk(value):
453461
# Return a list of dictionary with lic_key and score
454462
# extracted from SCTK scan
@@ -461,6 +469,8 @@ def ungroup_licenses_from_sctk(value):
461469
return detected_license_list
462470

463471
# FIXME: we should use a license object instead
472+
473+
464474
def ungroup_licenses(licenses):
465475
"""
466476
Ungroup multiple licenses information
@@ -537,7 +547,8 @@ def format_about_dict_for_json_output(about_dictionary_list):
537547
row_list[key] = element[key]
538548

539549
# Group the same license information in a list
540-
license_group = list(zip_longest(license_key, license_name, license_file, license_url))
550+
license_group = list(zip_longest(
551+
license_key, license_name, license_file, license_url))
541552
if license_group:
542553
licenses_list = []
543554
for lic_group in license_group:
@@ -616,6 +627,7 @@ def build_temp_dir(prefix='attributecode-'):
616627
create_dir(location)
617628
return location
618629

630+
619631
def get_file_text(file_name, reference):
620632
"""
621633
Return the file content from the license_file/notice_file field from the
@@ -629,10 +641,11 @@ def get_file_text(file_name, reference):
629641
error = Error(CRITICAL, msg)
630642
else:
631643
with codecs.open(file_path, 'rb', encoding='utf-8-sig', errors='replace') as txt:
632-
#with io.open(file_path, encoding='utf-8') as txt:
644+
# with io.open(file_path, encoding='utf-8') as txt:
633645
text = txt.read()
634646
return error, text
635647

648+
636649
def convert_object_to_dict(about):
637650
"""
638651
Convert the list of field object
@@ -650,6 +663,7 @@ def convert_object_to_dict(about):
650663
about_dict[key] = value
651664
return about_dict
652665

666+
653667
def load_scancode_json(location):
654668
"""
655669
Read the scancode JSON file at `location` and return a list of dictionaries.
@@ -671,6 +685,7 @@ def load_scancode_json(location):
671685
updated_results.append(updated_dict)
672686
return updated_results
673687

688+
674689
def load_excel(location, worksheet=None):
675690
"""
676691
Read XLSX at `location`, return a list of ordered dictionaries, one
@@ -723,6 +738,7 @@ def load_excel(location, worksheet=None):
723738
results.append(row_dict)
724739
return errors, results
725740

741+
726742
def write_licenses(lic_dict, location):
727743
import io
728744

0 commit comments

Comments
 (0)