Public Access
first version compare.py: compile changes by module
This commit is contained in:
+98
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DATA = Path("data")
|
||||
REPORTS = Path("reports")
|
||||
|
||||
|
||||
def versions():
|
||||
return sorted(
|
||||
[d for d in DATA.iterdir() if d.is_dir()],
|
||||
key=lambda p: [int(x) for x in p.name.split(".")]
|
||||
)
|
||||
|
||||
|
||||
def modules():
|
||||
first = versions()[0]
|
||||
return sorted(f.stem for f in first.glob("*.json"))
|
||||
|
||||
|
||||
def write_module(module):
|
||||
|
||||
outfile = REPORTS / f"{module}.md"
|
||||
|
||||
with outfile.open("w", encoding="utf8") as out:
|
||||
|
||||
out.write(f"# {module}\n\n")
|
||||
|
||||
for version in versions():
|
||||
|
||||
infile = version / f"{module}.json"
|
||||
|
||||
if not infile.exists():
|
||||
continue
|
||||
|
||||
out.write(f"## Version {version.name}\n\n")
|
||||
|
||||
data = json.loads(infile.read_text())
|
||||
|
||||
if not data:
|
||||
out.write("_no migrations found_\n\n")
|
||||
continue
|
||||
|
||||
for model in data['files']:
|
||||
|
||||
out.write(f"### {model['class']}\n\n")
|
||||
out.write(f"Line: {model['line']}\n\n")
|
||||
|
||||
for op in model["operations"]:
|
||||
|
||||
out.write(
|
||||
f"- **{op['phase']}** "
|
||||
f"`{op['operation']}`\n"
|
||||
)
|
||||
|
||||
if "condition" in op:
|
||||
out.write(
|
||||
f" - condition: `{op['condition']}`\n"
|
||||
)
|
||||
|
||||
if op["object"]:
|
||||
out.write(
|
||||
f" - object: `{op['object']}`\n"
|
||||
)
|
||||
|
||||
if op["args"]:
|
||||
out.write(
|
||||
f" - args: `{', '.join(op['args'])}`\n"
|
||||
)
|
||||
|
||||
if op["kwargs"]:
|
||||
out.write(" - kwargs:\n")
|
||||
|
||||
for k, v in op["kwargs"].items():
|
||||
out.write(
|
||||
f" - {k}: `{v}`\n"
|
||||
)
|
||||
|
||||
out.write("\n")
|
||||
|
||||
out.write("\n")
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
REPORTS.mkdir(exist_ok=True)
|
||||
|
||||
for module in modules():
|
||||
|
||||
print(module)
|
||||
|
||||
write_module(module)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user