Skip to content

Commit

Permalink
Add check for licenses (#49)
Browse files Browse the repository at this point in the history
* add check if license info is not included in .json

* add warning

* code correction

* move a bit up

* add news

---------

Co-authored-by: jaimergp <[email protected]>
  • Loading branch information
SC426 and jaimergp authored Dec 12, 2023
1 parent 1a31241 commit 08d67f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions news/49-license-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Do not crash if the metadata in one or more packages does not specify a `license` field. (#49)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
6 changes: 5 additions & 1 deletion src/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ def dump_licenses(prefix, include_text=False, text_errors=None, output="licenses
licenses = defaultdict(dict)
for info_json in Path(prefix).glob("conda-meta/*.json"):
info = json.loads(info_json.read_text())
license_info = info.get("license")
if license_info is None:
print(f"WARNING: no license for {info['name']}")
continue
extracted_package_dir = info["extracted_package_dir"]
licenses_dir = os.path.join(extracted_package_dir, "info", "licenses")
licenses[info["name"]]["type"] = info["license"]
licenses[info["name"]]["type"] = license_info
licenses[info["name"]]["files"] = license_files = []
if not os.path.isdir(licenses_dir):
continue
Expand Down

0 comments on commit 08d67f0

Please sign in to comment.