Open rishis07 opened 2 years ago
Funny seeing you here :)
In general I'm a big fan of
argparse
and for using as little PyPI as possible. I'm not sure howclick
works exactly with requiring arguments etc...At the moment the script doesn't run with 0 arguments:
$ ./price-alert.py Traceback (most recent call last): File "/home/eyal/repos/price-alert/./price-alert.py", line 136, in <module> main() File "/home/eyal/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/eyal/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/eyal/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/eyal/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/home/eyal/repos/price-alert/./price-alert.py", line 110, in main items = json.loads(json_items) File "/usr/lib/python3.10/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hello there. Maybe is not needed for this project but click is argparse with steroid. Not only allows to parse everything with only one wrapper but also allows you to create different behaviours. https://click.palletsprojects.com/en/7.x/commands/
I am not sure how would you like to handle the default behaviour, I could add a validation. The "problem" is that by using default args click is reading from the cfg.py where you can set up the args as environmental variables so forcing click to require certain args could be wrong... Or I am wrong and I should expect specific args.
Holy shit, delete me from this!!!
Sent from my iPhone
On 19 Jul 2022, at 17:49, eric.rishmüller @.***> wrote:
@rishis07 commented on this pull request.
In README.md:
Other sale pages/email client
-The script was tested on Amazon, so if you try running it on a different site make sure that
xpath_selector
is set correctly in the configuration json and that the price check itself is correct. +The script was tested on Amazon, so if you try running it on a different site make sure thatxpath_selector
is set correctly incfg.py
and that the price check itself is correct. Done— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
@kurama999 the settings are on your side, not ours https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/configuring-notifications#about-participating-and-watching-notifications
What: Implemented logic for setting the configuration from env variables
Why: It was one of the TODOs
How: Implemented click and python-decouple so you can both set the conf from params or from enviromantal variables. python decouple also allows you to create a settings.ini file.