mirror of https://github.com/ARMmbed/mbed-os.git
scancode: skip non code files
For instance pdf, or binaries - catch them as an exception and skip for additional SPDX checkpull/12437/head
parent
db989ba65a
commit
37a7ff0443
|
@ -81,17 +81,20 @@ def license_check(directory_name, file):
|
||||||
found_spdx = True
|
found_spdx = True
|
||||||
|
|
||||||
if not found_spdx:
|
if not found_spdx:
|
||||||
# Issue reported reported here https://github.com/nexB/scancode-toolkit/issues/1913
|
try:
|
||||||
# We verify here if SPDX is not really there as SDPX is part of the license text
|
# Issue reported here https://github.com/nexB/scancode-toolkit/issues/1913
|
||||||
# scancode has some problems detecting it properly
|
# We verify here if SPDX is not really there as SDPX is part of the license text
|
||||||
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
|
# scancode has some problems detecting it properly
|
||||||
filetext = spdx_file_check.read()
|
with open(os.path.join(os.path.abspath(license_offender['file']['path'])), 'r') as spdx_file_check:
|
||||||
matches = re.findall("SPDX-License-Identifier:?", filetext)
|
filetext = spdx_file_check.read()
|
||||||
if matches:
|
matches = re.findall("SPDX-License-Identifier:?", filetext)
|
||||||
|
if matches:
|
||||||
|
continue
|
||||||
|
license_offender['reason'] = MISSING_SPDX_TEXT
|
||||||
|
offenders.append(license_offender)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# not valid file for license check
|
||||||
continue
|
continue
|
||||||
license_offender['reason'] = MISSING_SPDX_TEXT
|
|
||||||
offenders.append(license_offender)
|
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
userlog.warning("Invalid scancode json file")
|
userlog.warning("Invalid scancode json file")
|
||||||
return -1
|
return -1
|
||||||
|
|
Loading…
Reference in New Issue