mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35:05 +02:00
Add FfM (Fachschaft für Mathematik) synchronizer
This commit moves exceptions and some other things into utils.py and renames files according to python's file naming guides (kinda). It also adds a new example config using the new FfM downloader.
This commit is contained in:
parent
5732268084
commit
2034c9d426
7 changed files with 156 additions and 33 deletions
29
PFERD/utils.py
Normal file
29
PFERD/utils.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
|
||||
__all__ = [
|
||||
"get_base_dir",
|
||||
"stream_to_path",
|
||||
"OutOfTriesException",
|
||||
"UnknownFileTypeException",
|
||||
"FileNotFoundException",
|
||||
]
|
||||
|
||||
def get_base_dir(script_file):
|
||||
return os.path.dirname(os.path.abspath(script_file))
|
||||
|
||||
async def stream_to_path(resp, to_path, chunk_size=1024**2):
|
||||
with open(to_path, 'wb') as fd:
|
||||
while True:
|
||||
chunk = await resp.content.read(chunk_size)
|
||||
if not chunk:
|
||||
break
|
||||
fd.write(chunk)
|
||||
|
||||
class OutOfTriesException(Exception):
|
||||
pass
|
||||
|
||||
class UnknownFileTypeException(Exception):
|
||||
pass
|
||||
|
||||
class FileNotFoundException(Exception):
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue