Commit 74c50a72 authored by scmalte's avatar scmalte

init.py (and others): added mu-init to copy package resources to local directory

parent efad50e1
...@@ -71,7 +71,7 @@ def main( ...@@ -71,7 +71,7 @@ def main(
jinja2_file_loader = jinja2.FileSystemLoader(".") jinja2_file_loader = jinja2.FileSystemLoader(".")
jinja2_env = jinja2.Environment(loader=jinja2_file_loader) 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) # output = template.render(colors=colors)
# print(output) # print(output)
......
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{ title }}</title>
{# <link rel="stylesheet" href="css/main.css" />
<link rel="icon" href="images/favicon.png" /> #}
</head>
<body style="padding: 1em">
No. of eDoz students: {{ edoz_count }} <br>
No. of CX students: {{ course_count }} <span style="color: #999999">(may include staff)</span><br>
No. of plagiarists: {{ plagiarist_count }} <br>
{% for key, value in percentages.items() %}
{{ key }}: {{ value }}% <br>
{% endfor %}
<table style="border-spacing: 1em 2em">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for (cluster, cluster_rows) in clusters %}
<tr>
<td>
Size: {{ cluster_rows.shape[0] }}
{{ cluster_rows.to_html(classes="cluster", header=False, index_names=False) }}
{# <table>
{% for row in cluster_rows %}
<tr>
<td>
{{ row }}
</td>
{ # <td></td>
<td></td> # }
</tr>
{% endfor %}
</table> #}
</td>
<td>
<object data="{{ cluster['svg_file'].iat[0] }}" type="image/svg+xml" style="transform:scale(60%); max-width: 75em; visibility: hidden"></object>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
window.addEventListener("load", function(){
var svg_objects = document.querySelectorAll("table > tbody object");
// console.log(svg_objects);
svg_objects.forEach(obj => {
var dim = obj.getBoundingClientRect();
// console.log(dim.width, dim.height);
obj.style.visibility = "visible";
//obj.style.removeProperty("visibility");
obj.style.transform = "";
obj.style.width = dim.width + "px";
obj.style.height = dim.height + "px";
})
});
</script>
</body>
</html>
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()
...@@ -28,6 +28,7 @@ setup( ...@@ -28,6 +28,7 @@ setup(
# scripts=['bin/mossutils-moss'], # scripts=['bin/mossutils-moss'],
entry_points = { entry_points = {
"console_scripts": [ "console_scripts": [
'mu-init = mossutils.init:main',
'mu-moss = mossutils.moss:main', 'mu-moss = mossutils.moss:main',
'mu-revise = mossutils.revise:main', 'mu-revise = mossutils.revise:main',
'mu-cluster = mossutils.cluster:main', 'mu-cluster = mossutils.cluster:main',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment