mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
add --keep-old flag
This commit is contained in:
18
README.md
18
README.md
@@ -175,8 +175,8 @@ It is the spiritual successor to [Second-Hand-Friends/ebayKleinanzeigen](https:/
|
||||
|
||||
## <a name="usage"></a>Usage
|
||||
|
||||
```yaml
|
||||
Usage: kleinanzeigen-bot COMMAND [-v|--verbose] [--config=<PATH>] [--logfile=<PATH>]
|
||||
```
|
||||
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> - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
|
||||
--logfile=<PATH> - 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
|
||||
```
|
||||
|
||||
## <a name="development"></a> Development Notes
|
||||
## <a name="development"></a>Development Notes
|
||||
|
||||
> Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you!
|
||||
|
||||
|
||||
@@ -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> - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
|
||||
--logfile=<PATH> - 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"])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user