mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
fix: Make description field optional in ad_defaults
The description field in the main configuration (ad_defaults) is now optional. Previously, the bot would fail if no description or affixes were provided in the main configuration. This change addresses issue #435. Changes: - Add fallback to empty string ("") when all description prefix/suffix sources are None in __get_description_with_affixes method - Add comprehensive test suite for description handling in test_init.py - Fix coverage path in pyproject.toml from 'kleinanzeigen_bot' to 'src/kleinanzeigen_bot' New tests cover: - Description handling without main config description - New format affixes in configuration - Mixed old/new format affixes - Ad-level affix precedence - None value handling in affixes - Email address @ symbol replacement This change maintains backward compatibility while making the description field optional in the main configuration, improving flexibility for users.
This commit is contained in:
committed by
Sebastian Thomschke
parent
a8f6817c5c
commit
c7f7b832b2
@@ -1080,6 +1080,7 @@ class KleinanzeigenBot(WebScrapingMixin):
|
||||
if dicts.safe_get(ad_cfg, "description", "prefix") is not None
|
||||
# 3. Global prefix from config
|
||||
else get_description_affixes(self.config, prefix=True)
|
||||
or "" # Default to empty string if all sources are None
|
||||
)
|
||||
|
||||
# Get suffix with precedence
|
||||
@@ -1091,6 +1092,7 @@ class KleinanzeigenBot(WebScrapingMixin):
|
||||
if dicts.safe_get(ad_cfg, "description", "suffix") is not None
|
||||
# 3. Global suffix from config
|
||||
else get_description_affixes(self.config, prefix=False)
|
||||
or "" # Default to empty string if all sources are None
|
||||
)
|
||||
|
||||
# Combine the parts and replace @ with (at)
|
||||
|
||||
Reference in New Issue
Block a user