Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/pull/5259



v33.0.0rc1 - 2026-05-14
------------------------

Expand Down
1 change: 1 addition & 0 deletions etc/scripts/licenses/buildrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 10 additions & 4 deletions etc/scripts/licenses/report_license_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Loading