diff --git a/README.md b/README.md index 87b2f18..b238338 100644 --- a/README.md +++ b/README.md @@ -175,8 +175,8 @@ It is the spiritual successor to [Second-Hand-Friends/ebayKleinanzeigen](https:/ ## Usage -```yaml -Usage: kleinanzeigen-bot COMMAND [-v|--verbose] [--config=] [--logfile=] +``` +Usage: kleinanzeigen-bot COMMAND [OPTIONS] Commands: publish - (re-)publishes ads @@ -184,6 +184,18 @@ Commands: -- help - displays this help (default command) version - displays the application version + +Options: + --ads=all|due|new - specifies which ads to (re-)publish (DEFAULT: due) + Possible values: + * all: (re-)publish all ads ignoring republication_interval + * due: publish all new ads and republish ads according the republication_interval + * new: only publish new ads (i.e. ads that have no id in the config file) + --force - alias for '--ads=all' + --keep-old - don't delete old ads on republication + --config= - path to the config YAML or JSON file (DEFAULT: ./config.yaml) + --logfile= - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log) + -v, --verbose - enables verbose output - only useful when troubleshooting issues ``` ### Configuration @@ -299,7 +311,7 @@ created_on: # set automatically updated_on: # set automatically ``` -## Development Notes +## Development Notes > Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you! diff --git a/kleinanzeigen_bot/__init__.py b/kleinanzeigen_bot/__init__.py index 032b41b..20e903e 100644 --- a/kleinanzeigen_bot/__init__.py +++ b/kleinanzeigen_bot/__init__.py @@ -45,6 +45,7 @@ class KleinanzeigenBot(SeleniumMixin): self.command = "help" self.ads_selector = "due" + self.delete_old_ads = True def __del__(self): if self.file_log: @@ -108,6 +109,7 @@ class KleinanzeigenBot(SeleniumMixin): * due: publish all new ads and republish ads according the republication_interval * new: only publish new ads (i.e. ads that have no id in the config file) --force - alias for '--ads=all' + --keep-old - don't delete old ads on republication --config= - path to the config YAML or JSON file (DEFAULT: ./config.yaml) --logfile= - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log) -v, --verbose - enables verbose output - only useful when troubleshooting issues @@ -115,7 +117,15 @@ class KleinanzeigenBot(SeleniumMixin): def parse_args(self, args:Iterable[str]) -> None: try: - options, arguments = getopt.gnu_getopt(args[1:], "hv", ["help", "verbose", "ads=", "logfile=", "config="]) # pylint: disable=unused-variable + options, arguments = getopt.gnu_getopt(args[1:], "hv", [ + "ads=", + "config=", + "force", + "help", + "keep-old", + "logfile=", + "verbose" + ]) except getopt.error as ex: LOG.error(ex.msg) LOG.error("Use --help to display available options") @@ -137,6 +147,8 @@ class KleinanzeigenBot(SeleniumMixin): self.ads_selector = value.strip().lower() case "--force": self.ads_selector = "all" + case "--keep-old": + self.delete_old_ads = False case "-v" | "--verbose": LOG.setLevel(logging.DEBUG) @@ -361,7 +373,8 @@ class KleinanzeigenBot(SeleniumMixin): LOG.info("############################################") def publish_ad(self, ad_file, ad_cfg: dict[str, Any], ad_cfg_orig: dict[str, Any]) -> None: - self.delete_ad(ad_cfg) + if self.delete_old_ads: + self.delete_ad(ad_cfg) LOG.info("Publishing ad '%s'...", ad_cfg["title"]) diff --git a/pyproject.toml b/pyproject.toml index d6e3627..76548a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,7 +154,7 @@ notes = [ "FIXME", "XXX", "TODO" ] [tool.pylint.design] max-attributes = 10 -max-branches = 20 +max-branches = 30 max-locals = 30 max-returns = 10 max-statements = 90