scancode: skip non code files

For instance pdf, or binaries - catch them as an exception and skip for
additional SPDX check
pull/12437/head
Martin Kojtal 2020-02-21 09:14:30 +00:00
parent db989ba65a
commit 37a7ff0443
1 changed files with 13 additions and 10 deletions

View File

@ -81,7 +81,8 @@ def license_check(directory_name, file):
found_spdx = True
if not found_spdx:
# Issue reported reported here https://github.com/nexB/scancode-toolkit/issues/1913
try:
# Issue reported here https://github.com/nexB/scancode-toolkit/issues/1913
# We verify here if SPDX is not really there as SDPX is part of the license text
# scancode has some problems detecting it properly
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
@ -91,7 +92,9 @@ def license_check(directory_name, file):
continue
license_offender['reason'] = MISSING_SPDX_TEXT
offenders.append(license_offender)
except UnicodeDecodeError:
# not valid file for license check
continue
except KeyError:
userlog.warning("Invalid scancode json file")
return -1