Skip to content

Commit ccd758f

Browse files
committed
style slight reformats of helpers
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 35bf568 commit ccd758f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

schema/cryptography-defs.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"$id": "http://cyclonedx.org/schema/cryptography-defs.schema.json",
4-
"$comment": "2025-09-07T12:38:20.698660",
4+
"$comment": "2025-09-07T11:12:52Z",
55
"title": "Cryptographic Algorithm Family Definitions",
66
"description": "Enumerates cryptographic algorithm families and their specific metadata.",
77
"type": "object",
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
#!/usr/bin/env python3
22

3-
import json
4-
from datetime import datetime
3+
from json import dump as json_dump, load as json_load
4+
from datetime import datetime, timezone
55
from pathlib import Path
6-
from typing import Dict, List, Any
6+
from typing import Any, Dict, List
77

8-
# Step 1: Load JSON data safely using context managers
9-
SCHEMA_DIR = Path(__file__).parent.parent / "../../../schema"
8+
# config
9+
SCHEMA_DIR = Path(__file__).parent.parent.parent.parent.parent / "schema"
1010
DEFS_FILE = SCHEMA_DIR / "cryptography-defs.json"
1111
SCHEMA_FILE = SCHEMA_DIR / "cryptography-defs.schema.json"
1212

13+
# Step 1: Load JSON data safely using context managers
1314
with DEFS_FILE.open("r", encoding="utf-8") as defs_file:
14-
defs_data: Dict[str, List[Dict[str, Any]]] = json.load(defs_file)
15+
defs_data: Dict[str, List[Dict[str, Any]]] = json_load(defs_file)
1516

1617
with SCHEMA_FILE.open("r", encoding="utf-8") as schema_file:
17-
schema_data: Dict[str, Any] = json.load(schema_file)
18+
schema_data: Dict[str, Any] = json_load(schema_file)
1819

1920
# Step 2: Extract unique algorithm families and sort them
2021
families: List[str] = sorted({algo['family'] for algo in defs_data.get('algorithms', [])})
@@ -25,7 +26,8 @@
2526
except KeyError as e:
2627
raise KeyError(f"Required schema property 'properties' missing: {e}")
2728

28-
schema_data['$comment'] = datetime.now().isoformat()
29+
schema_data['$comment'] = datetime.now(timezone.utc).replace(microsecond=0) \
30+
.isoformat().replace('+00:00', 'Z')
2931

3032
schema_data['definitions']['algorithmFamiliesEnum'] = {
3133
"type": "string",
@@ -36,6 +38,6 @@
3638

3739
# Step 4: Write the updated schema back to the file
3840
with SCHEMA_FILE.open("w", encoding="utf-8") as update_file:
39-
json.dump(schema_data, update_file, indent=2, ensure_ascii=False)
41+
json_dump(schema_data, update_file, indent=2, ensure_ascii=False)
4042

4143
print("Schema updated successfully.")

0 commit comments

Comments
 (0)