コード例 #1
0
ファイル: project-license.py プロジェクト: jens-erdmann/flict
def setup():
    global project
    global PROJECT_FILE
    global license_handler
    if license_handler == None:
        license_handler = LicenseHandler("var/translation.json",
                                         "var/relicense.json", "")
    if project == None:
        project = Project(PROJECT_FILE, license_handler)
コード例 #2
0
def output_outbound_license(compatibility, license_handler, licenses, output_format, extended_licenses):
    project = Project(None, license_handler, licenses)
    license = license_handler.license_expression_list(licenses)
    report_object = Report(project, compatibility)
    report = report_object.report()
    suggested_outbounds = report['compatibility_report']['compatibilities']['outbound_suggestions']
    
    if output_format.lower() == "json":
        print(json.dumps(suggested_outbounds))
    elif output_format.lower() == "markdown":
        print("MARKDOWN COMING SOON: " + str(suggested_outbounds))
    else:
        print("For \"" + str(licenses) + "\"", end=" ")
        if suggested_outbounds != None and len(suggested_outbounds) > 0:
            print("you can chose any of the following outbound suggestions:")
            for lic in suggested_outbounds:
                print(" * " + str(lic))
        else:
            print("we found no possible outbound license")
コード例 #3
0
ファイル: project.py プロジェクト: jens-erdmann/flict
def setup_big():
    license_handler = LicenseHandler(TRANSLATION_FILE, RELICENSE_FILE, "")
    project = Project(PROJECT_FILE_BIG, license_handler)
    return project
コード例 #4
0
ファイル: project.py プロジェクト: jens-erdmann/flict
def setup_small():
    license_handler = LicenseHandler(TRANSLATION_FILE, RELICENSE_FILE, "")
    #compatibility = Compatibility(args.matrix_file, args.scancode_file, args.license_group_file)

    project = Project(PROJECT_FILE_SMALL, license_handler)
    return project
コード例 #5
0
def main():
    args = parse()
    setup(args)

    license_handler = LicenseHandler(args.translations_file,
                                     args.relicense_file, "")
    compatibility = Compatibility(args.matrix_file, args.scancode_file,
                                  args.license_group_file,
                                  args.extended_licenses)

    if args.licenses:
        _licenses = []
        for lic in args.licenses:
            new_lic = license_handler.translate_and_relicense(lic).replace(
                "(", "").replace(")", "").replace(" ", "").replace(
                    "OR", " ").replace("AND", " ").strip().split(" ")
            _licenses += new_lic
            #print(lic + " ==> " + str(new_lic) + " =====> " + str(licenses))
        #print("Check compat for: " + str(licenses))

        # Diry trick to remove all duplicates
        licenses = list(set(_licenses))

        compats = compatibility.check_compatibilities(licenses,
                                                      args.extended_licenses)
        output_compat(compats, args.output_format, args.verbose)

    elif args.outbound_licenses:
        output_outbound_license(compatibility, license_handler,
                                args.outbound_licenses, args.output_format,
                                args.extended_licenses)

    elif args.list_supported_licenses:
        output_supported_licenses(compatibility, args.output_format)

    elif args.list_supported_license_groups:
        output_supported_license_groups(compatibility, args.output_format)

    elif args.license_expression_states:
        managed_license = license_handler.license_expression_list(
            args.license_expression_states)
        print(license_to_string_long(managed_license))

    elif args.license_expression:
        license = license_handler.license_expression_list(
            args.license_expression)
        if args.verbose:
            license._debug_license(license)
            print(license_to_string_long(license))
        else:
            print(license.simplified)

    elif args.compliance_report_file:
        if args.policy_file == None:
            error("Missing policy file.... bailing out")
            exit(23)
        policy = Policy(args.policy_file)
        report = read_compliance_report(args.compliance_report_file)
        policy_report = policy.report(report)
        ret = policy_report['policy_outbounds']['policy_result']
        print(json.dumps(policy_report))
        exit(ret)

    elif args.license_group:
        output_license_group(compatibility, license_handler, args)

    elif args.new:
        project = Project(args.project_file, license_handler)
        combined_license = project.new_license_set(license_handler)

    else:
        project = Project(args.project_file, license_handler)
        if project == None:
            error("Could not read project file \"" + args.project_file + "\"")
            exit(4)

        if args.list_project_licenses:
            output_license_list(list(project.license_set()),
                                args.output_format)
        elif args.license_combination_count:
            output_license_combinations(project, args.output_format)

        #print(str(project.project_combination_list()))

        else:

            report = Report(project, compatibility)

            print(json.dumps(report.report()))
            exit(0)

            if report.report() == None:
                exit(20)
            else:
                exit(0)