Skip to content

Commit 9291077

Browse files
committed
#492 - Enhance performance
* Remove extra "deduplicate" function call. The `unique` is called in the `report_errors`, so we do not need to call the `unique` multiple time. Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 63fdeeb commit 9291077

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/attributecode/cmd.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def inventory(location, output, format, quiet, verbose): # NOQA
188188
errors, abouts = collect_inventory(location)
189189
write_output(abouts=abouts, location=output, format=format)
190190

191-
errors = unique(errors)
192191
errors_count = report_errors(errors, quiet, verbose, log_file_loc=output + '-error.log')
193192
if not quiet:
194193
msg = 'Inventory collected in {output}.'.format(**locals())
@@ -270,7 +269,6 @@ def gen(location, output, android, fetch_license, fetch_license_djc, reference,
270269
fetch_license_djc=fetch_license_djc,
271270
)
272271

273-
errors = unique(errors)
274272
errors_count = report_errors(errors, quiet, verbose, log_file_loc=output + '-error.log')
275273
if not quiet:
276274
abouts_count = len(abouts)
@@ -355,7 +353,6 @@ def gen_license(location, output, djc, scancode, verbose):
355353
if write_errors:
356354
errors.extend(write_errors)
357355

358-
errors = unique(errors)
359356
severe_errors_count = report_errors(errors, quiet=False, verbose=verbose, log_file_loc=log_file_loc)
360357
sys.exit(severe_errors_count)
361358

@@ -499,12 +496,11 @@ def attrib(input, output, api_url, api_key, scancode, min_license_score, referen
499496

500497
if not abouts:
501498
if errors:
502-
errors = unique(errors)
503499
errors_count = report_errors(errors, quiet, verbose, log_file_loc=output + '-error.log')
504500
else:
505501
msg = 'No ABOUT file or reference is found from the input. Attribution generation halted.'
506502
click.echo(msg)
507-
sys.exit(1)
503+
sys.exit(errors_count)
508504

509505
if not is_about_input:
510506
# Check if both api_url and api_key present
@@ -547,7 +543,6 @@ def attrib(input, output, api_url, api_key, scancode, min_license_score, referen
547543
)
548544
errors.extend(attrib_errors)
549545

550-
errors = unique(errors)
551546
errors_count = report_errors(errors, quiet, verbose, log_file_loc=output + '-error.log')
552547

553548
if not quiet:
@@ -714,7 +709,6 @@ def check(location, djc, log, verbose):
714709
for e in errs:
715710
errors.append(e)
716711

717-
errors = unique(errors)
718712
severe_errors_count = report_errors(errors, quiet=False, verbose=verbose, log_file_loc=log)
719713
sys.exit(severe_errors_count)
720714

@@ -796,7 +790,6 @@ def transform(location, output, configuration, quiet, verbose): # NOQA
796790
print_version()
797791
click.echo('Transforming...')
798792

799-
errors = unique(errors)
800793
errors_count = report_errors(errors, quiet, verbose, log_file_loc=output + '-error.log')
801794
if not quiet and not errors:
802795
msg = 'Transformed file is written to {output}.'.format(**locals())
@@ -817,7 +810,6 @@ def report_errors(errors, quiet, verbose, log_file_loc=None):
817810
file.
818811
Return True if there were severe error reported.
819812
"""
820-
errors = unique(errors)
821813
messages, severe_errors_count = get_error_messages(errors, quiet, verbose)
822814
for msg in messages:
823815
click.echo(msg)

0 commit comments

Comments
 (0)