summaryrefslogtreecommitdiffstats
path: root/jinja_helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'jinja_helpers.py')
-rw-r--r--jinja_helpers.py37
1 files changed, 33 insertions, 4 deletions
diff --git a/jinja_helpers.py b/jinja_helpers.py
index af91786..cf68748 100644
--- a/jinja_helpers.py
+++ b/jinja_helpers.py
@@ -1,5 +1,6 @@
"""Functions in this module will be avaliable to call in jinja templates"""
import yaml
+import re
def recurse_class_tree_text(tree, indent = 4):
return yaml.dump(tree, indent = indent).replace(": {}", "")
@@ -19,12 +20,40 @@ def _get_helpers():
r.import_module("jinja_helpers")
return {k: v[0] for k, v in r.get_functions("jinja_helpers").items()}
+def get_required_num_args(funcname):
+ return int(re.findall(r"(?<=\()(\d+)(?=\))", funcname)[0])
+
+def bool_to_yesno(b:bool):
+ if b:
+ return "YES"
+ else:
+ return "NO"
+
+def len_documentation(comments, docs):
+ """This function isn't in jinja"""
+ if comments == "None":
+ commentlen = 0
+ else:
+ commentlen = len(comments)
+
+ if docs == "None":
+ docslen = 0
+ else:
+ docslen = len(docs)
+
+ return commentlen + docslen
+
+def get_source_numlines(source):
+ return "%d lines (%d characters)" % (source.count("\n"), len(source))
+
if __name__ == "__main__":
- import json
- with open("100301654_report.json", "r") as f:
- init_struct = json.load(f)["files"]
+ # 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"]))
- print(flatten_struct(flatten_struct(init_struct)["example.py"]["functions"]))
+ print(get_required_num_args("aFunctionThatIsntThere(2)"))
\ No newline at end of file