mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
fix: improve logging messages and documentation (#803)
This commit is contained in:
@@ -252,8 +252,7 @@ class KleinanzeigenBot(WebScrapingMixin): # noqa: PLR0904
|
||||
|
||||
# Log installation mode and config location (INFO level for user visibility)
|
||||
mode_display = "portable (current directory)" if self.installation_mode == "portable" else "system-wide (XDG directories)"
|
||||
LOG.info("Installation mode: %s", mode_display)
|
||||
LOG.info("Config file: %s", self.config_file_path)
|
||||
LOG.info("Installation mode: %s [%s]", mode_display, self.config_file_path)
|
||||
|
||||
async def run(self, args:list[str]) -> None:
|
||||
self.parse_args(args)
|
||||
@@ -585,7 +584,7 @@ class KleinanzeigenBot(WebScrapingMixin): # noqa: PLR0904
|
||||
header=(
|
||||
"# yaml-language-server: $schema="
|
||||
"https://raw.githubusercontent.com/Second-Hand-Friends/kleinanzeigen-bot"
|
||||
"/refs/heads/main/schemas/config.schema.json"
|
||||
"/main/schemas/config.schema.json"
|
||||
),
|
||||
exclude = {"ad_defaults": {"description"}},
|
||||
)
|
||||
@@ -599,12 +598,20 @@ class KleinanzeigenBot(WebScrapingMixin): # noqa: PLR0904
|
||||
self.config = Config.model_validate(config_yaml, strict = True, context = self.config_file_path)
|
||||
|
||||
# load built-in category mappings
|
||||
self.categories = dicts.load_dict_from_module(resources, "categories.yaml", "categories")
|
||||
deprecated_categories = dicts.load_dict_from_module(resources, "categories_old.yaml", "categories")
|
||||
self.categories = dicts.load_dict_from_module(resources, "categories.yaml", "")
|
||||
LOG.debug("Loaded %s categories from categories.yaml", len(self.categories))
|
||||
deprecated_categories = dicts.load_dict_from_module(resources, "categories_old.yaml", "")
|
||||
LOG.debug("Loaded %s categories from categories_old.yaml", len(deprecated_categories))
|
||||
self.categories.update(deprecated_categories)
|
||||
custom_count = 0
|
||||
if self.config.categories:
|
||||
custom_count = len(self.config.categories)
|
||||
self.categories.update(self.config.categories)
|
||||
LOG.info(" -> found %s", pluralize("category", self.categories))
|
||||
LOG.debug("Loaded %s categories from config.yaml (custom)", custom_count)
|
||||
total_count = len(self.categories)
|
||||
if total_count == 0:
|
||||
LOG.warning("No categories loaded - category files may be missing or empty")
|
||||
LOG.debug("Loaded %s categories in total", total_count)
|
||||
|
||||
# populate browser_config object used by WebScrapingMixin
|
||||
self.browser_config.arguments = self.config.browser.arguments
|
||||
|
||||
@@ -63,8 +63,11 @@ kleinanzeigen_bot/__init__.py:
|
||||
|
||||
load_config:
|
||||
"config": "Konfiguration"
|
||||
" -> found %s": "-> %s gefunden"
|
||||
"category": "Kategorie"
|
||||
"Loaded %s categories from categories.yaml": "%s Kategorien aus categories.yaml geladen"
|
||||
"Loaded %s categories from categories_old.yaml": "%s Kategorien aus categories_old.yaml geladen"
|
||||
"Loaded %s categories from config.yaml (custom)": "%s Kategorien aus config.yaml geladen (benutzerdefiniert)"
|
||||
"Loaded %s categories in total": "%s Kategorien insgesamt geladen"
|
||||
"No categories loaded - category files may be missing or empty": "Keine Kategorien geladen - Kategorie-Dateien fehlen oder sind leer"
|
||||
|
||||
check_and_wait_for_captcha:
|
||||
"# Captcha present! Please solve the captcha.": "# Captcha vorhanden! Bitte lösen Sie das Captcha."
|
||||
@@ -138,9 +141,8 @@ kleinanzeigen_bot/__init__.py:
|
||||
"Found extend button on page %s": "'Verlängern'-Button auf Seite %s gefunden"
|
||||
|
||||
finalize_installation_mode:
|
||||
"Config file: %s": "Konfigurationsdatei: %s"
|
||||
"First run detected, prompting user for installation mode": "Erster Start erkannt, frage Benutzer nach Installationsmodus"
|
||||
"Installation mode: %s": "Installationsmodus: %s"
|
||||
"Installation mode: %s [%s]": "Installationsmodus: %s [%s]"
|
||||
|
||||
publish_ads:
|
||||
"Processing %s/%s: '%s' from [%s]...": "Verarbeite %s/%s: '%s' von [%s]..."
|
||||
@@ -686,7 +688,7 @@ kleinanzeigen_bot/utils/xdg_paths.py:
|
||||
"Failed to create %s %s: %s": "Fehler beim Erstellen von %s %s: %s"
|
||||
detect_installation_mode:
|
||||
"Detected installation mode: %s": "Erkannter Installationsmodus: %s"
|
||||
"No existing installation found": "Keine bestehende Installation gefunden"
|
||||
"No existing configuration (portable or system-wide) found": "Keine bestehende Konfiguration (portabel oder systemweit) gefunden"
|
||||
prompt_installation_mode:
|
||||
"Non-interactive mode detected, defaulting to portable installation": "Nicht-interaktiver Modus erkannt, Standard-Installation: portabel"
|
||||
"Choose installation type:": "Installationstyp wählen:"
|
||||
|
||||
@@ -79,7 +79,7 @@ def load_dict(filepath:str, content_label:str = "") -> dict[str, Any]:
|
||||
|
||||
def load_dict_if_exists(filepath:str, content_label:str = "") -> dict[str, Any] | None:
|
||||
abs_filepath = files.abspath(filepath)
|
||||
LOG.info("Loading %s[%s]...", content_label and content_label + " from " or "", abs_filepath)
|
||||
LOG.debug("Loading %s[%s]...", content_label and content_label + " from " or "", abs_filepath)
|
||||
|
||||
__, file_ext = os.path.splitext(filepath)
|
||||
if file_ext not in {".json", ".yaml", ".yml"}:
|
||||
|
||||
@@ -89,7 +89,7 @@ def detect_installation_mode() -> InstallationMode | None:
|
||||
LOG.debug("Checking for portable config at: %s", portable_config)
|
||||
|
||||
if portable_config.exists():
|
||||
LOG.info("Detected installation mode: %s", "portable")
|
||||
LOG.debug("Detected installation mode: %s", "portable")
|
||||
return "portable"
|
||||
|
||||
# Check for XDG installation
|
||||
@@ -97,11 +97,11 @@ def detect_installation_mode() -> InstallationMode | None:
|
||||
LOG.debug("Checking for XDG config at: %s", xdg_config)
|
||||
|
||||
if xdg_config.exists():
|
||||
LOG.info("Detected installation mode: %s", "xdg")
|
||||
LOG.debug("Detected installation mode: %s", "xdg")
|
||||
return "xdg"
|
||||
|
||||
# Neither exists - first run
|
||||
LOG.info("No existing installation found")
|
||||
LOG.info("No existing configuration (portable or system-wide) found")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user