diff options
-rw-r--r-- | .gitmodules | 4 | ||||
-rw-r--r-- | Smarker/database.py (renamed from database.py) | 0 | ||||
-rw-r--r-- | Smarker/jinja_helpers.py (renamed from jinja_helpers.py) | 9 | ||||
-rw-r--r-- | Smarker/mark.py (renamed from mark.py) | 20 | ||||
-rw-r--r-- | Smarker/misc_classes.py (renamed from misc_classes.py) | 2 | ||||
-rw-r--r-- | Smarker/pytest_template.jinja2 (renamed from pytest_template.jinja2) | 0 | ||||
m--------- | Smarker/python-latex-highlighting (renamed from python-latex-highlighting) | 0 | ||||
-rw-r--r-- | Smarker/reflect.py (renamed from reflect.py) | 2 | ||||
-rw-r--r-- | Smarker/requirements.txt (renamed from requirements.txt) | 0 | ||||
-rw-r--r-- | Smarker/temp.py | 6 | ||||
-rw-r--r-- | Smarker/templates/markdown.jinja2 | bin | 0 -> 26 bytes | |||
-rw-r--r-- | Smarker/templates/md.jinja2 (renamed from templates/md.jinja2) | 0 | ||||
-rw-r--r-- | Smarker/templates/tex.jinja2 (renamed from templates/tex.jinja2) | 2 | ||||
-rw-r--r-- | Smarker/templates/text.jinja2 | bin | 0 -> 28 bytes | |||
-rw-r--r-- | Smarker/templates/txt.jinja2 (renamed from templates/txt.jinja2) | 0 | ||||
-rw-r--r-- | examplerun.bat | 3 | ||||
-rw-r--r-- | examplerun.sh | 12 | ||||
-rw-r--r-- | smarker.conf | 24 | ||||
l--------- | templates/markdown.jinja2 | bin | 26 -> 0 bytes | |||
l--------- | templates/text.jinja2 | bin | 28 -> 0 bytes |
20 files changed, 40 insertions, 44 deletions
diff --git a/.gitmodules b/.gitmodules index 3183235..63fc1f6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "python-latex-highlighting"] - path = python-latex-highlighting +[submodule "Smarker/python-latex-highlighting"] + path = Smarker/python-latex-highlighting url = git@github.com:olivierverdier/python-latex-highlighting.git diff --git a/database.py b/Smarker/database.py index a0e3640..a0e3640 100644 --- a/database.py +++ b/Smarker/database.py diff --git a/jinja_helpers.py b/Smarker/jinja_helpers.py index a9e0e2e..6d2f34c 100644 --- a/jinja_helpers.py +++ b/Smarker/jinja_helpers.py @@ -111,11 +111,14 @@ def tex_escape(text): # print(text, regex.sub(lambda match: conv[match.group()], text)) return regex.sub(lambda match: conv[match.group()], text) +def get_python_latex_highlight_sty_path(): + return os.path.join(os.path.split(__file__)[0], "python-latex-highlighting", "pythonhighlight") + def _get_helpers(): import reflect import os - r = reflect.Reflect(os.getcwd()) + r = reflect.Reflect(os.path.split(__file__)[0]) r.import_module("jinja_helpers") return {k: v[0] for k, v in r.get_functions("jinja_helpers").items()} @@ -126,7 +129,9 @@ if __name__ == "__main__": # print(flatten_struct(flatten_struct(init_struct)["example.py"]["functions"])) - print(get_required_num_args("aFunctionThatIsntThere(2)")) + print(get_python_latex_highlight_sty_path()) + + # print(_get_helpers())
\ No newline at end of file diff --git a/mark.py b/Smarker/mark.py index 720553b..e8070f8 100644 --- a/mark.py +++ b/Smarker/mark.py @@ -2,6 +2,7 @@ from dataclasses import dataclass import jinja_helpers import configparser import misc_classes +import subprocess import argparse import tempfile import zipfile @@ -28,8 +29,8 @@ def main(**kwargs): elif kwargs["format"] == "json": strout = json.dumps(output, indent = 4) else: - fp = os.path.join("templates", "%s.jinja2" % kwargs["format"]) - if kwargs["format"] == "tex": + fp = os.path.join(os.path.split(__file__)[0], "templates", "%s.jinja2" % kwargs["format"]) + if kwargs["format"] in ("tex", "pdf"): jinja_template = misc_classes.latex_jinja_env.get_template("tex.jinja2") else: with open(fp, "r") as f: @@ -48,11 +49,22 @@ def main(**kwargs): with open(output_file, "w") as f: f.write(strout) + if kwargs["format"] == "pdf": + os.environ["TEXINPUTS"] = os.path.join(os.path.split(__file__)[0], "python-latex-highlighting") + ":" + + os.rename(output_file, os.path.splitext(output_file)[0] + ".tex") + output_file = os.path.splitext(output_file)[0] + ".tex" + subprocess.run(["pdflatex", output_file]) + + os.remove(os.path.splitext(output_file)[0] + ".tex") + os.remove(os.path.splitext(output_file)[0] + ".log") + os.remove(os.path.splitext(output_file)[0] + ".aux") + # input("\n\n[tempdir: %s] Press any key to close..." % tempdir) if __name__ == "__main__": config = configparser.ConfigParser() - config.read("smarker.conf") + config.read(os.path.join(os.path.split(__file__)[0], "smarker.conf")) parser = argparse.ArgumentParser() parser.add_argument( @@ -71,7 +83,7 @@ if __name__ == "__main__": "-f", "--format", help = "Output format type", type = str, - choices = ["yaml", "json"] + [os.path.splitext(f)[0] for f in os.listdir("templates")], + choices = ["yaml", "json", "pdf"] + [os.path.splitext(f)[0] for f in os.listdir(os.path.join(os.path.split(__file__)[0], "templates"))], default = "txt" ) parser.add_argument( diff --git a/misc_classes.py b/Smarker/misc_classes.py index 5bf16c1..09c3a7d 100644 --- a/misc_classes.py +++ b/Smarker/misc_classes.py @@ -16,7 +16,7 @@ latex_jinja_env = jinja2.Environment( line_comment_prefix = '%#',
trim_blocks = True,
autoescape = False,
- loader = jinja2.FileSystemLoader(os.path.abspath('templates'))
+ loader = jinja2.FileSystemLoader(os.path.abspath(os.path.join(os.path.split(__file__)[0], "templates")))
)
@dataclass
diff --git a/pytest_template.jinja2 b/Smarker/pytest_template.jinja2 index 73c9a40..73c9a40 100644 --- a/pytest_template.jinja2 +++ b/Smarker/pytest_template.jinja2 diff --git a/python-latex-highlighting b/Smarker/python-latex-highlighting -Subproject a5b8353876512d8d571a3c3be59452995318a17 +Subproject a5b8353876512d8d571a3c3be59452995318a17 diff --git a/reflect.py b/Smarker/reflect.py index dbe551f..bc5ae0e 100644 --- a/reflect.py +++ b/Smarker/reflect.py @@ -192,7 +192,7 @@ class Reflect: test_results = {} test_results["pytest_report"] = "" - with open("pytest_template.jinja2", "r") as f: + with open(os.path.join(os.path.split(__file__)[0], "pytest_template.jinja2"), "r") as f: jinja_template = jinja2.Template(f.read()) for filename, filestests in tests.items(): diff --git a/requirements.txt b/Smarker/requirements.txt index 3831b5e..3831b5e 100644 --- a/requirements.txt +++ b/Smarker/requirements.txt diff --git a/Smarker/temp.py b/Smarker/temp.py new file mode 100644 index 0000000..60b1c18 --- /dev/null +++ b/Smarker/temp.py @@ -0,0 +1,6 @@ +import json + +with open("100301654_report.json", "r") as f: + tree = json.load(f)["class_tree"] + +print(tree)
\ No newline at end of file diff --git a/Smarker/templates/markdown.jinja2 b/Smarker/templates/markdown.jinja2 Binary files differnew file mode 100644 index 0000000..99c26ce --- /dev/null +++ b/Smarker/templates/markdown.jinja2 diff --git a/templates/md.jinja2 b/Smarker/templates/md.jinja2 index e764a49..e764a49 100644 --- a/templates/md.jinja2 +++ b/Smarker/templates/md.jinja2 diff --git a/templates/tex.jinja2 b/Smarker/templates/tex.jinja2 index 94deb20..eaa7db7 100644 --- a/templates/tex.jinja2 +++ b/Smarker/templates/tex.jinja2 @@ -39,7 +39,7 @@ \documentclass{article}
-\usepackage{python-latex-highlighting/pythonhighlight}
+\usepackage{pythonhighlight}
\usepackage[margin=1in]{geometry} % margins
\usepackage{multicol} % columns
diff --git a/Smarker/templates/text.jinja2 b/Smarker/templates/text.jinja2 Binary files differnew file mode 100644 index 0000000..eca6ebd --- /dev/null +++ b/Smarker/templates/text.jinja2 diff --git a/templates/txt.jinja2 b/Smarker/templates/txt.jinja2 index 9eb4beb..9eb4beb 100644 --- a/templates/txt.jinja2 +++ b/Smarker/templates/txt.jinja2 diff --git a/examplerun.bat b/examplerun.bat deleted file mode 100644 index 00b0a80..0000000 --- a/examplerun.bat +++ /dev/null @@ -1,3 +0,0 @@ -zip -r 100301654.zip .\ExampleSubmission\
-python .\mark.py -s 100301654.zip -a .\ExampleAssessments\example.yml -f yaml -o auto
-rm 100301654.zip
\ No newline at end of file diff --git a/examplerun.sh b/examplerun.sh index b78046f..1f3bb23 100644 --- a/examplerun.sh +++ b/examplerun.sh @@ -1,8 +1,8 @@ zip -r 100301654.zip ./ExampleSubmission/ -python ./mark.py -s 100301654.zip -a ./ExampleAssessments/example.yml -f tex -o auto +python ./Smarker/mark.py -s 100301654.zip -a ./ExampleAssessments/example.yml -f pdf -o auto rm 100301654.zip -pdflatex 100301654_report.tex -rm -v *.log -rm -v *.aux -# rm -v *.tex -rm -v *_test_report.pdf
\ No newline at end of file +# pdflatex 100301654_report.tex +# rm -v *.log +# rm -v *.aux +# # rm -v *.tex +# rm -v *_test_report.pdf
\ No newline at end of file diff --git a/smarker.conf b/smarker.conf deleted file mode 100644 index a31e5d7..0000000 --- a/smarker.conf +++ /dev/null @@ -1,24 +0,0 @@ -[mysql]
-host = 192.168.1.92
-port = 3306
-user = root
-passwd = *************
-
-[tex]
-columns = 1
-show_full_docs = True
-show_source = True
-show_all_regex_occurrences = True
-show_all_run_output = True
-
-[md]
-show_full_docs = False
-show_source = False
-show_all_regex_occurrences = True
-show_all_run_output = False
-
-[txt]
-show_full_docs = False
-show_source = False
-show_all_regex_occurrences = True
-show_all_run_output = False
\ No newline at end of file diff --git a/templates/markdown.jinja2 b/templates/markdown.jinja2 Binary files differdeleted file mode 120000 index 99c26ce..0000000 --- a/templates/markdown.jinja2 +++ /dev/null diff --git a/templates/text.jinja2 b/templates/text.jinja2 Binary files differdeleted file mode 120000 index eca6ebd..0000000 --- a/templates/text.jinja2 +++ /dev/null |