Skip to content

Commit 37a7ff0

Browse files
committed
scancode: skip non code files
For instance pdf, or binaries - catch them as an exception and skip for additional SPDX check
1 parent db989ba commit 37a7ff0

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tools/test/travis-ci/scancode-evaluate.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,20 @@ def license_check(directory_name, file):
8181
found_spdx = True
8282

8383
if not found_spdx:
84-
# Issue reported reported here https://github.com/nexB/scancode-toolkit/issues/1913
85-
# We verify here if SPDX is not really there as SDPX is part of the license text
86-
# scancode has some problems detecting it properly
87-
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
88-
filetext = spdx_file_check.read()
89-
matches = re.findall("SPDX-License-Identifier:?", filetext)
90-
if matches:
84+
try:
85+
# Issue reported here https://github.com/nexB/scancode-toolkit/issues/1913
86+
# We verify here if SPDX is not really there as SDPX is part of the license text
87+
# scancode has some problems detecting it properly
88+
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
89+
filetext = spdx_file_check.read()
90+
matches = re.findall("SPDX-License-Identifier:?", filetext)
91+
if matches:
92+
continue
93+
license_offender['reason'] = MISSING_SPDX_TEXT
94+
offenders.append(license_offender)
95+
except UnicodeDecodeError:
96+
# not valid file for license check
9197
continue
92-
license_offender['reason'] = MISSING_SPDX_TEXT
93-
offenders.append(license_offender)
94-
9598
except KeyError:
9699
userlog.warning("Invalid scancode json file")
97100
return -1

0 commit comments

Comments
 (0)