Explorer
/tmp/fix_adopt.py
← Zurück ↓ Download
#!/usr/bin/env python3
"""Rebuild the ADOPT test section cleanly (quotes were stripped by shell)."""
p = '/tmp/p2w_test.py'
src = open(p).read()
i = src.find("m.inventory = lambda: [{uuid:")
j = src.find('q2 = c.execute', i)
assert i > 0 and j > i, (i, j)
clean = (
    'm.inventory = lambda: [{"uuid": "adopted-uuid-42",\n'
    '    "source_description": "import_identity:" + ("f"*64)}]\n'
)
src = src[:i] + clean + src[j:]
open(p, 'w').write(src)
import py_compile
py_compile.compile(p, doraise=True)
print('ADOPT section rebuilt + SYNTAX_OK')