in tools/checker_demo.py [0:0]
def _check_conditions(out, licenses, allowed_conditions):
"""Check that the application does not use any disallowed licenses.
Args:
out: file object to write to
licenses: list of LicenseInfo objects
allowed_conditions: list of allowed condition names
Returns:
0 for no licenses from outside allowed_conditions.
"""
err = 0
for lic in licenses: # using strange name lic because license is built-in
rule = lic['rule']
for kind in lic['license_kinds']:
disallowed = []
for condition in kind['conditions']:
if condition not in allowed_conditions:
disallowed.append(condition)
if disallowed:
out.write('ERROR: %s\n' % rule)
out.write(' kind: %s\n' % kind['target'])
out.write(' conditions: %s\n' % kind['conditions'])
out.write(' disallowed condition: %s\n' % ','.join(disallowed))
err += 1
return err