pynintendoparental 1.0.5__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/PKG-INFO +3 -3
  2. pynintendoparental-1.1.1/pynintendoparental/_version.py +1 -0
  3. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/device.py +17 -12
  4. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/exceptions.py +16 -0
  5. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental.egg-info/PKG-INFO +3 -3
  6. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental.egg-info/requires.txt +2 -2
  7. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/setup.py +2 -2
  8. pynintendoparental-1.0.5/pynintendoparental/_version.py +0 -1
  9. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/LICENSE +0 -0
  10. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/README.md +0 -0
  11. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/__init__.py +0 -0
  12. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/api.py +0 -0
  13. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/application.py +0 -0
  14. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/authenticator/__init__.py +0 -0
  15. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/authenticator/const.py +0 -0
  16. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/const.py +0 -0
  17. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/enum.py +0 -0
  18. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/player.py +0 -0
  19. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/py.typed +0 -0
  20. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental/utils.py +0 -0
  21. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental.egg-info/SOURCES.txt +0 -0
  22. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental.egg-info/dependency_links.txt +0 -0
  23. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pynintendoparental.egg-info/top_level.txt +0 -0
  24. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/pyproject.toml +0 -0
  25. {pynintendoparental-1.0.5 → pynintendoparental-1.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pynintendoparental
3
- Version: 1.0.5
3
+ Version: 1.1.1
4
4
  Summary: A Python module to interact with Nintendo Parental Controls
5
5
  Home-page: http://github.com/pantherale0/pynintendoparental
6
6
  Author: pantherale0
@@ -17,9 +17,9 @@ Requires-Dist: black<26,>=23; extra == "dev"
17
17
  Requires-Dist: build<1.4,>=0.10; extra == "dev"
18
18
  Requires-Dist: flake8<8,>=6; extra == "dev"
19
19
  Requires-Dist: isort<7,>=5; extra == "dev"
20
- Requires-Dist: mypy<1.18,>=1.5; extra == "dev"
20
+ Requires-Dist: mypy<1.19,>=1.5; extra == "dev"
21
21
  Requires-Dist: pytest<9,>=7; extra == "dev"
22
- Requires-Dist: pytest-cov<7,>=4; extra == "dev"
22
+ Requires-Dist: pytest-cov<8,>=4; extra == "dev"
23
23
  Requires-Dist: twine<7,>=4; extra == "dev"
24
24
  Dynamic: author
25
25
  Dynamic: classifier
@@ -0,0 +1 @@
1
+ __version__ = "1.1.1"
@@ -8,7 +8,7 @@ from typing import Callable
8
8
 
9
9
  from .api import Api
10
10
  from .const import _LOGGER, DAYS_OF_WEEK
11
- from .exceptions import HttpException
11
+ from .exceptions import HttpException, BedtimeOutOfRangeError
12
12
  from .enum import AlarmSettingState, RestrictionMode
13
13
  from .player import Player
14
14
  from .utils import is_awaitable
@@ -121,20 +121,25 @@ class Device:
121
121
  self._parse_parental_control_setting(response["json"])
122
122
  await self._execute_callbacks()
123
123
 
124
- async def set_bedtime_alarm(self, end_time: time = None, enabled: bool = True):
124
+ async def set_bedtime_alarm(self, value: time):
125
125
  """Update the bedtime alarm for the device."""
126
- _LOGGER.debug(">> Device.set_bedtime_alarm(end_time=%s, enabled=%s)",
127
- end_time,
128
- enabled)
126
+ _LOGGER.debug(">> Device.set_bedtime_alarm(value=%s)",
127
+ value)
128
+ if not (
129
+ (16 <= value.hour <= 22) or
130
+ (value.hour == 23 and value.minute == 0) or
131
+ (value.hour == 0 and value.minute == 0)
132
+ ):
133
+ raise BedtimeOutOfRangeError(value=value)
129
134
  bedtime = {
130
- "enabled": enabled,
135
+ "enabled": value.hour != 0 and value.minute != 0,
131
136
  }
132
- if end_time is not None:
137
+ if bedtime["enabled"]:
133
138
  bedtime = {
134
139
  **bedtime,
135
140
  "endingTime": {
136
- "hour": end_time.hour,
137
- "minute": end_time.minute
141
+ "hour": value.hour,
142
+ "minute": value.minute
138
143
  }
139
144
  }
140
145
  if self.timer_mode == "DAILY":
@@ -225,7 +230,7 @@ class Device:
225
230
  current_day["bedtime"]["endingTime"]["hour"],
226
231
  minute=current_day["bedtime"]["endingTime"]["minute"])
