Skip to content
Snippets Groups Projects
Commit 5710de2c authored by tuhe's avatar tuhe
Browse files

Reference update

parent 680f76d7
No related branches found
No related tags found
No related merge requests found
Showing
with 120 additions and 159 deletions
# coursebox # Coursebox DTU
DTU course management software.
DTU course management ## Installation
\ No newline at end of file ```terminal
pip install coursebox
```
## What it can do
- Single semester-dependent configuration file
- Integrates with DTU Inside/DTU Learn
- Distribution/evalauation of project reports in Learn-compatible format
- Quiz-generation in DTU Learn/Beamer friendly format
- Automatic website/syllabus generation
- Automatic generation of lectures handouts/exercises (you don't have to track dynamic content like dates/lecture titles; it is all in the configuration)
- Easy compilation to 2/5 day formats (Continuous education)
## Usage
Coursebox requires a specific directory structure. It is easier to start with an existing course and adapt to your needs. Please contact me at tuhe@dtu.dk for more information.
## Citing
```bibtex
@online{coursebox,
title={Coursebox (0.1.1): \texttt{pip install coursebox}},
url={https://lab.compute.dtu.dk/tuhe/coursebox},
urldate = {2021-09-06},
publisher={Tue Herlau},
author={Tue Herlau},
comments={See url{asdfsdaf} for examples},
year={2021},
}
```
\ No newline at end of file
File added
File added
# Coursebox DTU
DTU course management software.
## Installation
```terminal
pip install coursebox
```
## What it can do
- Single semester-dependent configuration file
- Integrates with DTU Inside/DTU Learn
- Distribution/evalauation of project reports in Learn-compatible format
- Quiz-generation in DTU Learn/Beamer friendly format
- Automatic website/syllabus generation
- Automatic generation of lectures handouts/exercises (you don't have to track dynamic content like dates/lecture titles; it is all in the configuration)
- Easy compilation to 2/5 day formats (Continuous education)
## Usage
Coursebox requires a specific directory structure. It is easier to start with an existing course and adapt to your needs. Please contact me at tuhe@dtu.dk for more information.
## Citing
```bibtex
{{bibtex}}
```
\ No newline at end of file
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)
@online{coursebox,
title={Coursebox (0.1.1): \texttt{pip install coursebox}},
url={https://lab.compute.dtu.dk/tuhe/coursebox},
urldate = {2021-09-06},
publisher={Tue Herlau},
author={Tue Herlau},
comments={See url{asdfsdaf} for examples},
year={2021},
}
\ No newline at end of file
\documentclass[aspectratio=43]{beamer}
\usepackage{etoolbox}
\newtoggle{overlabel_includesvgs}
\newtoggle{overlabel_includelabels}
\toggletrue{overlabel_includesvgs}
\toggletrue{overlabel_includelabels}
\input{beamer_slider_preamble.tex}
\begin{document}
\begin{frame}
\maketitle
\end{frame}
\begin{frame}\osvg{myoverlay}
\title{Slide with overlay}
This is some example text!
\end{frame}
\end{document}
...@@ -9,5 +9,5 @@ matplotlib ...@@ -9,5 +9,5 @@ matplotlib
numpy numpy
pycode_similar pycode_similar
jinjafy jinjafy
slider beamer-slider
tinydb tinydb
...@@ -11,7 +11,7 @@ with open("README.md", "r", encoding="utf-8") as fh: ...@@ -11,7 +11,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.0", version="0.1.1",
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",
...@@ -30,5 +30,5 @@ setuptools.setup( ...@@ -30,5 +30,5 @@ setuptools.setup(
package_dir={"": "src"}, package_dir={"": "src"},
packages=setuptools.find_packages(where="src"), packages=setuptools.find_packages(where="src"),
python_requires=">=3.8", python_requires=">=3.8",
install_requires=[str(r) for r in pkg_resources.parse_requirements('requirements.txt')], install_requires=['openpyxl', 'tika','xlwings','pybtex','langdetect','wexpect','pexpect','matplotlib','numpy','pycode_similar','jinjafy','beamer-slider','tinydb'],
) )
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: coursebox Name: coursebox
Version: 0.1.0 Version: 0.1.1
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
...@@ -15,7 +15,7 @@ Requires-Python: >=3.8 ...@@ -15,7 +15,7 @@ Requires-Python: >=3.8
Description-Content-Type: text/markdown Description-Content-Type: text/markdown
License-File: LICENSE License-File: LICENSE
# coursebox # Coursebox DTU
DTU course management DTU course management software.
...@@ -13,7 +13,6 @@ src/coursebox.egg-info/top_level.txt ...@@ -13,7 +13,6 @@ src/coursebox.egg-info/top_level.txt
src/coursebox/book/__init__.py src/coursebox/book/__init__.py
src/coursebox/book/exam_includer.py src/coursebox/book/exam_includer.py
src/coursebox/core/__init__.py src/coursebox/core/__init__.py
src/coursebox/core/citations.py
src/coursebox/core/info.py src/coursebox/core/info.py
src/coursebox/core/info_paths.py src/coursebox/core/info_paths.py
src/coursebox/core/projects.py src/coursebox/core/projects.py
......
requirements.txt openpyxl
tika
xlwings
pybtex
langdetect
wexpect
pexpect
matplotlib
numpy
pycode_similar
jinjafy
beamer-slider
tinydb
File deleted
No preview for this file type
import os
import pybtex
import io
# import six
from coursebox.core.info_paths import get_paths
from pybtex import plugin
from pybtex.database.input import bibtex
def get_references(bibfile, gi):
"""
Import and convert slides dynamically.
"""
# base_dir = paths['02450public'] + "/Notes/Latex"
bibf = bibfile #base_dir + "/library.bib"
if not os.path.exists(bibf):
return None
# pybtex.plugin
pybtex_style = plugin.find_plugin('pybtex.style.formatting', 'alpha')()
pybtex_html_backend = plugin.find_plugin('pybtex.backends', 'html')()
pybtex_plain_backend = plugin.find_plugin('pybtex.backends', 'plaintext')()
pybtex_parser = bibtex.Parser()
with open(bibf, 'r', encoding='utf8') as f:
data = pybtex_parser.parse_stream(f)
# Tue: This used to be:
# import six
# itv = six.itervalues(data.entries)
# itv = iter(data.entries)
data_formatted = pybtex_style.format_entries(data.entries.values())
refs = {}
if 'auxfile' in gi:
all_references = parse_aux(gi['auxfile'], bibtex=gi['bibtex'])
else:
all_references = {}
for entry in data_formatted:
output = io.StringIO()
output_plain = io.StringIO()
pybtex_plain_backend.output = output_plain.write
pybtex_html_backend.output = output.write
pybtex_html_backend.write_entry(entry.key, entry.label, entry.text.render(pybtex_html_backend))
pybtex_plain_backend.write_entry(entry.key, entry.label, entry.text.render(pybtex_plain_backend))
html = output.getvalue()
plain = output_plain.getvalue()
entry.text.parts[-2].__str__()
url = ""
for i,p in enumerate(entry.text.parts):
if "\\url" in p.__str__():
url = entry.text.parts[i+1]
break
url = url.__str__()
i1 = html.find("\\textbf")
i2 = html.find("</span>", i1)
dht = html[i1:i2]
dht = dht[dht.find(">")+1:]
html = html[:i1] + " <b>"+dht+"</b> " + html[i2+7:]
plain = plain.replace("\\textbf ", "")
iu = plain.find("URL")
if iu > 0:
plain = plain[:iu]
refs[entry.key] = {'html': html,
'plain': plain,
'label': entry.label,
'filename': url,
'references': all_references}
newref = {}
ls = lambda x: x if isinstance(x, list) else [x]
if 'tex_command' in gi:
for cmd, aux, display in zip( ls(gi['tex_command']), ls(gi['tex_aux'] ), ls( gi['tex_display'] ) ):
ax = parse_aux(aux, bibtex=gi['bibtex'])
for k in ax:
ax[k]['pyref'] = display%(ax[k]['nicelabel'],)
newref[cmd] = ax
return refs, newref
def parse_aux(auxfile, bibtex):
paths = get_paths()
auxfile = os.path.join(paths['02450public'], auxfile)
if not os.path.exists(auxfile):
print(auxfile)
from warnings import warn
warn("Could not find file")
return {}
with open(auxfile, 'r') as f:
items = f.readlines()
entries = {}
for e in items:
e = e.strip()
if e.startswith("\\newlabel") and "@cref" in e:
# print(e)
i0 = e.find("{")
i1 = e.find("@cref}")
key = e[i0+1:i1]
j0 = e.find("{{[", i0)+3
j1 = e.find("}", j0)
val = e[j0:j1]
label = val[:val.find("]")]
number = val[val.rfind("]")+1:]
if label == "equation":
nlabel = f"eq. ({number})"
else:
nlabel = label.capitalize() + " " + number
coderef = "\\cite[%s]{%s}"%(nlabel, bibtex) if bibtex is not None else None
entries[key] = {'pyref': coderef, 'nicelabel': nlabel, 'rawlabel': label, 'number': number}
return entries
...@@ -2,8 +2,6 @@ from datetime import timedelta ...@@ -2,8 +2,6 @@ from datetime import timedelta
from datetime import datetime from datetime import datetime
import coursebox import coursebox
# import thtools # import thtools
import os
import shutil
from coursebox.thtools_base import list_dict2dict_list from coursebox.thtools_base import list_dict2dict_list
# import jinjafy # import jinjafy
import openpyxl import openpyxl
...@@ -113,20 +111,6 @@ def first_day_of_class(info): ...@@ -113,20 +111,6 @@ def first_day_of_class(info):
return first_day_of_class return first_day_of_class
def find_tex_cite(s, start=0, key="\\cite"):
txt = None
i = s.find(key, start)
if i < 0:
return (i,None), None, None
j = s.find("}", i)
cite = s[i:j + 1]
if cite.find("[") > 0:
txt = cite[cite.find("[") + 1:cite.find("]")]
reference = cite[cite.find("{") + 1:cite.find("}")]
return (i, j), reference, txt
def lectures(info, pensum=None): def lectures(info, pensum=None):
ow = timedelta(days=7) ow = timedelta(days=7)
d = first_day_of_class(info) d = first_day_of_class(info)
...@@ -267,7 +251,7 @@ def class_information(): ...@@ -267,7 +251,7 @@ def class_information():
del gi['key'] del gi['key']
del gi['value'] del gi['value']
from coursebox.core.citations import get_references from snipper.load_citations import get_references
if "pensum_bib" in gi: if "pensum_bib" in gi:
refs, nrefs = get_references(paths['02450public'] + "/" + gi['pensum_bib'], gi) refs, nrefs = get_references(paths['02450public'] + "/" + gi['pensum_bib'], gi)
d['references'], d['new_references'] = refs, nrefs d['references'], d['new_references'] = refs, nrefs
......
...@@ -12,13 +12,11 @@ from openpyxl.utils import get_column_letter ...@@ -12,13 +12,11 @@ from openpyxl.utils import get_column_letter
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import langdetect import langdetect
import xlwings as xw import xlwings as xw
from coursebox.core.projects_info import get_output_file, INSTRUCTOR_ROW, STUDENT_ID_ROW, parse_column from coursebox.core.projects_info import get_output_file, INSTRUCTOR_ROW, STUDENT_ID_ROW, parse_column
from coursebox.core.projects_info import EVALUATION_ROW_END, EVALUATION_ROW_START, WEIGHT_ROW_START, RANGE_MIN_COL, DELTA_ALLOWED_ROW from coursebox.core.projects_info import EVALUATION_ROW_END, EVALUATION_ROW_START, WEIGHT_ROW_START, RANGE_MIN_COL, DELTA_ALLOWED_ROW
from coursebox.core.info import get_paths, class_information, semester_id from coursebox.core.info import get_paths, class_information, semester_id
from coursebox.core import projects_info from coursebox.core import projects_info
from coursebox.core.projects_plagiarism import plagiarism_checker from coursebox.core.projects_plagiarism import plagiarism_checker
from jinjafy.cache import cache_contains_dir, cache_update_dir from jinjafy.cache import cache_contains_dir, cache_update_dir
from jinjafy.plot.plot_helpers import get_colors from jinjafy.plot.plot_helpers import get_colors
import time import time
......
...@@ -10,7 +10,7 @@ from jinjafy import jinjafy_template ...@@ -10,7 +10,7 @@ from jinjafy import jinjafy_template
from coursebox.core.info_paths import get_paths from coursebox.core.info_paths import get_paths
from slider.legacy_importer import slide_to_image from slider.legacy_importer import slide_to_image
from slider.legacy_importer import li_import from slider.legacy_importer import li_import
from slider.slider import set_svg_background_images from slider.slide import set_svg_background_images
from coursebox.book.exam_includer import HOMEWORK_PROBLEMS from coursebox.book.exam_includer import HOMEWORK_PROBLEMS
from coursebox.core.info import class_information from coursebox.core.info import class_information
from coursebox.material.lecture_questions import lecture_question_compiler from coursebox.material.lecture_questions import lecture_question_compiler
......
...@@ -5,7 +5,7 @@ import glob ...@@ -5,7 +5,7 @@ import glob
from jinjafy import jinjafy_template from jinjafy import jinjafy_template
from slider import latexmk from slider import latexmk
from coursebox.thtools_base import execute_command from coursebox.thtools_base import execute_command
from slider.slider import slide_no_by_text, recursive_tex_apply from slider.slide import slide_no_by_text, recursive_tex_apply
from slider.legacy_importer import slide_to_image from slider.legacy_importer import slide_to_image
......
from coursebox.core.info import find_tex_cite from snipper.load_citations import find_tex_cite
import os import os
import functools import functools
from jinjafy import execute_command from jinjafy import execute_command
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment