Skip to content

Commit 9b4f0ca

Browse files
committed
Fixed #200 Do not treat file resource not found as problematic errors
* Lower the severity level for about_resource not found error to INFO level. As a result, this error will only be shown if user set the `--verbose` Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 61adbf6 commit 9b4f0ca

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/attributecode/cmd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from attributecode import model
3636
from attributecode import severities
3737
from attributecode.util import extract_zip
38-
from attributecode.util import ignore_about_resource_path_not_exist_error
38+
from attributecode.util import update_severity_level_about_resource_path_not_exist_error
3939
from attributecode.util import to_posix
4040

4141

@@ -161,7 +161,7 @@ def inventory(location, output, mapping, mapping_file, quiet, format, verbose):
161161
for err in write_errors:
162162
errors.append(err)
163163

164-
finalized_errors = ignore_about_resource_path_not_exist_error(errors)
164+
finalized_errors = update_severity_level_about_resource_path_not_exist_error(errors)
165165

166166
log_errors(finalized_errors, quiet, verbose, os.path.dirname(output))
167167
sys.exit(0)
@@ -239,7 +239,7 @@ def gen(location, output, mapping, mapping_file, license_notice_text_location, f
239239

240240
about_count = len(abouts)
241241
error_count = 0
242-
finalized_errors = ignore_about_resource_path_not_exist_error(errors)
242+
finalized_errors = update_severity_level_about_resource_path_not_exist_error(errors)
243243

244244
for e in finalized_errors:
245245
# Only count as warning/error if CRITICAL, ERROR and WARNING
@@ -325,7 +325,7 @@ def attrib(location, output, template, mapping, mapping_file, inventory, quiet,
325325
for no_match_error in no_match_errors:
326326
inv_errors.append(no_match_error)
327327

328-
finalized_errors = ignore_about_resource_path_not_exist_error(inv_errors)
328+
finalized_errors = update_severity_level_about_resource_path_not_exist_error(inv_errors)
329329

330330
log_errors(finalized_errors, quiet, verbose, os.path.dirname(output))
331331
click.echo('Finished.')

src/attributecode/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# Python 3
4747
import http.client as httplib
4848

49-
from attributecode import CRITICAL
49+
from attributecode import CRITICAL, INFO
5050
from attributecode import Error
5151

5252

@@ -534,12 +534,13 @@ def copy_license_notice_files(fields, base_dir, license_notice_text_location, af
534534
print('Cannot copy file at %(from_lic_path)r.' % locals())
535535

536536

537-
def ignore_about_resource_path_not_exist_error(errors):
537+
def update_severity_level_about_resource_path_not_exist_error(errors):
538538
ignore_resource_path_check_message = u'Field about_resource_path:'
539539
updated_errors = []
540540
for err in errors:
541541
if ignore_resource_path_check_message in err.message:
542-
continue
542+
updated_errors.append(Error(INFO, err.message))
543+
#continue
543544
else:
544545
updated_errors.append(err)
545546
return updated_errors

tests/test_util.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from testing_utils import on_windows
3030

3131
from attributecode import CRITICAL
32-
from attributecode import ERROR
32+
from attributecode import ERROR, INFO
3333
from attributecode import Error
3434
from attributecode import util
3535

@@ -440,8 +440,7 @@ def test_apply_mapping(self):
440440
])]
441441
assert util.apply_mapping(input) == expected
442442

443-
def test_ignore_about_resource_path_not_exist_error(self):
444-
input_err = [Error(ERROR, 'Field about_resource_path: test.tar.gz does not exist'),
445-
Error(ERROR, 'Field about_resource_path: test.tar.gz does not exist')]
446-
expected_err = []
447-
assert util.ignore_about_resource_path_not_exist_error(input_err) == expected_err
443+
def test_update_severity_level_about_resource_path_not_exist_error(self):
444+
input_err = [Error(ERROR, 'Field about_resource_path: test.tar.gz does not exist')]
445+
expected_err = [Error(INFO, 'Field about_resource_path: test.tar.gz does not exist')]
446+
assert util.update_severity_level_about_resource_path_not_exist_error(input_err) == expected_err

0 commit comments

Comments
 (0)