From 4e7333b3960745028871cbe00358c314f6609d14 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 24 Apr 2020 11:50:27 +0000 Subject: [PATCH] Allow specifying paths as strings in Pferd --- PFERD/pferd.py | 8 ++++---- PFERD/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/PFERD/pferd.py b/PFERD/pferd.py index dd72a8e..3965154 100644 --- a/PFERD/pferd.py +++ b/PFERD/pferd.py @@ -4,7 +4,7 @@ Convenience functions for using PFERD. import logging from pathlib import Path -from typing import Optional +from typing import Optional, Union from .cookie_jar import CookieJar from .ilias import (IliasAuthenticator, IliasCrawler, IliasDirectoryFilter, @@ -38,7 +38,7 @@ class Pferd(Location): def _ilias( self, - target: Path, + target: Union[Path, str], base_url: str, course_id: str, authenticator: IliasAuthenticator, @@ -51,7 +51,7 @@ class Pferd(Location): cookie_jar = CookieJar(cookies) session = cookie_jar.create_session() tmp_dir = self._tmp_dir.new_subdir() - organizer = Organizer(self.resolve(target)) + organizer = Organizer(self.resolve(Path(target))) crawler = IliasCrawler(base_url, course_id, session, authenticator, dir_filter) downloader = IliasDownloader(tmp_dir, organizer, session, authenticator) @@ -69,7 +69,7 @@ class Pferd(Location): def ilias_kit( self, - target: Path, + target: Union[Path, str], course_id: str, dir_filter: IliasDirectoryFilter = lambda x: True, transform: Transform = lambda x: x, diff --git a/PFERD/utils.py b/PFERD/utils.py index e659e39..9026644 100644 --- a/PFERD/utils.py +++ b/PFERD/utils.py @@ -4,7 +4,7 @@ A few utility bobs and bits. import logging from pathlib import Path, PurePath -from typing import Optional, Tuple +from typing import Optional, Tuple, Union import bs4 import requests @@ -123,7 +123,7 @@ class PrettyLogger: def starting_synchronizer( self, - target_directory: Path, + target_directory: Union[Path, str], synchronizer_name: str, subject: Optional[str] = None, ) -> None: