diff --git a/mossutils/aggr.py b/mossutils/aggr.py index 9ea39d8b3c3c4ad966400f47d4500cec16baefe4..9488d37e08eda262f0d3357ff52213e90434e098 100644 --- a/mossutils/aggr.py +++ b/mossutils/aggr.py @@ -71,7 +71,7 @@ def main( jinja2_file_loader = jinja2.FileSystemLoader(".") jinja2_env = jinja2.Environment(loader=jinja2_file_loader) - template = jinja2_env.get_template("clusters.html.jinja") + template = jinja2_env.get_template("./_static/clusters.html.jinja") # output = template.render(colors=colors) # print(output) diff --git a/mossutils/data/cluster_mail.txt b/mossutils/data/cluster_mail.txt new file mode 100644 index 0000000000000000000000000000000000000000..c2fa70e7c9e3b1f60ef193cd0246ca6a95bc1806 --- /dev/null +++ b/mossutils/data/cluster_mail.txt @@ -0,0 +1,6 @@ +Sehr geehrte Studierende + +Sie sind beim Kopieren der Bonusaufgabe erwischt worden. Das ist höchst unerfreulich — für Sie! Denn nun müssen wir Ihnen leider die Punkte wieder abziehen. + +Freundliche Grüsse +Ihre Dozenten \ No newline at end of file diff --git a/mossutils/data/clusters.html.jinja b/mossutils/data/clusters.html.jinja new file mode 100644 index 0000000000000000000000000000000000000000..ac95d19532be012e87dc6bd83dd71564c4e40032 --- /dev/null +++ b/mossutils/data/clusters.html.jinja @@ -0,0 +1,70 @@ + + + + + + + + {{ title }} + + {# + #} + + + + No. of eDoz students: {{ edoz_count }}
+ No. of CX students: {{ course_count }} (may include staff)
+ No. of plagiarists: {{ plagiarist_count }}
+ {% for key, value in percentages.items() %} + {{ key }}: {{ value }}%
+ {% endfor %} + + + + + + + + + {% for (cluster, cluster_rows) in clusters %} + + + + + {% endfor %} + +
+ Size: {{ cluster_rows.shape[0] }} + {{ cluster_rows.to_html(classes="cluster", header=False, index_names=False) }} + {# + {% for row in cluster_rows %} + + + { # + # } + + {% endfor %} +
+ {{ row }} +
#} +
+ +
+ + + + diff --git a/mossutils/init.py b/mossutils/init.py new file mode 100644 index 0000000000000000000000000000000000000000..bb0a5866ebdcb7aab040534385320afe33f7c886 --- /dev/null +++ b/mossutils/init.py @@ -0,0 +1,37 @@ +import logging +import pkgutil +import os +from .utils import logging as logutils + +def main(): + logutils.configure_level_and_format() + + # Files hardcoded here because I couldn't figure out how to iterate over the + # files in the package's "data" directory. + # See also https://stackoverflow.com/questions/61531935. + files = [ + "style.css", + "script.js", + "sorttable.js", + "clusters.html.jinja", + "cluster_mail.txt" + ] + + source_data_directory = "./data" + destination_data_directory = "./_static" + + logging.info("Creating directory {}".format(destination_data_directory)) + os.makedirs(destination_data_directory, exist_ok=True) + + for file in files: + source_file = os.path.join(source_data_directory, file) + destination_file = os.path.join(destination_data_directory, file) + + logging.info("Creating file {}".format(destination_file)) + + with open(destination_file, "wb") as destination_fh: + destination_fh.write(pkgutil.get_data(__name__, source_file)) + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 0d28b4959e6cc2a2233ba8d5decae66b2a0390d7..c7dc4fd5d0e0a9672ed586a6d6f1656819db2196 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ setup( # scripts=['bin/mossutils-moss'], entry_points = { "console_scripts": [ + 'mu-init = mossutils.init:main', 'mu-moss = mossutils.moss:main', 'mu-revise = mossutils.revise:main', 'mu-cluster = mossutils.cluster:main',