mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Satisfy pyling. Useful docstrings? Not quite sure.
This commit is contained in:
parent
ca8fcf7a1d
commit
509e624d47
@ -1,3 +1,7 @@
|
|||||||
|
"""
|
||||||
|
Contains a Location class for objects with an inherent path.
|
||||||
|
"""
|
||||||
|
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
"""
|
||||||
|
Convenience functions for using PFERD.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -21,6 +25,10 @@ PRETTY = PrettyLogger(LOGGER)
|
|||||||
|
|
||||||
class Pferd(Location):
|
class Pferd(Location):
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
|
"""
|
||||||
|
The main entrypoint in your Pferd usage: This class combines a number of
|
||||||
|
useful shortcuts for running synchronizers in a single interface.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, base_dir: Path, tmp_dir: Path = Path(".tmp")):
|
def __init__(self, base_dir: Path, tmp_dir: Path = Path(".tmp")):
|
||||||
super().__init__(Path(base_dir))
|
super().__init__(Path(base_dir))
|
||||||
@ -38,6 +46,7 @@ class Pferd(Location):
|
|||||||
transform: Transform,
|
transform: Transform,
|
||||||
download_strategy: DownloadStrategy,
|
download_strategy: DownloadStrategy,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
# pylint: disable=too-many-locals
|
||||||
cookie_jar = CookieJar(cookies)
|
cookie_jar = CookieJar(cookies)
|
||||||
session = cookie_jar.create_session()
|
session = cookie_jar.create_session()
|
||||||
tmp_dir = self._tmp_dir.new_subdir()
|
tmp_dir = self._tmp_dir.new_subdir()
|
||||||
@ -68,6 +77,30 @@ class Pferd(Location):
|
|||||||
password: Optional[str] = None,
|
password: Optional[str] = None,
|
||||||
download_strategy: DownloadStrategy = download_everything,
|
download_strategy: DownloadStrategy = download_everything,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
"""
|
||||||
|
Synchronizes a folder with the ILIAS instance of the KIT.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
target {Path} -- the target path to write the data to
|
||||||
|
course_id {str} -- the id of the main course page (found in the URL after ref_id
|
||||||
|
when opening the course homepage)
|
||||||
|
|
||||||
|
Keyword Arguments:
|
||||||
|
dir_filter {IliasDirectoryFilter} -- A filter for directories. Will be applied on the
|
||||||
|
crawler level, these directories and all of their content is skipped.
|
||||||
|
(default: {lambdax:True})
|
||||||
|
transform {Transform} -- A transformation function for the output paths. Return None
|
||||||
|
to ignore a file. (default: {lambdax:x})
|
||||||
|
cookies {Optional[Path]} -- The path to store and load cookies from.
|
||||||
|
(default: {None})
|
||||||
|
username {Optional[str]} -- The SCC username. If none is given, it will prompt
|
||||||
|
the user. (default: {None})
|
||||||
|
password {Optional[str]} -- The SCC password. If none is given, it will prompt
|
||||||
|
the user. (default: {None})
|
||||||
|
download_strategy {DownloadStrategy} -- A function to determine which files need to
|
||||||
|
be downloaded. Can save bandwidth and reduce the number of requests.
|
||||||
|
(default: {download_everything})
|
||||||
|
"""
|
||||||
# This authenticator only works with the KIT ilias instance.
|
# This authenticator only works with the KIT ilias instance.
|
||||||
authenticator = KitShibbolethAuthenticator(username=username, password=password)
|
authenticator = KitShibbolethAuthenticator(username=username, password=password)
|
||||||
PRETTY.starting_synchronizer(target, "ILIAS", course_id)
|
PRETTY.starting_synchronizer(target, "ILIAS", course_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user