diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2022-01-20 18:51:27 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-01-20 18:51:27 +0000 |
commit | 7e055c6eaf4291539c77932b29b8db0cc42c5d8c (patch) | |
tree | e59febf7e5ae32578e9455ff86942057013f4270 /jinja_helpers.py | |
parent | e39f4203ca1c08827bfe9b9a35c2034d71703624 (diff) | |
download | Smarker-7e055c6eaf4291539c77932b29b8db0cc42c5d8c.tar.gz Smarker-7e055c6eaf4291539c77932b29b8db0cc42c5d8c.zip |
started work on templating
Diffstat (limited to 'jinja_helpers.py')
-rw-r--r-- | jinja_helpers.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/jinja_helpers.py b/jinja_helpers.py new file mode 100644 index 0000000..af91786 --- /dev/null +++ b/jinja_helpers.py @@ -0,0 +1,30 @@ +"""Functions in this module will be avaliable to call in jinja templates""" +import yaml + +def recurse_class_tree_text(tree, indent = 4): + return yaml.dump(tree, indent = indent).replace(": {}", "") + +def flatten_struct(struct): + out = {} + for s in struct: + key = list(s.keys())[0] + out[key] = s[key] + return out + +def _get_helpers(): + import reflect + import os + + r = reflect.Reflect(os.getcwd()) + r.import_module("jinja_helpers") + return {k: v[0] for k, v in r.get_functions("jinja_helpers").items()} + +if __name__ == "__main__": + import json + with open("100301654_report.json", "r") as f: + init_struct = json.load(f)["files"] + + print(flatten_struct(flatten_struct(init_struct)["example.py"]["functions"])) + + +
\ No newline at end of file |