Spaces:
Running
Running
Update src/aibom_generator/generator.py
Browse files
src/aibom_generator/generator.py
CHANGED
@@ -200,9 +200,23 @@ class AIBOMGenerator:
|
|
200 |
|
201 |
# Add critical fields for industry-neutral scoring (silently aligned with SPDX)
|
202 |
if metadata and "last_modified" in metadata:
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
204 |
# Add releaseTime as well if available, otherwise use last_modified
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
# Add downloadLocation if available
|
208 |
if metadata and "commit_url" in metadata:
|
@@ -383,6 +397,8 @@ class AIBOMGenerator:
|
|
383 |
try:
|
384 |
if isinstance(value, (list, dict)):
|
385 |
value = json.dumps(value)
|
|
|
|
|
386 |
properties.append({"name": key, "value": str(value)})
|
387 |
except Exception as e:
|
388 |
print(f"Error processing metadata property {key}: {e}")
|
|
|
200 |
|
201 |
# Add critical fields for industry-neutral scoring (silently aligned with SPDX)
|
202 |
if metadata and "last_modified" in metadata:
|
203 |
+
# Convert datetime to string before adding to AIBOM
|
204 |
+
if isinstance(metadata["last_modified"], datetime.datetime):
|
205 |
+
aibom["buildTime"] = metadata["last_modified"].isoformat() + "Z"
|
206 |
+
else:
|
207 |
+
aibom["buildTime"] = str(metadata["last_modified"])
|
208 |
+
|
209 |
# Add releaseTime as well if available, otherwise use last_modified
|
210 |
+
if "release_date" in metadata:
|
211 |
+
if isinstance(metadata["release_date"], datetime.datetime):
|
212 |
+
aibom["releaseTime"] = metadata["release_date"].isoformat() + "Z"
|
213 |
+
else:
|
214 |
+
aibom["releaseTime"] = str(metadata["release_date"])
|
215 |
+
else:
|
216 |
+
if isinstance(metadata["last_modified"], datetime.datetime):
|
217 |
+
aibom["releaseTime"] = metadata["last_modified"].isoformat() + "Z"
|
218 |
+
else:
|
219 |
+
aibom["releaseTime"] = str(metadata["last_modified"])
|
220 |
|
221 |
# Add downloadLocation if available
|
222 |
if metadata and "commit_url" in metadata:
|
|
|
397 |
try:
|
398 |
if isinstance(value, (list, dict)):
|
399 |
value = json.dumps(value)
|
400 |
+
elif isinstance(value, datetime.datetime):
|
401 |
+
value = value.isoformat() + "Z"
|
402 |
properties.append({"name": key, "value": str(value)})
|
403 |
except Exception as e:
|
404 |
print(f"Error processing metadata property {key}: {e}")
|