From 898ceb2a47c8f5c79f925ec2503ba145adcefca3 Mon Sep 17 00:00:00 2001 From: Sarthak Shubham Date: Mon, 3 Aug 2026 08:24:50 +0530 Subject: [PATCH 1/3] Update license scripts to support YAML frontmatter changes Signed-off-by: Sarthak Shubham --- etc/scripts/licenses/buildrules.py | 1 + etc/scripts/licenses/report_license_rules.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/etc/scripts/licenses/buildrules.py b/etc/scripts/licenses/buildrules.py index 6def6781a9f..ddf743bab79 100644 --- a/etc/scripts/licenses/buildrules.py +++ b/etc/scripts/licenses/buildrules.py @@ -294,6 +294,7 @@ def cli(licenses_file, dump_to_file_on_errors=False): """ rules_data = load_data(licenses_file) + click.echo("Loading existing rules to check for duplicates. This may take several minutes...") rule_by_tokens = all_rule_by_tokens() licenses_by_key = cache.get_licenses_db() diff --git a/etc/scripts/licenses/report_license_rules.py b/etc/scripts/licenses/report_license_rules.py index 7a5f84adada..32accda2606 100644 --- a/etc/scripts/licenses/report_license_rules.py +++ b/etc/scripts/licenses/report_license_rules.py @@ -83,8 +83,8 @@ def write_data_to_csv(data, output_csv, fieldnames): - with open(output_csv, "w") as f: - w = csv.DictWriter(f, fieldnames=fieldnames) + with open(output_csv, "w", encoding="utf-8") as f: + w = csv.DictWriter(f, fieldnames=fieldnames, extrasaction='ignore') w.writeheader() for entry in data: w.writerow(entry) @@ -180,6 +180,7 @@ def cli(licenses, rules, category, license_key, with_text): licenses_output = [] rules_output = [] + click.echo("Loading licenses from the database...") licenses_data = load_licenses() if licenses: @@ -208,8 +209,10 @@ def cli(licenses, rules, category, license_key, with_text): write_data_to_csv(data=licenses_output, output_csv=licenses, fieldnames=LICENSES_FIELDNAMES) if rules: - rules_data = list(load_rules()) - for rule in rules_data: + click.echo("Loading 30,000+ rules from the database. This will take several minutes, so please be patient...") + for i, rule in enumerate(load_rules()): + if i > 0 and i % 5000 == 0: + click.echo(f"Processed {i} rules...") rule_data = rule.to_dict() rule_data["identifier"] = rule.identifier rule_data["referenced_filenames"] = rule.referenced_filenames @@ -240,6 +243,9 @@ def cli(licenses, rules, category, license_key, with_text): rules_output = flatten_output(rules_output) write_data_to_csv(data=rules_output, output_csv=rules, fieldnames=RULES_FIELDNAMES) + if licenses or rules: + click.echo("Export complete! Check your CSV files.") + if __name__ == "__main__": cli() From 0af23f69ff809dcc89aca46153fdb9a1ae9a8f6c Mon Sep 17 00:00:00 2001 From: Sarthak Shubham Date: Mon, 3 Aug 2026 10:22:02 +0530 Subject: [PATCH 2/3] Add AUTHORS and CHANGELOG entries for #3138 Signed-off-by: Sarthak Shubham --- AUTHORS.rst | 1 + CHANGELOG.rst | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index 9a8224dc7da..4822396cf93 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -79,6 +79,7 @@ The following organizations or individuals have contributed to ScanCode: - Sankha Das @sankha555 - Saravanan G @SaravananOffl - Sarita Singh @itssingh +- Sarthak Shubham @sarthak-shubham - Savino Sguera @savinos - Sebastian Roth @ened - Sebastian Schuberth @sschuberth diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d9a5a6b4026..83b6059e415 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,13 @@ Next release ``licensedcode-data``. https://github.com/aboutcode-org/scancode-toolkit/pull/5056 +- Fix ``report_license_rules.py`` and ``buildrules.py`` in + ``etc/scripts/licenses/`` to work correctly with the YAML frontmatter + fields added in #3100. + https://github.com/aboutcode-org/scancode-toolkit/issues/3138 + + + v33.0.0rc1 - 2026-05-14 ------------------------ From 80b1e0aad76c6dcba5af18ec698bd93fe19e6fae Mon Sep 17 00:00:00 2001 From: Sarthak Shubham Date: Mon, 3 Aug 2026 10:35:30 +0530 Subject: [PATCH 3/3] Update CHANGELOG link to reference PR #5259 Signed-off-by: Sarthak Shubham --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 83b6059e415..94af05e6df7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,7 +11,7 @@ Next release - Fix ``report_license_rules.py`` and ``buildrules.py`` in ``etc/scripts/licenses/`` to work correctly with the YAML frontmatter fields added in #3100. - https://github.com/aboutcode-org/scancode-toolkit/issues/3138 + https://github.com/aboutcode-org/scancode-toolkit/pull/5259