OXYGENHUB
# 85ef828b6bf0 oxygen / fix.py
1.4 KiB · Python · last changed Diffs no longer anchor a block of new lines one line early 1 month ago source blame history raw
1
with open('/home/andymccall/development/oxygen/docs/xenon_spec.md', 'r') as f:
2
    text = f.read()
3
4
# Remove all existing ```json, ```cbor, ``` blocks to start clean
5
import re
6
text = re.sub(r'```[a-z]*\n', '', text)
7
text = re.sub(r'```\n', '', text)
8
9
# Now, apply the blocks properly
10
text = text.replace('Receipt {\n', '```cbor\nReceipt {\n')
11
text = text.replace('  duration_ms    [8]: u64\n}\n', '  duration_ms    [8]: u64\n}\n```\n')
12
13
text = text.replace('Attest {\n', '```json\nAttest {\n')
14
text = text.replace('      "reproducible": bool\n    }\n  }\n}\n', '      "reproducible": bool\n    }\n  }\n}\n```\n')
15
16
text = text.replace('Signature {\n', '```cbor\nSignature {\n')
17
text = text.replace('  ml  [3]: bytes(3309)                 // Post-quantum signature\n}\n', '  ml  [3]: bytes(3309)                 // Post-quantum signature\n}\n```\n')
18
19
text = text.replace('PolicyRule {\n', '```json\nPolicyRule {\n')
20
text = text.replace('      signer_roles: [ "official-worker" ]\n    }\n  ]\n}\n', '      signer_roles: [ "official-worker" ]\n    }\n  ]\n}\n```\n')
21
22
# KDL block is already fixed mostly, let's ensure it's clean
23
if '```kdl' not in text:
24
    text = text.replace('schema-version 1\n', '```kdl\nschema-version 1\n')
25
    text = text.replace('    }\n}\n\n### 3.2', '    }\n}\n```\n\n### 3.2')
26
27
with open('/home/andymccall/development/oxygen/docs/xenon_spec.md', 'w') as f:
28
    f.write(text)