alitheg commented on code in PR #942:
URL: 
https://github.com/apache/tooling-trusted-releases/pull/942#discussion_r2993710087


##########
atr/sbom/utilities.py:
##########
@@ -138,10 +140,35 @@ def patch_to_data(patch_ops: models.patch.Patch) -> 
list[dict[str, Any]]:
     return [op.model_dump(by_alias=True, exclude_none=True) for op in 
patch_ops]
 
 
-def path_to_bundle(path: pathlib.Path) -> models.bundle.Bundle:
+def path_to_bundle(path: pathlib.Path) -> models.bundle.Bundle | None:
     text = path.read_text(encoding="utf-8")
-    bom = models.bom.Bom.model_validate_json(text)
-    return models.bundle.Bundle(doc=yyjson.Document(text), bom=bom, path=path, 
text=text)
+    bom: Bom | None = None
+    source_type: Literal["json", "xml"] | None = None
+    # Default to latest schema version
+    version_str: str | None = None
+    spec_version: SchemaVersion | None = None
+    if path.name.endswith(".json"):
+        bom_json: dict[str, Any] = json.loads(text)
+        bom = Bom.from_json(data=bom_json)
+        source_type = "json"
+        version_str = bom_json.get('specVersion', '1.7')

Review Comment:
   The formatter in pre-commit is changing all my single quotes back to double 
for some reason...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to