mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Fix and extend example config
This commit is contained in:
parent
1aaa6e7ab5
commit
13c5a29ff0
@ -1,32 +1,119 @@
|
||||
"""
|
||||
A small sample config for PFERD.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
from pathlib import Path, PurePath
|
||||
|
||||
from PFERD import Pferd, enable_logging
|
||||
from PFERD.ilias.download_strategies import (download_everything,
|
||||
download_modified_or_new)
|
||||
import PFERD
|
||||
from PFERD.transform import (attempt, glob, keep, move, move_dir, optionally,
|
||||
re_move)
|
||||
|
||||
tf_ss_2020_numerik = attempt(
|
||||
re_move(r"Übungsblätter/(\d+)\. Übungsblatt/.*", "Blätter/Blatt_{1:0>2}.pdf"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
tf_ss_2020_db = attempt(
|
||||
move_dir("Begrüßungsvideo/", "Vorlesung/Videos/"),
|
||||
move_dir("Vorlesungsmaterial/Vorlesungsvideos/", "Vorlesung/Videos/"),
|
||||
move_dir("Vorlesungsmaterial/", "Vorlesung/"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
tf_ss_2020_rechnernetze = attempt(
|
||||
re_move(r"Vorlesungsmaterial/.*/(.+?)\.mp4", "Vorlesung/Videos/{1}.mp4"),
|
||||
move_dir("Vorlesungsmaterial/", "Vorlesung/"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
tf_ss_2020_sicherheit = attempt(
|
||||
move_dir("Vorlesungsvideos/", "Vorlesung/Videos/"),
|
||||
move_dir("Übungsvideos/", "Übung/Videos/"),
|
||||
re_move(r"VL(.*)\.pdf", "Vorlesung/{1}.pdf"),
|
||||
re_move(r"Übungsblatt (\d+)\.pdf", "Blätter/Blatt_{1:0>2}.pdf"),
|
||||
move("Chiffrat.txt", "Blätter/Blatt_01_Chiffrat.txt"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
tf_ss_2020_pg = attempt(
|
||||
move_dir("Vorlesungsaufzeichnungen/", "Vorlesung/Videos/"),
|
||||
move_dir("Vorlesungsmaterial/", "Vorlesung/"),
|
||||
re_move(r"Übungen/uebungsblatt(\d+).pdf", "Blätter/Blatt_{1:0>2}.pdf"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
def df_ss_2020_or1(path: PurePath) -> bool:
|
||||
if glob("Tutorien/")(path): return True
|
||||
if glob("Tutorien/Tutorium 10, dienstags 15:45 Uhr/")(path): return True
|
||||
if glob("Tutorien/*")(path): return False
|
||||
return True
|
||||
|
||||
|
||||
tf_ss_2020_or1 = attempt(
|
||||
move_dir("Vorlesung/Unbeschriebene Folien/", "Vorlesung/Folien/"),
|
||||
move_dir("Video zur Organisation/", "Vorlesung/Videos/"),
|
||||
keep,
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
enable_logging()
|
||||
pferd = Pferd(Path(__file__).parent)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--test-run", action="store_true")
|
||||
parser.add_argument("synchronizers", nargs="*")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Synchronize "databases" and only download files with a more recent timestamp than
|
||||
# the local copy, if any exists.
|
||||
PFERD.enable_logging()
|
||||
pferd = PFERD.Pferd(Path(__file__).parent, test_run=args.test_run)
|
||||
|
||||
if not args.synchronizers or "numerik" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
Path("DB"),
|
||||
"1101554",
|
||||
cookies=Path("ilias_cookies.txt"),
|
||||
download_strategy=download_modified_or_new
|
||||
target="Numerik",
|
||||
course_id="1083036",
|
||||
transform=tf_ss_2020_numerik,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
# Synchronize "databases" and redownload every file (default).
|
||||
if not args.synchronizers or "db" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
Path("DB"),
|
||||
"1101554",
|
||||
cookies=Path("ilias_cookies.txt"),
|
||||
download_strategy=download_everything
|
||||
target="DB",
|
||||
course_id="1101554",
|
||||
transform=tf_ss_2020_db,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
if not args.synchronizers or "rechnernetze" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
target="Rechnernetze",
|
||||
course_id="1099996",
|
||||
transform=tf_ss_2020_rechnernetze,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
if not args.synchronizers or "sicherheit" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
target="Sicherheit",
|
||||
course_id="1101980",
|
||||
transform=tf_ss_2020_sicherheit,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
if not args.synchronizers or "pg" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
target="PG",
|
||||
course_id="1106095",
|
||||
transform=tf_ss_2020_pg,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
if not args.synchronizers or "or1" in args.synchronizers:
|
||||
pferd.ilias_kit(
|
||||
target="OR1",
|
||||
course_id="1105941",
|
||||
dir_filter=df_ss_2020_or1,
|
||||
transform=tf_ss_2020_or1,
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user