MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / cli

Function cli

etc/scripts/licenses/synclic.py:1430–1493  ·  view source on GitHub ↗

Synchronize ScanCode licenses with an external license source. DIR is the directory to store fetched external licenses (or where to load from already fetched licenses). Side-by-side with "DIR", three directories are created with new, updated or deleted licenses (with regards to Sca

(
    license_dir,
    source,
    match_text,
    match_approx,
    trace,
    create_external,
    update_external,
    commitish=None,
    use_cache=False,
)

Source from the content-addressed store, hash-verified

1428)
1429@click.help_option("-h", "--help")
1430def cli(
1431 license_dir,
1432 source,
1433 match_text,
1434 match_approx,
1435 trace,
1436 create_external,
1437 update_external,
1438 commitish=None,
1439 use_cache=False,
1440):
1441 """
1442 Synchronize ScanCode licenses with an external license source.
1443
1444 DIR is the directory to store fetched external licenses (or where to load
1445 from already fetched licenses). Side-by-side with "DIR", three directories
1446 are created with new, updated or deleted licenses (with regards to ScanCode
1447 licenses). The ScanCode licenses are collected from the current installation.
1448
1449 When using the dejacode source your need to set the 'DEJACODE_API_URL' and
1450 'DEJACODE_API_KEY' environment variables with your credentials.
1451 """
1452 global TRACE
1453 TRACE = trace
1454
1455 licenses_source_class = EXTERNAL_LICENSE_SYNCHRONIZATION_SOURCES[source]
1456 external_source = licenses_source_class(license_dir)
1457 scancode_licenses = ScanCodeLicenses()
1458
1459 use_spdx_key = source == "spdx"
1460 added_to_external, updated_in_external = synchronize_licenses(
1461 scancode_licenses,
1462 external_source,
1463 use_spdx_key=use_spdx_key,
1464 match_text=match_text,
1465 match_approx=match_approx,
1466 commitish=commitish,
1467 use_cache=use_cache,
1468 )
1469 print()
1470 if source == "dejacode":
1471 if create_external:
1472 api_url = external_source.api_base_url
1473 api_key = external_source.api_key
1474 for new_lic in added_to_external:
1475 if new_lic.key in dejacode_special_skippable_keys:
1476 continue
1477 if TRACE:
1478 print(f"Creating external: {new_lic}")
1479 create_or_update_license(api_url, api_key, lico=new_lic)
1480
1481 if update_external:
1482 externals_by_key = external_source.externals_by_key
1483 for modified_lic in updated_in_external:
1484 if modified_lic.key in dejacode_special_skippable_keys:
1485 continue
1486 mold = license_to_dict(modified_lic)
1487 original = externals_by_key[modified_lic.key]

Callers 1

synclic.pyFile · 0.70

Calls 4

ScanCodeLicensesClass · 0.85
synchronize_licensesFunction · 0.85
create_or_update_licenseFunction · 0.85
license_to_dictFunction · 0.85

Tested by

no test coverage detected