diff --git a/Pipfile b/Pipfile index 6afaee4..c65be00 100644 --- a/Pipfile +++ b/Pipfile @@ -5,14 +5,14 @@ name = "pypi" [packages] requests = "*" -pytest = "*" -pytest-mock = "*" click = "*" schedule = "*" notify-py = "*" [dev-packages] flake8 = "*" +pytest = "*" +pytest-mock = "*" [requires] python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock index e7d9ae3..d0e98bc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "66a034435a9b16d1e951839e1e65bc6fc38e9eec5bd49a2ef99bf49e706465d9" + "sha256": "b1f7443b0ef383b55df1e84167df1ab9b100229a9bc577446cfb968d3f85f5d7" }, "pipfile-spec": 6, "requires": { @@ -16,14 +16,6 @@ ] }, "default": { - "attrs": { - "hashes": [ - "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6", - "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c" - ], - "markers": "python_version >= '3.5'", - "version": "==22.1.0" - }, "certifi": { "hashes": [ "sha256:0d9c601124e5a6ba9712dbc60d9c53c21e34f5f641fe83002317394311bdce14", @@ -56,13 +48,6 @@ "markers": "python_version >= '3.5'", "version": "==3.4" }, - "iniconfig": { - "hashes": [ - "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", - "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" - ], - "version": "==1.1.1" - }, "jeepney": { "hashes": [ "sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806", @@ -87,54 +72,6 @@ "index": "pypi", "version": "==0.3.3" }, - "packaging": { - "hashes": [ - "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", - "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" - ], - "markers": "python_version >= '3.6'", - "version": "==21.3" - }, - "pluggy": { - "hashes": [ - "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", - "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" - ], - "markers": "python_version >= '3.6'", - "version": "==1.0.0" - }, - "py": { - "hashes": [ - "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719", - "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", - "version": "==1.11.0" - }, - "pyparsing": { - "hashes": [ - "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", - "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - ], - "markers": "python_full_version >= '3.6.8'", - "version": "==3.0.9" - }, - "pytest": { - "hashes": [ - "sha256:1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7", - "sha256:4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39" - ], - "index": "pypi", - "version": "==7.1.3" - }, - "pytest-mock": { - "hashes": [ - "sha256:77f03f4554392558700295e05aed0b1096a20d4a60a4f3ddcde58b0c31c8fca2", - "sha256:8a9e226d6c0ef09fcf20c94eb3405c388af438a90f3e39687f84166da82d5948" - ], - "index": "pypi", - "version": "==3.8.2" - }, "requests": { "hashes": [ "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983", @@ -151,14 +88,6 @@ "index": "pypi", "version": "==1.1.0" }, - "tomli": { - "hashes": [ - "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" - ], - "markers": "python_version >= '3.7'", - "version": "==2.0.1" - }, "urllib3": { "hashes": [ "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e", @@ -169,6 +98,14 @@ } }, "develop": { + "attrs": { + "hashes": [ + "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6", + "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c" + ], + "markers": "python_version >= '3.5'", + "version": "==22.1.0" + }, "flake8": { "hashes": [ "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db", @@ -177,6 +114,13 @@ "index": "pypi", "version": "==5.0.4" }, + "iniconfig": { + "hashes": [ + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + ], + "version": "==1.1.1" + }, "mccabe": { "hashes": [ "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", @@ -185,6 +129,30 @@ "markers": "python_version >= '3.6'", "version": "==0.7.0" }, + "packaging": { + "hashes": [ + "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb", + "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522" + ], + "markers": "python_version >= '3.6'", + "version": "==21.3" + }, + "pluggy": { + "hashes": [ + "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159", + "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3" + ], + "markers": "python_version >= '3.6'", + "version": "==1.0.0" + }, + "py": { + "hashes": [ + "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719", + "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==1.11.0" + }, "pycodestyle": { "hashes": [ "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785", @@ -200,6 +168,38 @@ ], "markers": "python_version >= '3.6'", "version": "==2.5.0" + }, + "pyparsing": { + "hashes": [ + "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb", + "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" + ], + "markers": "python_full_version >= '3.6.8'", + "version": "==3.0.9" + }, + "pytest": { + "hashes": [ + "sha256:1377bda3466d70b55e3f5cecfa55bb7cfcf219c7964629b967c37cf0bda818b7", + "sha256:4f365fec2dff9c1162f834d9f18af1ba13062db0c708bf7b946f8a5c76180c39" + ], + "index": "pypi", + "version": "==7.1.3" + }, + "pytest-mock": { + "hashes": [ + "sha256:77f03f4554392558700295e05aed0b1096a20d4a60a4f3ddcde58b0c31c8fca2", + "sha256:8a9e226d6c0ef09fcf20c94eb3405c388af438a90f3e39687f84166da82d5948" + ], + "index": "pypi", + "version": "==3.8.2" + }, + "tomli": { + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "markers": "python_version >= '3.7'", + "version": "==2.0.1" } } } diff --git a/assests/leetcoin.png b/assets/leetcoin.png similarity index 100% rename from assests/leetcoin.png rename to assets/leetcoin.png diff --git a/leeteasy/__main__.py b/leeteasy/__main__.py index 592478a..ad8f774 100644 --- a/leeteasy/__main__.py +++ b/leeteasy/__main__.py @@ -11,10 +11,21 @@ @click.command() +@click.option( + '-d', + '--difficulty', + type=click.Choice(['Medium', 'Hard'], case_sensitive=False), + help='Additional problem difficulty for notification.' +) @click.argument('time') -def main(time) -> None: - """Schedule notification at TIME.""" +def main(time, difficulty) -> None: + """ + Schedule notification at given TIME [24hrs]. + + Example: leeteasy 13:15 + """ TimeValidator.validate(time) + Notifier.target_difficulty.append(difficulty) schedule.every().day.at(time).do(Notifier.notify) while True: diff --git a/leeteasy/services/notification_service.py b/leeteasy/services/notification_service.py index 7654c1d..e284076 100644 --- a/leeteasy/services/notification_service.py +++ b/leeteasy/services/notification_service.py @@ -8,23 +8,25 @@ class Notifier: """Handles notification related functionalities.""" target_difficulty = ['Easy'] - app_name = 'LeetEasy - Easy Problem Alert \U0001F514' + app_name = 'LeetEasy' + challenge = None @classmethod def prepare_notification(cls): """Prepares notification msg and triggers notification.""" challenge_info = RequestHandler.get_challenge_info() - challenge = RequestParser.parse(challenge_info) - if challenge.difficulty in cls.target_difficulty: + cls.challenge = RequestParser.parse(challenge_info) + if cls.challenge.difficulty in cls.target_difficulty: return '{0}\nLink: {1}'.format( - challenge.title, - challenge.problem_link, + cls.challenge.title, + cls.challenge.problem_link, ) @classmethod def notify(cls): notification = Notify() - notification.title = cls.app_name notification.message = cls.prepare_notification() - notification.icon = 'assests/leetcoin.png' + notification.title = f'{cls.app_name} - {cls.challenge.difficulty} ' \ + f'Problem Alert \U0001F514' + notification.icon = 'assets/leetcoin.png' notification.send() diff --git a/requirements.txt b/requirements.txt index d99ae34..07e08ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,22 +1,3 @@ -certifi==2022.9.14 -charset-normalizer==2.1.1 -idna==3.4 -requests==2.28.1 -urllib3==1.26.12 -attrs==22.1.0 -certifi==2022.9.14 -charset-normalizer==2.1.1 -idna==3.4 -iniconfig==1.1.1 -packaging==21.3 -pluggy==1.0.0 -py==1.11.0 -pyparsing==3.0.9 -pytest==7.1.3 -pytest-mock==3.8.2 -requests==2.28.1 -tomli==2.0.1 -urllib3==1.26.12 attrs==22.1.0 certifi==2022.9.24 charset-normalizer==2.1.1 @@ -25,13 +6,14 @@ idna==3.4 iniconfig==1.1.1 jeepney==0.8.0 loguru==0.5.3 +mccabe==0.7.0 notify-py==0.3.3 packaging==21.3 pluggy==1.0.0 py==1.11.0 +pycodestyle==2.9.1 +pyflakes==2.5.0 pyparsing==3.0.9 -pytest==7.1.3 -pytest-mock==3.8.2 requests==2.28.1 schedule==1.1.0 tomli==2.0.1 diff --git a/setup.cfg b/setup.cfg index 900d2c4..c33b5fa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = leet-easy -version = 0.0.1 +version = 0.1.0 author = Sudipto Baral author_email = sudiptobaral.me@gmail.com description = Desktop notification of easy daily challenge of leetcode. @@ -32,25 +32,6 @@ install_requires = [options.packages.find] where = - certifi==2022.9.14 - charset-normalizer==2.1.1 - idna==3.4 - requests==2.28.1 - urllib3==1.26.12 - attrs==22.1.0 - certifi==2022.9.14 - charset-normalizer==2.1.1 - idna==3.4 - iniconfig==1.1.1 - packaging==21.3 - pluggy==1.0.0 - py==1.11.0 - pyparsing==3.0.9 - pytest==7.1.3 - pytest-mock==3.8.2 - requests==2.28.1 - tomli==2.0.1 - urllib3==1.26.12 attrs==22.1.0 certifi==2022.9.24 charset-normalizer==2.1.1 @@ -59,13 +40,14 @@ where = iniconfig==1.1.1 jeepney==0.8.0 loguru==0.5.3 + mccabe==0.7.0 notify-py==0.3.3 packaging==21.3 pluggy==1.0.0 py==1.11.0 + pycodestyle==2.9.1 + pyflakes==2.5.0 pyparsing==3.0.9 - pytest==7.1.3 - pytest-mock==3.8.2 requests==2.28.1 schedule==1.1.0 tomli==2.0.1