From 9c6e4fa02f8d5a28a90395b5bda62108f221d57a Mon Sep 17 00:00:00 2001 From: Tue Herlau <tuhe@dtu.dk> Date: Mon, 2 Jan 2023 16:38:17 +0100 Subject: [PATCH] updates --- docs/build_docs.py | 4 +--- setup.py | 2 +- src/coursebox.egg-info/PKG-INFO | 2 +- src/coursebox/book/irlc_main.py.pclprof | 1 + src/coursebox/core/info.py | 6 +++--- src/coursebox/core/info_paths.py | 6 +++++- src/coursebox/core/projects_info.py | 2 +- .../material/homepage_lectures_exercises.py | 19 +++++++++++-------- src/coursebox/thtools_base.py | 2 +- 9 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 src/coursebox/book/irlc_main.py.pclprof diff --git a/docs/build_docs.py b/docs/build_docs.py index 0f674b2..867c7d9 100644 --- a/docs/build_docs.py +++ b/docs/build_docs.py @@ -1,13 +1,11 @@ - import jinja2 + if __name__ == "__main__": from jinjafy.bibliography_maker import make_bibliography bib = make_bibliography("../setup.py", "./") - # bib = '' data = {'bibtex': bib} with open("README.jinja.md", 'r') as f: s = jinja2.Environment().from_string(f.read()).render(data) with open("../README.md", 'w') as f: f.write(s) - diff --git a/setup.py b/setup.py index 941b7ab..4939390 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ with open("README.md", "r", encoding="utf-8") as fh: # beamer-slider setuptools.setup( name="coursebox", - version="0.1.9", + version="0.1.13", author="Tue Herlau", author_email="tuhe@dtu.dk", description="A course management system currently used at DTU", diff --git a/src/coursebox.egg-info/PKG-INFO b/src/coursebox.egg-info/PKG-INFO index 18831e3..1ee6aab 100644 --- a/src/coursebox.egg-info/PKG-INFO +++ b/src/coursebox.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: coursebox -Version: 0.1.9 +Version: 0.1.13 Summary: A course management system currently used at DTU Home-page: https://lab.compute.dtu.dk/tuhe/coursebox Author: Tue Herlau diff --git a/src/coursebox/book/irlc_main.py.pclprof b/src/coursebox/book/irlc_main.py.pclprof new file mode 100644 index 0000000..a970559 --- /dev/null +++ b/src/coursebox/book/irlc_main.py.pclprof @@ -0,0 +1 @@ +{"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 diff --git a/src/coursebox/core/info.py b/src/coursebox/core/info.py index a80d792..5074b65 100644 --- a/src/coursebox/core/info.py +++ b/src/coursebox/core/info.py @@ -12,10 +12,10 @@ from coursebox.core.info_paths import core_conf # import pybtex.database.input.bibtex # import pybtex.plugin # import io -from line_profiler_pycharm import profile +# from line_profiler_pycharm import profile import time -@profile +# @profile def xlsx_to_dicts(xlsx_file,sheet=None, as_dict_list=False): # print("Loading...", xlsx_file, sheet, as_dict_list) t0 = time.time() @@ -245,7 +245,7 @@ def get_forum(paths): d2.append({k: v[i] for k, v in dd.items()}) return d2 -@profile +# @profile def class_information(): course_number = core_conf['course_number'] piazza = 'https://piazza.com/dtu.dk/%s%s/%s' % (semester().lower(), year(), course_number) diff --git a/src/coursebox/core/info_paths.py b/src/coursebox/core/info_paths.py index 8a0c02f..9666831 100644 --- a/src/coursebox/core/info_paths.py +++ b/src/coursebox/core/info_paths.py @@ -43,7 +43,11 @@ def get_paths(): _files = [] sCE = "CE" if core_conf['continuing_education_mode'] else "" - paths ={'02450private': root_02450private, + + paths ={ + # 'docs': + # 'docs': + '02450private': root_02450private, '02450public': root_02450public, '02450instructors': root_02450instructors, '02450students': root_02450students, diff --git a/src/coursebox/core/projects_info.py b/src/coursebox/core/projects_info.py index bae377d..a716c8a 100644 --- a/src/coursebox/core/projects_info.py +++ b/src/coursebox/core/projects_info.py @@ -3,7 +3,7 @@ import os import re import openpyxl import numpy as np -from line_profiler_pycharm import profile +# from line_profiler_pycharm import profile INSTRUCTOR_ROW = 6 INSTRUCTOR_CHECKER_ROW = 31 diff --git a/src/coursebox/material/homepage_lectures_exercises.py b/src/coursebox/material/homepage_lectures_exercises.py index 0a6b395..d4ba93e 100644 --- a/src/coursebox/material/homepage_lectures_exercises.py +++ b/src/coursebox/material/homepage_lectures_exercises.py @@ -4,7 +4,7 @@ from datetime import datetime, timedelta import calendar import pickle import time -from line_profiler_pycharm import profile +# from line_profiler_pycharm import profile from coursebox.thtools_base import partition_list import slider @@ -233,7 +233,7 @@ from pathlib import Path from jinjafy.cache.simplecache import hash_file_ -@profile +# @profile def get_hash_from_base(base): if not os.path.exists(base + "/sharedcache.pkl"): source = {} @@ -262,8 +262,11 @@ def get_hash_from_base(base): actual_files[rel]['hash'] = source[rel]['hash'] 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): ''' Copy shared files into lecture directories @@ -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 slider.convert import svg2pdf, pdfcrop from slider import convert - import filecmp + # import filecmp t0 = time.time() shared_base = paths['shared'] @@ -290,7 +293,7 @@ def fix_shared(paths, output_dir, pdf2png=False,dosvg=True,verbose=False, compil source_extra = {} for rel in source: 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) 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 # update_source_cache = True # Perform sync here. + for rel in source: if rel.endswith("_partial.tex"): continue if rel not in target or target[rel]['hash'] != source[rel]['hash']: + _ensure_target_dir_exists( output_dir + "/" + rel) print(" -> ", output_dir + "/" + rel) shutil.copy(shared_base +"/" + rel, output_dir + "/" + rel) target[rel] = source[rel].copy() @@ -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]['mtime'] = os.path.getmtime(output_dir + "/" + rel) - # Save the cache. - with open(shared_base + "/sharedcache.pkl", 'wb') as f: pickle.dump(source, f) @@ -551,7 +554,7 @@ def mvfiles(source_dir, dest_dir): if (os.path.isfile(full_file_name)): shutil.copy(full_file_name, os.path.dirname(dest_dir)) -@profile +# @profile def make_webpage(dosvg=True): cinfo = class_information() paths = get_paths() diff --git a/src/coursebox/thtools_base.py b/src/coursebox/thtools_base.py index b04434e..3b42df8 100644 --- a/src/coursebox/thtools_base.py +++ b/src/coursebox/thtools_base.py @@ -9,7 +9,7 @@ def is_win(): return platform.uname()[0].startswith("Windows") -def is_compute():f +def is_compute(): return platform.uname()[1] == "linuxterm1" -- GitLab