diff --git a/.gitignore b/.gitignore index 5391d87392a9983b4dcac6751022ac8b0c20e424..a81c8ee121952cf06bfaf9ff9988edd8cded763c 100644 --- a/.gitignore +++ b/.gitignore @@ -135,4 +135,4 @@ dmypy.json .pytype/ # Cython debug symbols -cython_debug/ \ No newline at end of file +cython_debug/ diff --git a/requirements.txt b/requirements.txt index 14848f0c4fca9691de3b0c52c412881e784c96d8..7be40b1dbf54a49507318e83e8b177306bfa367b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,8 @@ pexpect matplotlib numpy pycode_similar -# jinjafy beamer-slider tinydb python-gitlab +sphinx>=6.0.0 +docutils>=0.20.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 36c5650a6c93050e03a6ebaa9d17bf69665cbab6..3d3630f9f134813b642ed9c0fcdd2b8893240f5e 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="coursebox", - version="0.1.19.11", + version="0.1.20.1", 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 a5537f7baac9745949e772a7594d2b97a9dd15a0..3c9d50a82d90df2619ff536bf8bdfe6871843bec 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.19.11 +Version: 0.1.20.1 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/core/info.py b/src/coursebox/core/info.py index fd3364d5399841ae28ddb95c896d9884a7749237..cc92393ad76b7401387159918615b2fd27e1f8a8 100644 --- a/src/coursebox/core/info.py +++ b/src/coursebox/core/info.py @@ -192,7 +192,7 @@ def lectures(info, pensum=None): else: - d = d + timedelta(days=dd[i-0] if i > 1 else 0) + d = d + timedelta(days=(dd+[0 for _ in range(10)])[i] if i > 1 else 0) d = d.replace(hour=ice['hour'][i-1], minute=ice['minute'][i-1]) @@ -202,8 +202,13 @@ def lectures(info, pensum=None): ir = linfo.get('reading', "") linfo['reading_long'] = ir.replace("C", "Chapter ") if ir else "" - hwp = linfo['homework_problems'] + hwp = linfo['homework_problems'] + # if str(hwp).strip().endswith(","): + # hwp = hwp[:-1] + + linfo['homework_problems_long'] = str(hwp) if isinstance(hwp, int) else (hwp.replace("P", "Problem ") if hwp else "") + if linfo["learning_objectives"]: linfo["learning_objectives"] = [s.strip() for s in linfo["learning_objectives"].split("\n")] linfo['reading_rst'] = bib2rst(linfo['reading']) @@ -379,6 +384,7 @@ def class_information(verbose=False, d['CE2'] = gi.get("days", 5) == 2 if continuing_education_mode else False d['CE5'] = gi.get("days", 5) == 5 if continuing_education_mode else False + d['CE'] = True if continuing_education_mode else False d['freeze_report_evaluation'] = d['freeze_report_evaluation'] == 'True' d['freeze_grades'] = d['freeze_grades'] == 'True' diff --git a/src/coursebox/material/documentation.py b/src/coursebox/material/documentation.py index 7b74dd0830f798f877fa247b651473dd54bf47ac..e5d9e26b0792151f9427c4ee69642230e60cecc6 100644 --- a/src/coursebox/material/documentation.py +++ b/src/coursebox/material/documentation.py @@ -54,8 +54,13 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop # from cp_box.material.student_files import setup_student_files # from coursebox.material.homepage_lectures_exercises import set from coursebox.student_files.student_files import setup_student_files + from coursebox.core.info import class_information + from coursebox.core import info_paths + info = class_information() - if os.path.isfile(d_ := f"{paths['book']}/{paths['course_number']}_Notes.pdf"): + BOOK_PDF_NAME = os.path.basename(info.get('lecture_notes_tex', paths['course_number'] + "_Notes.pdf"))[:-4] + ".pdf" + + if os.path.isfile(d_ := f"{paths['book']}/{BOOK_PDF_NAME}"): book_frontpage_png = paths['shared']+"/figures/book.png" slide_to_image(d_, book_frontpage_png, page_to_take=1) image = PIL.Image.open(book_frontpage_png) @@ -67,10 +72,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop """ Return extra information required for building the documentation. """ # from coursebox.core.info_paths import get_paths - from coursebox.core.info import class_information - from coursebox.core import info_paths - # paths = get_paths() - info = class_information() + # {{ (date1|to_datetime - date2|to_datetime).days < lecture['show_slides_after'] }} # (info['lectures'][2]['date'].now() - info['lectures'][2]['date']).days < lecture['show_slides_after'] }} source = _get_source(paths) @@ -144,7 +146,7 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop shutil.copy(g, dst) pdfs.append(dst) - for g in [paths['pdf_out'] + "/" + paths['course_number'] + "_Notes.pdf"]: + for g in [paths['pdf_out'] + "/" + BOOK_PDF_NAME]: dst = paths['02450public'] + "/src/docs/assets/" + os.path.basename(g) shutil.copy(g, dst) pdfs.append(dst) @@ -218,10 +220,8 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop # subprocess.run(cmd, shell=True) # subprocess.run('cd "C:/Users/tuhe/Documents/02002students_complete/docs" && set PYTHONPATH="C:/Users/tuhe/Documents/02002students_complete" && sphinx-build -b html source "../../02002public/public" -a ', shell=True) - problems = [] if os.name == "nt": - # do win specific stuff here. # >> > result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE) # >> > result.stdout @@ -233,21 +233,17 @@ def build_sphinx_documentation(cut_files=False, open_browser=True, build_and_cop process = run(cmd, print_output=True, log_output=True, check=False, env=my_env) """r - cd /home/tuhe/Documents/02465students_complete/ && sphinx-build -b html docs/source ./public - cd "/home/tuhe/Documents/02465students_complete/docs" && sphinx-build -b html source "../../02465public/public" -a - + cd /home/tuhe/Documents/02465students_complete/ && sphinx-build -b html docs/source ./public + cd "/home/tuhe/Documents/02465students_complete/docs" && sphinx-build -b html source "../../02465public/public" -a """ if os.name == 'nt': - # time.sleep(10) process = run(cmd, print_output=True, log_output=True, check=False, env=my_env) print("TH 2023 Juli: Running sphinx compilation job twice bc of path error on windows. This should be easy to fix but I don't know enough about windows to do so.") print(process.stderr.getvalue()) errors = process.stderr.getvalue() - file = f"{os.path.normpath(PUBLIC_BUILD_DEST)}/log_{l}.txt" fns.append(file) - if not os.path.isdir(d_ := os.path.dirname(file)): os.makedirs(d_) with open(file,'w') as f: diff --git a/src/coursebox/material/homepage_lectures_exercises.py b/src/coursebox/material/homepage_lectures_exercises.py index f6a539694377cb38de1708ff5a3e93fa60b9b880..3c6d8a3829fea31387bf957ddae1e9c0940f33a7 100644 --- a/src/coursebox/material/homepage_lectures_exercises.py +++ b/src/coursebox/material/homepage_lectures_exercises.py @@ -528,15 +528,12 @@ def make_exercises_projects_tutors(week=None, only_exercises=False, make_exercis "R": lang == "R", 'HOMEWORK_PROBLEMS': HOMEWORK_PROBLEMS, } - # get lang dir if not os.path.exists("%s/Exercises%s"%(paths['exercises'], lang)): continue - info.update(tv) ex_base = "%s/ExercisesShared/%sex%i_Base.tex"%(paths['exercises'], course_number, w) ex_tex_out = "%s/Exercises%s/Exercise%i/latex/%sex%i_%s.tex" % ( paths['exercises'], lang, w, course_number, w, lang) - # fbody = os.path.dirname(ex_tex_out) +f"/ex{w}_body.tex" if os.path.exists(ex_base): jinjafy_template(info, ex_base, file_out=ex_tex_out, filters=filters, template_searchpath=paths['exercises']) diff --git a/src/coursebox/material/lecture_questions.py b/src/coursebox/material/lecture_questions.py index 1e35f27662dfece72fb631798ecb664f884ee80a..a341461ccf01b4bf9544ce1bc42018d16452125a 100644 --- a/src/coursebox/material/lecture_questions.py +++ b/src/coursebox/material/lecture_questions.py @@ -67,8 +67,13 @@ def lecture_question_compiler(paths, info, lecture_texfile): print("png_out", png_out) slide_to_image(lecture_pdffile, png_out, page_to_take=n) if dex < 0: - execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"]) - ls = glob.glob( fout_q_pdf[:-4] +"-*.png") + # import subprocess + # out = subprocess.run(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"], capture_output=True, encoding='utf-8') + from slider.convert import pdf2png + fout = pdf2png(fout_q_pdf) + + # execute_command(["pdftocairo", fout_q_pdf, fout_q_pdf[:-4], "-png"]) + ls = glob.glob( fout) if len(ls) > 1: print("Hacky, two files exist (bad/old png conversaion code", ls) l2 = glob.glob(fout_q_pdf[:-4] + "-000*.png")[0]