Public Access
compare.py fasst nach Klassen zusammen
This commit is contained in:
+93
-56
@@ -19,68 +19,102 @@ 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")
|
||||
|
||||
class Module(object):
|
||||
def __init__(self, module):
|
||||
self.name = module
|
||||
self.versionen = {}
|
||||
self.classes = {}
|
||||
self.operations = []
|
||||
|
||||
def read_data(self):
|
||||
for version in versions():
|
||||
|
||||
vers = version.name.rsplit('.', 1)[0]
|
||||
self.versionen[vers] = {}
|
||||
|
||||
infile = version / f"{module}.json"
|
||||
|
||||
infile = version / f"{self.name}.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():
|
||||
|
||||
for f in data["files"]:
|
||||
f['version'] = vers
|
||||
file = f['file']
|
||||
classe = f.get('class', 'ohne')
|
||||
method = f.get('method', 'ohne')
|
||||
if classe not in self.versionen[vers]:
|
||||
self.versionen[vers][classe] = []
|
||||
self.versionen[vers][classe].append(f)
|
||||
try:
|
||||
if vers not in self.classes[classe]:
|
||||
self.classes[classe][vers] = []
|
||||
except KeyError:
|
||||
self.classes[classe] = {}
|
||||
self.classes[classe][vers] = []
|
||||
self.classes[classe][vers].append(f)
|
||||
for o in f['operations']:
|
||||
o['class'] = classe
|
||||
o['method'] = method
|
||||
o['file'] = file
|
||||
o['version'] = vers
|
||||
self.operations.append(o)
|
||||
|
||||
def write_data(self):
|
||||
|
||||
outfile = REPORTS / f"{self.name}.md"
|
||||
|
||||
with outfile.open("w", encoding="utf8") as out:
|
||||
|
||||
out.write(f"# {self.name}\n\n")
|
||||
|
||||
for c, classe in self.classes.items():
|
||||
|
||||
out.write(f"## Klasse {c}\n\n")
|
||||
|
||||
for k in sorted(self.versionen.keys()):
|
||||
v = classe.get(k, None)
|
||||
if not v:
|
||||
continue
|
||||
|
||||
out.write(f"### {k}\n\n")
|
||||
|
||||
for m in v:
|
||||
out.write(f"file: {m['file']} : {m['line']}\n")
|
||||
|
||||
for op in m["operations"]:
|
||||
|
||||
out.write(
|
||||
f" - {k}: `{v}`\n"
|
||||
f"- **{op['phase']}** "
|
||||
f"`{op['operation']}`\n"
|
||||
)
|
||||
|
||||
out.write("\n")
|
||||
|
||||
out.write("\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():
|
||||
@@ -90,8 +124,11 @@ def main():
|
||||
for module in modules():
|
||||
|
||||
print(module)
|
||||
|
||||
write_module(module)
|
||||
|
||||
mod = Module(module)
|
||||
|
||||
mod.read_data()
|
||||
mod.write_data()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user