コード例 #1
0
ファイル: spdx_checker.py プロジェクト: klimkin/hooks
def check_license(output, license_id):
    license_value = spdx_lookup.by_id(license_id)
    # use case-sensitive check
    if license_value and license_value.id == license_id:
        output.info('license "%s" is a valid SPDX license identifier' %
                    license_id)
    else:
        output.error('license "%s" is not a valid SPDX license identifier' %
                     license_id)
コード例 #2
0
def check_license(main, recipe_license):
    if spdx_lookup.by_id(recipe_license):
        main.output_result_check(passed=True, title="SPDX License identifier")
        return True
    else:
        main.output_result_check(
            passed=False,
            title="SPDX License identifier",
            reason="identifier doesn't seem to be a valid SPDX one. "
            "Have a look at https://spdx.org/licenses/")
        return False
コード例 #3
0
def check_for_spdx_license(main, file):
    conan_instance, _, _ = conan_api.Conan.factory()
    try:
        recipe_license = conan_instance.inspect(path=file, attributes=['license'])['license']
        if spdx_lookup.by_id(recipe_license):
            main.output_result_check(passed=True, title="SPDX License identifier")
            return True
        else:
            main.output_result_check(passed=False, title="SPDX License identifier",
                                reason="identifier doesn't seem to be a valid SPDX one. Have a look at https://spdx.org/licenses/")
            return False
    except ConanException:
        main.output_result_check(passed=False, title="SPDX License identifier",
                            reason="could not get the license attribute from the Conanfile")
        return False
コード例 #4
0
def main():
    p = argparse.ArgumentParser(prog='spdx-lookup')

    g = p.add_argument_group('Lookup method')
    x = g.add_mutually_exclusive_group(required=True)
    x.add_argument('-i', '--id', help='Find license with given identifier')
    x.add_argument('-n', '--name', help='Find license with given name')
    x.add_argument('-d', '--dir', help='Search directory for valid license')
    x.add_argument('-f',
                   '--file',
                   type=argparse.FileType('r'),
                   help='Read file to detect license')

    g = p.add_subparsers(dest='action', title='Actions')
    g.required = True
    g.add_parser('template', help='print license template')
    g.add_parser('info', help='print metadata about license')

    args = p.parse_args()

    if args.id:
        res = lookup.by_id(args.id)
    elif args.name:
        res = lookup.by_name(args.name)
    elif args.dir:
        res = lookup.match_path(args.dir)
    elif args.file:
        res = lookup.match(args.file.read())
        args.file.close()

    if res is None:
        print("No supported license was detected.")
        return 1

    if args.action == 'info':
        print_info(res)
    elif args.action == 'template':
        print_license(res)
コード例 #5
0
ファイル: check.py プロジェクト: tkas/editor-layer-index
        ## dict_raise_on_duplicates raises error on duplicate keys in geojson
        source = json.load(io.open(filename, encoding='utf-8'), object_pairs_hook=dict_raise_on_duplicates)

        ## jsonschema validate
        validator.validate(source, schema)
        sourceid = source['properties']['id']
        if sourceid in seen_ids:
            raise ValidationError('Id %s used multiple times' % sourceid)
        seen_ids.add(sourceid)

        ## {z} instead of {zoom}
        if '{z}' in source['properties']['url']:
            raise ValidationError('{z} found instead of {zoom} in tile url')
        if 'license' in source['properties']:
            license = source['properties']['license']
            if not spdx_lookup.by_id(license) and license != 'COMMERCIAL':
                raise ValidationError('Unknown license %s' % license)
        else:
            logger.debug("{} has no license property".format(filename))

        ## Check for license url. Too many missing to mark as required in schema.
        if 'license_url' not in source['properties']:
            logger.debug("{} has no license_url".format(filename))
        if 'attribution' not in source['properties']:
            logger.debug("{} has no attribution".format(filename))

        ## Check for big fat embedded icons
        if 'icon' in source['properties']:
            if source['properties']['icon'].startswith("data:"):
                iconsize = len(source['properties']['icon'].encode('utf-8'))
                spacesave += iconsize
コード例 #6
0
ファイル: spdx_checker.py プロジェクト: yssource/hooks
def check_license(output, license_id):
    if spdx_lookup.by_id(license_id):
        output.info('license "%s" is a valid SPDX license identifier' % license_id)
    else:
        output.error('license "%s" is not a valid SPDX license identifier' % license_id)
コード例 #7
0
ファイル: extract-fedora.py プロジェクト: abate/LicenseMatrix
 gpl2 = row[3].strip()
 gpl3 = row[4].strip()
 url = row[5].strip()
 name_norm = None
 spdxid_norm = None
 matchLicense = 0
 print "Examining ID %s" % spdxid
 print "Examining NAME %s" % name
 lname = lookup.by_name(name)
 if lname:
     print "Match %s" % lname
     name_norm = lname.name
     spdxid_norm = lname.id
     matchLicense = 100
 else:
     lid = lookup.by_id(spdxid)
     if lid:
         print "Match %s" % lid
         spdxid_norm = lid.id
         name_norm = lid.name
         matchLicense = 100
     else:
         match = lookup.match(name)
         if match:
             print "Match Lookup %s" % match.license
             name_norm = match.license
             print match
             matchLicense = match.confidence
         (fuzzyid, c) = process.extractOne(spdxid, lincensesIDS)
         if c >= 95:
             print "Fuzzy IDS: ", fuzzyid
コード例 #8
0
        source = json.load(io.open(filename, encoding='utf-8'),
                           object_pairs_hook=dict_raise_on_duplicates)

        ## jsonschema validate
        validator.validate(source, schema)
        sourceid = source['properties']['id']
        if sourceid in seen_ids:
            raise ValidationError('Id %s used multiple times' % sourceid)
        seen_ids.add(sourceid)

        ## {z} instead of {zoom}
        if '{z}' in source['properties']['url']:
            raise ValidationError('{z} found instead of {zoom} in tile url')
        if 'license' in source['properties']:
            license = source['properties']['license']
            if not spdx_lookup.by_id(license):
                raise ValidationError('Unknown license %s' % license)
        else:
            logger.debug("{} has no license property".format(filename))

        ## Check for license url. Too many missing to mark as required in schema.
        if 'license_url' not in source['properties']:
            logger.debug("{} has no license_url".format(filename))
        if 'attribution' not in source['properties']:
            logger.debug("{} has no attribution".format(filename))

        ## Check for big fat embedded icons
        if 'icon' in source['properties']:
            if source['properties']['icon'].startswith("data:"):
                iconsize = len(source['properties']['icon'].encode('utf-8'))
                spacesave += iconsize