示例#1
0
def do_import_licenses(file_data: List[dict]):
    imported = set()
    print('Importing licenses ... ', flush=True)
    for idx, p in enumerate(file_data):
        info = p.get('info')
        license_text = detect_license(info.get('license'))

        if license_text and license_text not in imported:
            imported.add(license_text)
            session = db_session.create_session()

            package_license = License()
            package_license.id = license_text
            package_license.description = info.get('license')

            session.add(package_license)
            session.commit()

    sys.stderr.flush()
    sys.stdout.flush()
示例#2
0
def do_import_licenses(file_data: List[dict]):
    imported = set()
    print("Importing licenses ... ", flush=True)
    with progressbar.ProgressBar(max_value=len(file_data)) as bar:
        for idx, p in enumerate(file_data):
            info = p.get('info')
            license_text = detect_license(info.get('license'))

            if license_text and license_text not in imported:
                imported.add(license_text)
                session = db_session.create_session()

                package_license = License()
                package_license.id = license_text
                package_license.description = info.get('license')

                session.add(package_license)
                session.commit()

            bar.update(idx)

    sys.stderr.flush()
    sys.stdout.flush()