Skip to content

Commit 0cba7b8

Browse files
committed
Use util.unique and prefer os.path to posixpath
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent d7be24b commit 0cba7b8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/attributecode/model.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import codecs
3333
import json
3434
import os
35+
# FIXME: why posixpath???
3536
import posixpath
36-
from posixpath import dirname
3737

3838
import yaml
3939
import re
@@ -65,8 +65,9 @@
6565
from attributecode.util import add_unc
6666
from attributecode.util import copy_license_notice_files
6767
from attributecode.util import on_windows
68-
from attributecode.util import ungroup_licenses
6968
from attributecode.util import UNC_PREFIX
69+
from attributecode.util import ungroup_licenses
70+
from attributecode.util import unique
7071

7172

7273
class Field(object):
@@ -1275,7 +1276,6 @@ def collect_inventory(location, use_mapping=False, mapping_file=None):
12751276
About objects.
12761277
"""
12771278
errors = []
1278-
dedup_errors = []
12791279
input_location = util.get_absolute(location)
12801280
about_locations = list(util.get_about_locations(input_location))
12811281

@@ -1291,11 +1291,7 @@ def collect_inventory(location, use_mapping=False, mapping_file=None):
12911291
errors.append(Error(severity, msg))
12921292
abouts.append(about)
12931293

1294-
# Avoid logging duplicated/same errors multiple times
1295-
for about_error in errors:
1296-
if not about_error in dedup_errors:
1297-
dedup_errors.append(about_error)
1298-
return dedup_errors, abouts
1294+
return unique(errors), abouts
12991295

13001296

13011297
def field_names(abouts, with_paths=True, with_absent=True, with_empty=True):
@@ -1560,7 +1556,7 @@ def verify_license_files_in_location(about, lic_location):
15601556
for lic in about.license_file.value:
15611557
lic_path = util.to_posix(posixpath.join(lic_location, lic))
15621558
if posixpath.exists(lic_path):
1563-
copy_to = dirname(about.about_file_path)
1559+
copy_to = os.path.dirname(about.about_file_path)
15641560
license_location_dict[copy_to] = lic_path
15651561
else:
15661562
msg = (u'The license file : '

0 commit comments

Comments
 (0)