227
232
  else:
228
- self.bedtime_alarm = None
233
+ self.bedtime_alarm = time(hour=0, minute=0)
229
234
  else:
230
235
  bedtime_alarm = self.parental_control_settings["playTimerRegulations"]["dailyRegulations"]["bedtime"]
231
236
  if bedtime_alarm["enabled"]:
@@ -233,7 +238,7 @@ class Device:
233
238
  bedtime_alarm["endingTime"]["hour"],
234
239
  minute=bedtime_alarm["endingTime"]["minute"])
235
240
  else:
236
- self.bedtime_alarm = None
241
+ self.bedtime_alarm = time(hour=0, minute=0)
237
242
  return True
238
243
 
239
244
  def _parse_parental_control_setting(self, pcs: dict):
@@ -286,7 +291,7 @@ class Device:
286
291
  effective_remaining_time = time_remaining_by_play_limit
287
292
 
288
293
  # 2. Factor in bedtime alarm, if any, to further constrain remaining time
289
- if self.bedtime_alarm is not None:
294
+ if self.bedtime_alarm not in (None, time(hour=0, minute=0)):
290
295
  bedtime_dt = datetime.combine(now.date(), self.bedtime_alarm)
291
296
  time_remaining_by_bedtime = 0.0
292
297
  if bedtime_dt > now: # Bedtime is in the future today
@@ -1,5 +1,7 @@
1
1
  """Nintendo Parental exceptions."""
2
2
 
3
+ from datetime import time
4
+
3
5
  class HttpException(Exception):
4
6
  """A HTTP error occured"""
5
7
  def __init__(self, status_code: int, message: str) -> None:
@@ -19,3 +21,17 @@ class InvalidOAuthConfigurationException(HttpException):
19
21
 
20
22
  class NoDevicesFoundException(Exception):
21
23
  """No devices were found for the account."""
24
+
25
+ class InputValidationError(Exception):
26
+ """Input Validation Failed."""
27
+ value: object
28
+ error_key: str
29
+
30
+ class BedtimeOutOfRangeError(InputValidationError):
31
+ """Bedtime is outside of the allowed range."""
32
+
33
+ error_key = "bedtime_alarm_out_of_range"
34
+
35
+ def __init__(self, value: object) -> None:
36
+ super().__init__()
37
+ self.value = value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pynintendoparental
3
- Version: 1.0.5
3
+ Version: 1.1.1
4
4
  Summary: A Python module to interact with Nintendo Parental Controls
5
5
  Home-page: http://github.com/pantherale0/pynintendoparental
6
6
  Author: pantherale0
@@ -17,9 +17,9 @@ Requires-Dist: black<26,>=23; extra == "dev"
17
17
  Requires-Dist: build<1.4,>=0.10; extra == "dev"
18
18
  Requires-Dist: flake8<8,>=6; extra == "dev"
19
19
  Requires-Dist: isort<7,>=5; extra == "dev"
20
- Requires-Dist: mypy<1.18,>=1.5; extra == "dev"
20
+ Requires-Dist: mypy<1.19,>=1.5; extra == "dev"
21
21
  Requires-Dist: pytest<9,>=7; extra == "dev"
22
- Requires-Dist: pytest-cov<7,>=4; extra == "dev"
22
+ Requires-Dist: pytest-cov<8,>=4; extra == "dev"
23
23
  Requires-Dist: twine<7,>=4; extra == "dev"
24
24
  Dynamic: author
25
25
  Dynamic: classifier
@@ -5,7 +5,7 @@ black<26,>=23
5
5
  build<1.4,>=0.10
6
6
  flake8<8,>=6
7
7
  isort<7,>=5
8
- mypy<1.18,>=1.5
8
+ mypy<1.19,>=1.5
9
9
  pytest<9,>=7
10
- pytest-cov<7,>=4
10
+ pytest-cov<8,>=4
11
11
  twine<7,>=4
@@ -24,9 +24,9 @@ DEV_REQUIREMENTS = [
24
24
  'build >= 0.10,< 1.4',
25
25
  'flake8 >= 6,< 8',
26
26
  'isort >= 5,< 7',
27
- 'mypy >= 1.5,< 1.18',
27
+ 'mypy >= 1.5,< 1.19',
28
28
  'pytest >= 7,< 9',
29
- 'pytest-cov >= 4,< 7',
29
+ 'pytest-cov >= 4,< 8',
30
30
  'twine >= 4,< 7',
31
31
  ]
32
32
 
@@ -1 +0,0 @@
1
- __version__ = "1.0.5"