diff --git a/PFERD/ilias/__init__.py b/PFERD/ilias/__init__.py index 379d244..0a5f08b 100644 --- a/PFERD/ilias/__init__.py +++ b/PFERD/ilias/__init__.py @@ -2,8 +2,7 @@ Synchronizing files from ILIAS instances (https://www.ilias.de/). """ -from .authenticators import (IliasAuthenticator, KitShibbolethAuthenticator, - KeyringKitShibbolethAuthenticator) +from .authenticators import IliasAuthenticator, KitShibbolethAuthenticator from .crawler import (IliasCrawler, IliasCrawlerEntry, IliasDirectoryFilter, IliasElementType) from .downloader import (IliasDownloader, IliasDownloadInfo, diff --git a/PFERD/pferd.py b/PFERD/pferd.py index 12ead8b..1bb6f78 100644 --- a/PFERD/pferd.py +++ b/PFERD/pferd.py @@ -6,6 +6,7 @@ import logging from pathlib import Path from typing import Callable, List, Optional, Union +from .authenticators import UserPassAuthenticator from .cookie_jar import CookieJar from .diva import (DivaDownloader, DivaDownloadStrategy, DivaPlaylistCrawler, diva_download_new) @@ -64,6 +65,13 @@ class Pferd(Location): for transformable in transformables: LOGGER.info(transformable.path) + @staticmethod + def _get_authenticator( + username: Optional[str], password: Optional[str] + ) -> KitShibbolethAuthenticator: + inner_auth = UserPassAuthenticator("ILIAS - Pferd.py", username, password) + return KitShibbolethAuthenticator(inner_auth) + def _ilias( self, target: PathLike, @@ -150,7 +158,7 @@ class Pferd(Location): with overwriting or deleting files. The default always asks the user. """ # This authenticator only works with the KIT ilias instance. - authenticator = KitShibbolethAuthenticator(username=username, password=password) + authenticator = Pferd._get_authenticator(username=username, password=password) PRETTY.starting_synchronizer(target, "ILIAS", course_id) organizer = self._ilias( @@ -220,7 +228,7 @@ class Pferd(Location): with overwriting or deleting files. The default always asks the user. """ # This authenticator only works with the KIT ilias instance. - authenticator = KitShibbolethAuthenticator(username=username, password=password) + authenticator = Pferd._get_authenticator(username, password) PRETTY.starting_synchronizer(target, "ILIAS", "Personal Desktop") organizer = self._ilias( @@ -285,7 +293,7 @@ class Pferd(Location): with overwriting or deleting files. The default always asks the user. """ # This authenticator only works with the KIT ilias instance. - authenticator = KitShibbolethAuthenticator(username=username, password=password) + authenticator = Pferd._get_authenticator(username=username, password=password) PRETTY.starting_synchronizer(target, "ILIAS", "An ILIAS element by url") if not full_url.startswith("https://ilias.studium.kit.edu"): diff --git a/mypy.ini b/mypy.ini index 91792d8..60306de 100644 --- a/mypy.ini +++ b/mypy.ini @@ -3,5 +3,5 @@ disallow_untyped_defs = True disallow_incomplete_defs = True no_implicit_optional = True -[mypy-rich.*,bs4] +[mypy-rich.*,bs4,keyring] ignore_missing_imports = True