Restructure crawling and auth related modules

This commit is contained in:
Joscha 2021-05-23 19:16:42 +02:00
parent bbf9f8f130
commit 2fdf24495b
13 changed files with 29 additions and 33 deletions

View File

@ -1,8 +1,8 @@
from configparser import SectionProxy from configparser import SectionProxy
from typing import Callable, Dict from typing import Callable, Dict
from ..authenticator import Authenticator, AuthSection
from ..config import Config from ..config import Config
from .authenticator import Authenticator, AuthSection
from .simple import SimpleAuthenticator, SimpleAuthSection from .simple import SimpleAuthenticator, SimpleAuthSection
from .tfa import TfaAuthenticator from .tfa import TfaAuthenticator

View File

@ -1,7 +1,7 @@
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from typing import Tuple from typing import Tuple
from .config import Config, Section from ..config import Config, Section
class AuthLoadException(Exception): class AuthLoadException(Exception):

View File

@ -1,9 +1,9 @@
from typing import Optional, Tuple from typing import Optional, Tuple
from ..authenticator import Authenticator, AuthException, AuthSection
from ..config import Config from ..config import Config
from ..logging import log from ..logging import log
from ..utils import agetpass, ainput from ..utils import agetpass, ainput
from .authenticator import Authenticator, AuthException, AuthSection
class SimpleAuthSection(AuthSection): class SimpleAuthSection(AuthSection):

View File

@ -1,9 +1,9 @@
from typing import Tuple from typing import Tuple
from ..authenticator import Authenticator, AuthException, AuthSection
from ..config import Config from ..config import Config
from ..logging import log from ..logging import log
from ..utils import ainput from ..utils import ainput
from .authenticator import Authenticator, AuthException, AuthSection
class TfaAuthenticator(Authenticator): class TfaAuthenticator(Authenticator):

View File

@ -1,11 +1,11 @@
from configparser import SectionProxy from configparser import SectionProxy
from typing import Callable, Dict from typing import Callable, Dict
from ..authenticator import Authenticator from ..auth import Authenticator
from ..config import Config from ..config import Config
from ..crawler import Crawler from .crawler import Crawler, CrawlError # noqa: F401
from .ilias import KitIliasWebCrawler, KitIliasWebCrawlerSection from .ilias import KitIliasWebCrawler, KitIliasWebCrawlerSection
from .local import LocalCrawler, LocalCrawlerSection from .local_crawler import LocalCrawler, LocalCrawlerSection
CrawlerConstructor = Callable[[ CrawlerConstructor = Callable[[
str, # Name (without the "crawl:" prefix) str, # Name (without the "crawl:" prefix)

View File

@ -6,14 +6,14 @@ from typing import Any, Awaitable, Callable, Dict, List, Optional, Sequence, Tup
from rich.markup import escape from rich.markup import escape
from .authenticator import Authenticator from ..auth import Authenticator
from .config import Config, Section from ..config import Config, Section
from .limiter import Limiter from ..limiter import Limiter
from .logging import ProgressBar, log from ..logging import ProgressBar, log
from .output_dir import FileSink, FileSinkToken, OnConflict, OutputDirectory, OutputDirError, Redownload from ..output_dir import FileSink, FileSinkToken, OnConflict, OutputDirectory, OutputDirError, Redownload
from .report import MarkConflictError, MarkDuplicateError from ..report import MarkConflictError, MarkDuplicateError
from .transformer import Transformer from ..transformer import Transformer
from .utils import ReusableAsyncContextManager, fmt_path from ..utils import ReusableAsyncContextManager, fmt_path
class CrawlWarning(Exception): class CrawlWarning(Exception):

View File

@ -4,11 +4,11 @@ from typing import Optional
import aiohttp import aiohttp
from .config import Config from ..config import Config
from ..logging import log
from ..utils import fmt_real_path
from ..version import NAME, VERSION
from .crawler import Crawler, CrawlerSection from .crawler import Crawler, CrawlerSection
from .logging import log
from .utils import fmt_real_path
from .version import NAME, VERSION
class HttpCrawler(Crawler): class HttpCrawler(Crawler):

View File

@ -6,15 +6,13 @@ import aiohttp
from aiohttp import hdrs from aiohttp import hdrs
from bs4 import BeautifulSoup, Tag from bs4 import BeautifulSoup, Tag
from PFERD.authenticators import Authenticator from ...auth import Authenticator
from PFERD.config import Config from ...config import Config
from PFERD.crawler import CrawlError, CrawlerSection, CrawlWarning, anoncritical from ...logging import ProgressBar, log
from PFERD.http_crawler import HttpCrawler from ...output_dir import FileSink, Redownload
from PFERD.logging import ProgressBar, log from ...utils import fmt_path, soupify, url_set_query_param
from PFERD.output_dir import FileSink, Redownload from ..crawler import CrawlError, CrawlerSection, CrawlWarning, anoncritical
from PFERD.utils import soupify, url_set_query_param from ..http_crawler import HttpCrawler
from ...utils import fmt_path
from .file_templates import link_template_plain, link_template_rich from .file_templates import link_template_plain, link_template_rich
from .kit_ilias_html import IliasElementType, IliasPage, IliasPageElement from .kit_ilias_html import IliasElementType, IliasPage, IliasPageElement

View File

@ -5,7 +5,7 @@ from pathlib import Path, PurePath
from typing import Optional from typing import Optional
from ..config import Config from ..config import Config
from ..crawler import Crawler, CrawlerSection, anoncritical from .crawler import Crawler, CrawlerSection, anoncritical
class LocalCrawlerSection(CrawlerSection): class LocalCrawlerSection(CrawlerSection):

View File

@ -2,11 +2,9 @@ from typing import Dict, List, Optional
from rich.markup import escape from rich.markup import escape
from .authenticator import Authenticator from .auth import AUTHENTICATORS, Authenticator
from .authenticators import AUTHENTICATORS
from .config import Config, ConfigOptionError from .config import Config, ConfigOptionError
from .crawler import Crawler, CrawlError from .crawl import CRAWLERS, Crawler, CrawlError
from .crawlers import CRAWLERS
from .logging import log from .logging import log