mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 18:41:50 +01:00
move TypeVar T to utils module
This commit is contained in:
@@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
"""
|
"""
|
||||||
import logging, os, shutil, sys
|
import logging, os, shutil, sys
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing import Any, Final, TypeVar
|
from typing import Any, Final
|
||||||
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
||||||
@@ -23,12 +23,10 @@ from webdriver_manager.chrome import ChromeDriverManager
|
|||||||
from webdriver_manager.microsoft import EdgeChromiumDriverManager
|
from webdriver_manager.microsoft import EdgeChromiumDriverManager
|
||||||
from webdriver_manager.utils import ChromeType
|
from webdriver_manager.utils import ChromeType
|
||||||
|
|
||||||
from .utils import ensure, pause
|
from .utils import ensure, pause, T
|
||||||
|
|
||||||
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.selenium_mixin")
|
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.selenium_mixin")
|
||||||
|
|
||||||
T:Final[TypeVar] = TypeVar('T')
|
|
||||||
|
|
||||||
|
|
||||||
class BrowserConfig:
|
class BrowserConfig:
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import copy, decimal, json, logging, os, re, secrets, sys, traceback, time
|
|||||||
from importlib.resources import read_text as get_resource_as_string
|
from importlib.resources import read_text as get_resource_as_string
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Any, Final
|
from typing import Any, Final, TypeVar
|
||||||
|
|
||||||
import coloredlogs, inflect
|
import coloredlogs, inflect
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
@@ -14,6 +14,8 @@ from ruamel.yaml import YAML
|
|||||||
LOG_ROOT:Final[logging.Logger] = logging.getLogger()
|
LOG_ROOT:Final[logging.Logger] = logging.getLogger()
|
||||||
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.utils")
|
LOG:Final[logging.Logger] = logging.getLogger("kleinanzeigen_bot.utils")
|
||||||
|
|
||||||
|
T:Final[TypeVar] = TypeVar('T')
|
||||||
|
|
||||||
|
|
||||||
def abspath(relative_path:str, relative_to:str = None):
|
def abspath(relative_path:str, relative_to:str = None):
|
||||||
"""
|
"""
|
||||||
@@ -123,8 +125,7 @@ def configure_console_logging() -> None:
|
|||||||
def on_exception(ex_type, ex_value, ex_traceback) -> None:
|
def on_exception(ex_type, ex_value, ex_traceback) -> None:
|
||||||
if issubclass(ex_type, KeyboardInterrupt):
|
if issubclass(ex_type, KeyboardInterrupt):
|
||||||
sys.__excepthook__(ex_type, ex_value, ex_traceback)
|
sys.__excepthook__(ex_type, ex_value, ex_traceback)
|
||||||
return
|
elif LOG.isEnabledFor(logging.DEBUG) or isinstance(ex_value, (AttributeError, ImportError, NameError, TypeError)):
|
||||||
if LOG.isEnabledFor(logging.DEBUG) or isinstance(ex_value, (AttributeError, ImportError, NameError, TypeError)):
|
|
||||||
LOG.error("".join(traceback.format_exception(ex_type, ex_value, ex_traceback)))
|
LOG.error("".join(traceback.format_exception(ex_type, ex_value, ex_traceback)))
|
||||||
elif isinstance(ex_value, AssertionError):
|
elif isinstance(ex_value, AssertionError):
|
||||||
LOG.error(ex_value)
|
LOG.error(ex_value)
|
||||||
|
|||||||
Reference in New Issue
Block a user