Skip to content

Commit

Permalink
Merge pull request #12 from sudiptob2/feature/11-difficulty-option
Browse files Browse the repository at this point in the history
Feature/11 difficulty option
  • Loading branch information
sudiptob2 authored Sep 25, 2022
2 parents 7b4ecab + 8b39e7d commit 03bb725
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 126 deletions.
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
144 changes: 72 additions & 72 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
15 changes: 13 additions & 2 deletions leeteasy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 9 additions & 7 deletions leeteasy/services/notification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
24 changes: 3 additions & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
26 changes: 4 additions & 22 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = leet-easy
version = 0.0.1
version = 0.1.0
author = Sudipto Baral
author_email = [email protected]
description = Desktop notification of easy daily challenge of leetcode.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 03bb725

Please sign in to comment.