Skip to content

Commit

Permalink
feat: support shipping for WANTED ads #349
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Nov 21, 2024
1 parent 6a315c9 commit 01d78bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ notes = [ "FIXME", "XXX", "TODO" ] # list of note tags to take in consideration
# https://pylint.pycqa.org/en/latest/user_guide/configuration/all-options.html#design-checker
# https://pylint.pycqa.org/en/latest/user_guide/checkers/features.html#design-checker-messages
max-attributes = 15 # maximum number of instance attributes for a class (R0902)
max-branches = 30 # maximum number of branch for function / method body (R0912)
max-branches = 40 # maximum number of branch for function / method body (R0912)
max-locals = 30 # maximum number of local variables for function / method body (R0914)
max-returns = 10 # maximum number of return / yield for function / method body (R0911)
max-statements = 100 # maximum number of statements in function / method body (R0915)
max-statements = 150 # maximum number of statements in function / method body (R0915)
max-public-methods = 30 # maximum number of public methods for a class (R0904)


Expand Down
10 changes: 9 additions & 1 deletion src/kleinanzeigen_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,15 @@ async def publish_ad(self, ad_file:str, ad_cfg: dict[str, Any], ad_cfg_orig: dic
#############################
# set shipping type/options/costs
#############################
if ad_cfg["shipping_type"] == "PICKUP":
if ad_cfg["type"] == "WANTED":
# special handling for ads of type WANTED since shipping is a special attribute for these
if ad_cfg["shipping_type"] in {"PICKUP", "SHIPPING"}:
shipping_value = "ja" if ad_cfg["shipping_type"] == "SHIPPING" else "nein"
try:
await self.web_select(By.XPATH, "//select[contains(@id, '.versand_s')]", shipping_value)
except TimeoutError:
LOG.warning("Failed to set shipping attribute for type '%s'!", ad_cfg['shipping_type'])
elif ad_cfg["shipping_type"] == "PICKUP":
try:
await self.web_click(By.XPATH,
'//*[contains(@class, "ShippingPickupSelector")]//label[text()[contains(.,"Nur Abholung")]]/input[@type="radio"]')
Expand Down

0 comments on commit 01d78bb

Please sign in to comment.