Skip to content
Snippets Groups Projects
Commit 9c6e4fa0 authored by tuhe's avatar tuhe
Browse files

updates

parent e26e2a43
Branches
No related tags found
No related merge requests found
import jinja2 import jinja2
if __name__ == "__main__": if __name__ == "__main__":
from jinjafy.bibliography_maker import make_bibliography from jinjafy.bibliography_maker import make_bibliography
bib = make_bibliography("../setup.py", "./") bib = make_bibliography("../setup.py", "./")
# bib = ''
data = {'bibtex': bib} data = {'bibtex': bib}
with open("README.jinja.md", 'r') as f: with open("README.jinja.md", 'r') as f:
s = jinja2.Environment().from_string(f.read()).render(data) s = jinja2.Environment().from_string(f.read()).render(data)
with open("../README.md", 'w') as f: with open("../README.md", 'w') as f:
f.write(s) f.write(s)
...@@ -15,7 +15,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -15,7 +15,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
# beamer-slider # beamer-slider
setuptools.setup( setuptools.setup(
name="coursebox", name="coursebox",
version="0.1.9", version="0.1.13",
author="Tue Herlau", author="Tue Herlau",
author_email="tuhe@dtu.dk", author_email="tuhe@dtu.dk",
description="A course management system currently used at DTU", description="A course management system currently used at DTU",
......
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: coursebox Name: coursebox
Version: 0.1.9 Version: 0.1.13
Summary: A course management system currently used at DTU Summary: A course management system currently used at DTU
Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Home-page: https://lab.compute.dtu.dk/tuhe/coursebox
Author: Tue Herlau Author: Tue Herlau
......
{"profiledFunctions": [{"file": "/home/tuhe/Documents/02465public/pythontools/irlc_box/material/student_files.py", "lineNo": 19, "functionName": "setup_student_files", "profiledLines": []}], "unit": 1e-09}
\ No newline at end of file
...@@ -12,10 +12,10 @@ from coursebox.core.info_paths import core_conf ...@@ -12,10 +12,10 @@ from coursebox.core.info_paths import core_conf
# import pybtex.database.input.bibtex # import pybtex.database.input.bibtex
# import pybtex.plugin # import pybtex.plugin
# import io # import io
from line_profiler_pycharm import profile # from line_profiler_pycharm import profile
import time import time
@profile # @profile
def xlsx_to_dicts(xlsx_file,sheet=None, as_dict_list=False): def xlsx_to_dicts(xlsx_file,sheet=None, as_dict_list=False):
# print("Loading...", xlsx_file, sheet, as_dict_list) # print("Loading...", xlsx_file, sheet, as_dict_list)
t0 = time.time() t0 = time.time()
...@@ -245,7 +245,7 @@ def get_forum(paths): ...@@ -245,7 +245,7 @@ def get_forum(paths):
d2.append({k: v[i] for k, v in dd.items()}) d2.append({k: v[i] for k, v in dd.items()})
return d2 return d2
@profile # @profile
def class_information(): def class_information():
course_number = core_conf['course_number'] course_number = core_conf['course_number']
piazza = 'https://piazza.com/dtu.dk/%s%s/%s' % (semester().lower(), year(), course_number) piazza = 'https://piazza.com/dtu.dk/%s%s/%s' % (semester().lower(), year(), course_number)
......
...@@ -43,7 +43,11 @@ def get_paths(): ...@@ -43,7 +43,11 @@ def get_paths():
_files = [] _files = []
sCE = "CE" if core_conf['continuing_education_mode'] else "" sCE = "CE" if core_conf['continuing_education_mode'] else ""
paths ={'02450private': root_02450private,
paths ={
# 'docs':
# 'docs':
'02450private': root_02450private,
'02450public': root_02450public, '02450public': root_02450public,
'02450instructors': root_02450instructors, '02450instructors': root_02450instructors,
'02450students': root_02450students, '02450students': root_02450students,
......
...@@ -3,7 +3,7 @@ import os ...@@ -3,7 +3,7 @@ import os
import re import re
import openpyxl import openpyxl
import numpy as np import numpy as np
from line_profiler_pycharm import profile # from line_profiler_pycharm import profile
INSTRUCTOR_ROW = 6 INSTRUCTOR_ROW = 6
INSTRUCTOR_CHECKER_ROW = 31 INSTRUCTOR_CHECKER_ROW = 31
......
...@@ -4,7 +4,7 @@ from datetime import datetime, timedelta ...@@ -4,7 +4,7 @@ from datetime import datetime, timedelta
import calendar import calendar
import pickle import pickle
import time import time
from line_profiler_pycharm import profile # from line_profiler_pycharm import profile
from coursebox.thtools_base import partition_list from coursebox.thtools_base import partition_list
import slider import slider
...@@ -233,7 +233,7 @@ from pathlib import Path ...@@ -233,7 +233,7 @@ from pathlib import Path
from jinjafy.cache.simplecache import hash_file_ from jinjafy.cache.simplecache import hash_file_
@profile # @profile
def get_hash_from_base(base): def get_hash_from_base(base):
if not os.path.exists(base + "/sharedcache.pkl"): if not os.path.exists(base + "/sharedcache.pkl"):
source = {} source = {}
...@@ -262,8 +262,11 @@ def get_hash_from_base(base): ...@@ -262,8 +262,11 @@ def get_hash_from_base(base):
actual_files[rel]['hash'] = source[rel]['hash'] actual_files[rel]['hash'] = source[rel]['hash']
return actual_files return actual_files
def _ensure_target_dir_exists(out):
if not os.path.isdir(os.path.dirname(out)):
os.makedirs(os.path.dirname(out))
@profile # @profile
def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compile_templates=True,shallow=True): def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compile_templates=True,shallow=True):
''' '''
Copy shared files into lecture directories Copy shared files into lecture directories
...@@ -272,7 +275,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -272,7 +275,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
from jinjafy.cache import cache_contains_file, cache_update_file from jinjafy.cache import cache_contains_file, cache_update_file
from slider.convert import svg2pdf, pdfcrop from slider.convert import svg2pdf, pdfcrop
from slider import convert from slider import convert
import filecmp # import filecmp
t0 = time.time() t0 = time.time()
shared_base = paths['shared'] shared_base = paths['shared']
...@@ -290,7 +293,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -290,7 +293,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
source_extra = {} source_extra = {}
for rel in source: for rel in source:
if rel.endswith(".svg") and source[rel]['modified']: if rel.endswith(".svg") and source[rel]['modified']:
pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True, verbose=True) pdf_file = svg2pdf(shared_base + "/"+rel, crop=True, text_to_path=True)
rel = os.path.relpath(pdf_file, shared_base) rel = os.path.relpath(pdf_file, shared_base)
source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True) source_extra[rel] = dict(mtime=os.path.getmtime(pdf_file), hash=hash_file_(pdf_file), modified=True)
...@@ -300,11 +303,13 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -300,11 +303,13 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
# update_source_cache = True # update_source_cache = True
# Perform sync here. # Perform sync here.
for rel in source: for rel in source:
if rel.endswith("_partial.tex"): if rel.endswith("_partial.tex"):
continue continue
if rel not in target or target[rel]['hash'] != source[rel]['hash']: if rel not in target or target[rel]['hash'] != source[rel]['hash']:
_ensure_target_dir_exists( output_dir + "/" + rel)
print(" -> ", output_dir + "/" + rel) print(" -> ", output_dir + "/" + rel)
shutil.copy(shared_base +"/" + rel, output_dir + "/" + rel) shutil.copy(shared_base +"/" + rel, output_dir + "/" + rel)
target[rel] = source[rel].copy() target[rel] = source[rel].copy()
...@@ -320,8 +325,6 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil ...@@ -320,8 +325,6 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil
target[rel]['hash'] = hash_file_(output_dir + "/" + rel) target[rel]['hash'] = hash_file_(output_dir + "/" + rel)
target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel) target[rel]['mtime'] = os.path.getmtime(output_dir + "/" + rel)
# Save the cache.
with open(shared_base + "/sharedcache.pkl", 'wb') as f: with open(shared_base + "/sharedcache.pkl", 'wb') as f:
pickle.dump(source, f) pickle.dump(source, f)
...@@ -551,7 +554,7 @@ def mvfiles(source_dir, dest_dir): ...@@ -551,7 +554,7 @@ def mvfiles(source_dir, dest_dir):
if (os.path.isfile(full_file_name)): if (os.path.isfile(full_file_name)):
shutil.copy(full_file_name, os.path.dirname(dest_dir)) shutil.copy(full_file_name, os.path.dirname(dest_dir))
@profile # @profile
def make_webpage(dosvg=True): def make_webpage(dosvg=True):
cinfo = class_information() cinfo = class_information()
paths = get_paths() paths = get_paths()
......
...@@ -9,7 +9,7 @@ def is_win(): ...@@ -9,7 +9,7 @@ def is_win():
return platform.uname()[0].startswith("Windows") return platform.uname()[0].startswith("Windows")
def is_compute():f def is_compute():
return platform.uname()[1] == "linuxterm1" return platform.uname()[1] == "linuxterm1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment