python-ort 0.9.1__py3-none-any.whl → 0.9.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-ort
3
- Version: 0.9.1
3
+ Version: 0.9.3
4
4
  Summary: A Python Ort model serialization library
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
14
14
  Classifier: Programming Language :: Python :: 3.14
15
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Requires-Dist: click>=8.4.1
16
17
  Requires-Dist: license-expression>=30.4.4
17
18
  Requires-Dist: packageurl-python>=0.17.6
18
19
  Requires-Dist: pydantic>=2.13.4
@@ -110,8 +110,10 @@ ort/utils/spdx/spdx_expression.py,sha256=K_ZsIGwLP_zNcS6haO2TFM1aRa2l79zFU7HZaB_
110
110
  ort/utils/spdx/spdx_license_choice.py,sha256=hop1tcSAq1ZWMd-504tAaCJ8KxzX_fp9_-r_LvEE2wc,1227
111
111
  ort/utils/validated_enum.py,sha256=UFAGP7BGzAx1nSBWEeMXn1X1teVb6507N-lfXBf5qGM,1643
112
112
  ort/utils/yaml_loader.py,sha256=kOiuRV93_q_ZUnAqHoNohAvqL7fkUn66WrvrdbgZKHs,1290
113
- python_ort-0.9.1.dist-info/licenses/LICENSE,sha256=koFhbHMglt1BNVuMKdBBlrQcgQsWLgo4pZW6cCtyGvA,1081
114
- python_ort-0.9.1.dist-info/WHEEL,sha256=8ZlpUMJ7mlDirmlHRhDirEx_nPnARrwDjeE92mlk68E,81
115
- python_ort-0.9.1.dist-info/entry_points.txt,sha256=v2_5_A1Rs4kGKx2g-6PZQoNwx_JlDy6pfWSjMNT_BMU,58
116
- python_ort-0.9.1.dist-info/METADATA,sha256=sHPosyqURDTMi8yzYbBRjrhjbYVdLnyeEnmRlocbV7Q,1405
117
- python_ort-0.9.1.dist-info/RECORD,,
113
+ tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
+ tools/ort_validate.py,sha256=fjz0laU903mieeMwqeWsNPY8aEGPQw-xDfvEauZq4NE,1758
115
+ python_ort-0.9.3.dist-info/licenses/LICENSE,sha256=koFhbHMglt1BNVuMKdBBlrQcgQsWLgo4pZW6cCtyGvA,1081
116
+ python_ort-0.9.3.dist-info/WHEEL,sha256=8ZlpUMJ7mlDirmlHRhDirEx_nPnARrwDjeE92mlk68E,81
117
+ python_ort-0.9.3.dist-info/entry_points.txt,sha256=v2_5_A1Rs4kGKx2g-6PZQoNwx_JlDy6pfWSjMNT_BMU,58
118
+ python_ort-0.9.3.dist-info/METADATA,sha256=ea3uYJNnYqv8oluYlyOvSLHOEMGIMcxQYEdngpZ5dv0,1433
119
+ python_ort-0.9.3.dist-info/RECORD,,
tools/__init__.py ADDED
File without changes
tools/ort_validate.py ADDED
@@ -0,0 +1,61 @@
1
+ # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com>
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ import logging
5
+ import sys
6
+ from pathlib import Path
7
+ from typing import TypeVar
8
+
9
+ import click
10
+ from pydantic import BaseModel, ValidationError
11
+
12
+ from ort import RepositoryConfiguration, ort_yaml_load
13
+ from ort.models import LicenseClassifications
14
+
15
+ logger = logging.getLogger()
16
+
17
+ ModelT = TypeVar("ModelT", bound=BaseModel)
18
+
19
+
20
+ def load_and_validate(model: type[ModelT], datafile: str) -> None:
21
+ """Load ``datafile`` as YAML, validate it into ``model`` and pretty-print the result."""
22
+ try:
23
+ with Path(datafile).open() as fd:
24
+ data = ort_yaml_load(fd)
25
+ parsed = model.model_validate(data or {})
26
+ logger.debug(parsed.model_dump_json(indent=2))
27
+ logger.info(f"Successfully validated {datafile} as {model.__name__}.")
28
+ except ValidationError:
29
+ logger.error("Validation error while parsing the ORT result:")
30
+ sys.exit(1)
31
+ except OSError as e:
32
+ logger.error(f"Error while opening the file {datafile}: {e}")
33
+ sys.exit(1)
34
+
35
+
36
+ @click.group()
37
+ @click.option("-d", "--debug", is_flag=True, help="Enable debug logging.")
38
+ def main(debug: bool = False) -> None:
39
+ logging.basicConfig(level=logging.DEBUG)
40
+ if debug:
41
+ logging.basicConfig(level=logging.DEBUG)
42
+ pass
43
+
44
+
45
+ @click.command()
46
+ @click.argument("datafile")
47
+ def license_classifications(datafile):
48
+ load_and_validate(LicenseClassifications, datafile)
49
+
50
+
51
+ @click.command()
52
+ @click.argument("datafile")
53
+ def repository_configuration(datafile):
54
+ load_and_validate(RepositoryConfiguration, datafile)
55
+
56
+
57
+ main.add_command(repository_configuration)
58
+ main.add_command(license_classifications)
59
+
60
+ if __name__ == "__main__":
61
+ main()