pynintendoparental 1.0.5__py3-none-any.whl → 1.1.1__py3-none-any.whl
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.
- pynintendoparental/_version.py +1 -1
- pynintendoparental/device.py +17 -12
- pynintendoparental/exceptions.py +16 -0
- {pynintendoparental-1.0.5.dist-info → pynintendoparental-1.1.1.dist-info}/METADATA +3 -3
- {pynintendoparental-1.0.5.dist-info → pynintendoparental-1.1.1.dist-info}/RECORD +8 -8
- {pynintendoparental-1.0.5.dist-info → pynintendoparental-1.1.1.dist-info}/WHEEL +0 -0
- {pynintendoparental-1.0.5.dist-info → pynintendoparental-1.1.1.dist-info}/licenses/LICENSE +0 -0
- {pynintendoparental-1.0.5.dist-info → pynintendoparental-1.1.1.dist-info}/top_level.txt +0 -0
pynintendoparental/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.
|
|
1
|
+
__version__ = "1.1.1"
|
pynintendoparental/device.py
CHANGED
|
@@ -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,
|
|
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(
|
|
127
|
-
|
|
128
|
-
|
|
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":
|
|
135
|
+
"enabled": value.hour != 0 and value.minute != 0,
|
|
131
136
|
}
|
|
132
|
-
if
|
|
137
|
+
if bedtime["enabled"]:
|
|
133
138
|
bedtime = {
|
|
134
139
|
**bedtime,
|
|
135
140
|
"endingTime": {
|
|
136
|
-
"hour":
|
|
137
|
-
"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 =
|
|
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 =
|
|
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
|
|
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
|
pynintendoparental/exceptions.py
CHANGED
|
@@ -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.
|
|
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.
|
|
20
|
+
Requires-Dist: mypy<1.19,>=1.5; extra == "dev"
|
|
21
21
|
Requires-Dist: pytest<9,>=7; extra == "dev"
|
|
22
|
-
Requires-Dist: pytest-cov<
|
|
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
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
pynintendoparental/__init__.py,sha256=pNcBsHRa4B85USP7uzwPEGF9fu3MA9YgW_hI82F_NXQ,2460
|
|
2
|
-
pynintendoparental/_version.py,sha256=
|
|
2
|
+
pynintendoparental/_version.py,sha256=q8_5C0f-8mHWNb6mMw02zlYPnEGXBqvOmP3z0CEwZKM,22
|
|
3
3
|
pynintendoparental/api.py,sha256=hMXq0eNIgFELlNZJtN0rK3plKyu9nirvwiUPNlkjOCY,7013
|
|
4
4
|
pynintendoparental/application.py,sha256=l-oVwM4hrVVUf_2djQ7rJVya7LQP38yhaLPAWt8V8TY,3941
|
|
5
5
|
pynintendoparental/const.py,sha256=sQZqU0f1NSClMPfCSJonlCunLdbPPiXjL-JS2LMZGd4,2101
|
|
6
|
-
pynintendoparental/device.py,sha256=
|
|
6
|
+
pynintendoparental/device.py,sha256=5yfdOgLjoYM9cxBfUf1v9_NZBzwn2v4n8ik5Czu9pmc,22458
|
|
7
7
|
pynintendoparental/enum.py,sha256=lzacGti7fcQqAOROjB9782De7bOMYKSEM61SQd6aYG4,401
|
|
8
|
-
pynintendoparental/exceptions.py,sha256=
|
|
8
|
+
pynintendoparental/exceptions.py,sha256=DGguLw1QwjRtKKglnd_ZD9ekUyGeXHN_beVeVvGBKwM,1092
|
|
9
9
|
pynintendoparental/player.py,sha256=WDl0pspHgrV9lGhDp-NKlfP8DV4Yxe02aYaGg9wTTeg,1785
|
|
10
10
|
pynintendoparental/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
pynintendoparental/utils.py,sha256=5-EP_rmPnSSWtbi18Y226GtjLhF3PLONKwmRdiy7m2c,198
|
|
12
12
|
pynintendoparental/authenticator/__init__.py,sha256=MZdA6qqHV0i7rspNL9Z9xl7aRy-EJEm3NIapiIgEJBA,7688
|
|
13
13
|
pynintendoparental/authenticator/const.py,sha256=_nUJVC0U64j_n1LaQd_KDg0EWFcezb87bQyYYXpbPPY,917
|
|
14
|
-
pynintendoparental-1.
|
|
15
|
-
pynintendoparental-1.
|
|
16
|
-
pynintendoparental-1.
|
|
17
|
-
pynintendoparental-1.
|
|
18
|
-
pynintendoparental-1.
|
|
14
|
+
pynintendoparental-1.1.1.dist-info/licenses/LICENSE,sha256=zsxHgHVMnyWq121yND8zBl9Rl9H6EF2K9N51B2ZSm_k,1071
|
|
15
|
+
pynintendoparental-1.1.1.dist-info/METADATA,sha256=sdkHFhEyZTvYT_Cu9ipFIZwMl3tMmk4nw19BSkgmEqI,1871
|
|
16
|
+
pynintendoparental-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
pynintendoparental-1.1.1.dist-info/top_level.txt,sha256=QQ5bAl-Ljso16P8KLf1NHrFmKk9jLT7bVJG_rVlIXWk,19
|
|
18
|
+
pynintendoparental-1.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|