Use global conductor instance

The switch from crawler-local conductors to a single pferd-global conductor was
made to prepare for auth section credential providers.
This commit is contained in:
Joscha
2021-05-10 23:50:16 +02:00
parent 595ba8b7ab
commit d5f29f01c5
6 changed files with 34 additions and 13 deletions

View File

@ -4,7 +4,7 @@ from datetime import datetime
from pathlib import Path, PurePath
# TODO In Python 3.9 and above, AsyncContextManager is deprecated
from typing import (Any, AsyncContextManager, AsyncIterator, Awaitable,
Callable, Optional, Protocol, TypeVar)
Callable, Optional, TypeVar)
from rich.markup import escape
@ -141,8 +141,9 @@ class Crawler(ABC):
def __init__(
self,
name: str,
config: Config,
section: CrawlerSection,
config: Config,
conductor: TerminalConductor,
) -> None:
"""
Initialize a crawler from its name and its section in the config file.
@ -154,9 +155,9 @@ class Crawler(ABC):
"""
self.name = name
self._conductor = TerminalConductor()
self._conductor = conductor
self._limiter = Limiter()
self.error_free = True
try:
self._transformer = Transformer(section.transform())
@ -171,8 +172,6 @@ class Crawler(ABC):
self._conductor,
)
self.error_free = False
def print(self, text: str) -> None:
"""
Print rich markup to the terminal. Crawlers *must* use this function to