Added devision by semester
This commit is contained in:
@@ -4,12 +4,13 @@ import os
|
||||
from pathlib import Path
|
||||
from logger import get_worker_thread_logger
|
||||
from urllib.parse import urlparse
|
||||
from config import get_settings
|
||||
|
||||
def get_datestring() -> str:
|
||||
return datetime.datetime.now().strftime("%d.%m.%y")
|
||||
return datetime.datetime.now().strftime("%d.%m.%y (%H:%M:%S)")
|
||||
|
||||
|
||||
def cache_cheatsheet(url, outdir: str) -> str | None:
|
||||
def cache_cheatsheet(url) -> str | None:
|
||||
settings = get_settings()
|
||||
logger = get_worker_thread_logger()
|
||||
logger.info(f"Caching cheatsheet from {url}")
|
||||
|
||||
@@ -27,14 +28,22 @@ def cache_cheatsheet(url, outdir: str) -> str | None:
|
||||
|
||||
url_base_name = Path(urlparse(url).path).stem
|
||||
|
||||
filesname = os.path.join("cache", f"{url_base_name}.pdf")
|
||||
filesname = os.path.join(f"{url_base_name}.pdf")
|
||||
|
||||
if not os.path.exists(os.path.join(outdir, "cache")):
|
||||
os.mkdir(os.path.join(outdir, "cache"))
|
||||
if not os.path.exists(os.path.join(settings.paths.cache)):
|
||||
os.mkdir(os.path.join(settings.paths.cache))
|
||||
|
||||
with open(os.path.join(outdir, filesname), "wb") as f:
|
||||
|
||||
if not os.path.exists(os.path.join(settings.paths.output, "cache")):
|
||||
os.mkdir(os.path.join(settings.paths.output, "cache"))
|
||||
|
||||
|
||||
with open(os.path.join(settings.paths.output, "cache", filesname), "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
with open(os.path.join(settings.paths.cache, filesname), "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
logger.info(f"Saved file to {filesname}")
|
||||
|
||||
return filesname
|
||||
return os.path.join("cache", filesname)
|
||||
|
||||
Reference in New Issue
Block a user