MouseTools 4.2.0__tar.gz → 4.3.0__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 (30) hide show
  1. {mousetools-4.2.0 → mousetools-4.3.0}/PKG-INFO +1 -1
  2. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/__init__.py +51 -0
  3. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/calendar/__init__.py +4 -49
  4. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/characters/__init__.py +4 -49
  5. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/facilities/__init__.py +3 -46
  6. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/facilitystatus/__init__.py +25 -44
  7. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/forecastedwaittimes/__init__.py +4 -50
  8. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/mixins/couchbase.py +1 -1
  9. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools.egg-info/PKG-INFO +1 -1
  10. {mousetools-4.2.0 → mousetools-4.3.0}/pyproject.toml +1 -1
  11. {mousetools-4.2.0 → mousetools-4.3.0}/LICENSE +0 -0
  12. {mousetools-4.2.0 → mousetools-4.3.0}/README.md +0 -0
  13. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/__init__.py +0 -0
  14. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/api/__init__.py +0 -0
  15. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/api/menu.py +0 -0
  16. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/api/search.py +0 -0
  17. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/auth.py +0 -0
  18. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/enums.py +0 -0
  19. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/channels/facilities/enums.py +0 -0
  20. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/decorators.py +0 -0
  21. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/enums.py +0 -0
  22. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/mixins/__init__.py +0 -0
  23. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/mixins/disney.py +0 -0
  24. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools/resources/environments.bin +0 -0
  25. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools.egg-info/SOURCES.txt +0 -0
  26. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools.egg-info/dependency_links.txt +0 -0
  27. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools.egg-info/requires.txt +0 -0
  28. {mousetools-4.2.0 → mousetools-4.3.0}/mousetools.egg-info/top_level.txt +0 -0
  29. {mousetools-4.2.0 → mousetools-4.3.0}/setup.cfg +0 -0
  30. {mousetools-4.2.0 → mousetools-4.3.0}/tests/test_mixins.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.2.0
3
+ Version: 4.3.0
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -1,11 +1,62 @@
1
+ import logging
1
2
  import typing
2
3
  from datetime import datetime, timedelta
3
4
  from enum import Enum
4
5
 
6
+ from dateutil.parser import isoparse
7
+
5
8
  from mousetools.channels.enums import DestinationTimezones, DLRCouchbaseChannels, WDWCouchbaseChannels
6
9
  from mousetools.enums import DestinationShort, EntityType
7
10
  from mousetools.mixins.couchbase import CouchbaseMixin
8
11
 
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class CouchbaseChildChannel(CouchbaseMixin):
16
+ def __init__(self, channel_id: str, lazy_load: bool = True):
17
+ if isinstance(channel_id, Enum):
18
+ channel_id = channel_id.value
19
+
20
+ self.channel_id: str = channel_id
21
+ self.entity_id: str = channel_id.rsplit(".", 1)[-1]
22
+
23
+ self._destination_short: DestinationShort = self.channel_id.split(".")[0]
24
+ self._tz: DestinationTimezones = (
25
+ DestinationTimezones.WALT_DISNEY_WORLD
26
+ if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
27
+ else DestinationTimezones.DISNEYLAND_RESORT
28
+ )
29
+ self._refresh_interval: timedelta = timedelta(minutes=30)
30
+ self._cb_data: typing.Optional[dict] = None
31
+ self._cb_data_pull_time: datetime = datetime.now(tz=self._tz.value)
32
+ if not lazy_load:
33
+ self.refresh()
34
+
35
+ def refresh(self) -> None:
36
+ """Pulls initial data if none exists or if it is older than the refresh interval"""
37
+ if self._cb_data is None or datetime.now(tz=self._tz.value) - self.last_update > self._refresh_interval:
38
+ self._cb_data = self.get_channel_data(self.channel_id)
39
+ self._cb_data_pull_time = datetime.now(tz=self._tz.value)
40
+
41
+ @property
42
+ def last_update(self) -> datetime:
43
+ """
44
+ The last time the data was updated.
45
+
46
+ Returns:
47
+ (datetime): The last time the entity's data was updated, or None if no such data exists.
48
+ """
49
+ if self._cb_data is None:
50
+ self._cb_data = self.get_channel_data(self.channel_id)
51
+
52
+ try:
53
+ dt = isoparse(self._cb_data["lastUpdate"])
54
+ dt = dt.replace(tzinfo=self._tz.value)
55
+ return dt
56
+ except (KeyError, TypeError, ValueError):
57
+ logger.debug("No last updated found for %s", self.channel_id)
58
+ return self._cb_data_pull_time
59
+
9
60
 
10
61
  class CouchbaseChannel(CouchbaseMixin):
11
62
  def __init__(self, channel_id: typing.Union[WDWCouchbaseChannels, DLRCouchbaseChannels], lazy_load: bool = True):
@@ -1,21 +1,17 @@
1
1
  import logging
2
2
  import typing
3
- from datetime import datetime, timedelta
4
- from enum import Enum
5
3
  from zoneinfo import ZoneInfo
6
4
 
7
5
  from dateutil.parser import isoparse
8
6
 
9
- from mousetools.channels import CouchbaseChannel
10
- from mousetools.channels.enums import CouchbaseChannels, DestinationTimezones
7
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
8
+ from mousetools.channels.enums import CouchbaseChannels
11
9
  from mousetools.decorators import disney_property
12
- from mousetools.enums import DestinationShort
13
- from mousetools.mixins.couchbase import CouchbaseMixin
14
10
 
15
11
  logger = logging.getLogger(__name__)
16
12
 
17
13
 
18
- class CalendarChildChannel(CouchbaseMixin):
14
+ class CalendarChildChannel(CouchbaseChildChannel):
19
15
  def __init__(
20
16
  self,
21
17
  channel_id: str,
@@ -26,34 +22,11 @@ class CalendarChildChannel(CouchbaseMixin):
26
22
  channel_id (str): Calendar Channel ID
27
23
  lazy_load (bool, optional): If True, will not pull data until a method or property is called. Defaults to True.
28
24
  """
29
- if isinstance(channel_id, Enum):
30
- channel_id = channel_id.value
31
-
32
- self.channel_id: str = channel_id
33
- self.entity_id: str = channel_id.rsplit(".", 1)[-1]
34
-
35
- self._destination_short: DestinationShort = self.channel_id.split(".")[0]
36
- self._tz: DestinationTimezones = (
37
- DestinationTimezones.WALT_DISNEY_WORLD
38
- if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
39
- else DestinationTimezones.DISNEYLAND_RESORT
40
- )
41
- self._refresh_interval: timedelta = timedelta(minutes=30)
42
-
43
- self._cb_data: typing.Optional[dict] = None
44
- self._cb_data_pull_time: datetime = datetime.now(tz=self._tz.value)
45
- if not lazy_load:
46
- self.refresh()
25
+ super().__init__(channel_id, lazy_load=lazy_load)
47
26
 
48
27
  def __repr__(self):
49
28
  return f"{self.__class__.__name__}(channel_id='{self.channel_id}')"
50
29
 
51
- def refresh(self) -> None:
52
- """Pulls initial data if none exists or if it is older than the refresh interval"""
53
- if self._cb_data is None or datetime.now(tz=self._tz.value) - self.last_update > self._refresh_interval:
54
- self._cb_data = self.get_channel_data(self.channel_id)
55
- self._cb_data_pull_time = datetime.now(tz=self._tz.value)
56
-
57
30
  @disney_property()
58
31
  def calendar_id(self) -> typing.Optional[str]:
59
32
  """The ID of the calendar
@@ -63,24 +36,6 @@ class CalendarChildChannel(CouchbaseMixin):
63
36
  """
64
37
  return self._cb_data["id"]
65
38
 
66
- @property
67
- def last_update(self) -> datetime:
68
- """The last time the data was updated.
69
-
70
- Returns:
71
- (datetime): The last time the entity's data was updated, or None if no such data exists.
72
- """
73
- if self._cb_data is None:
74
- self._cb_data = self.get_channel_data(self.channel_id)
75
-
76
- try:
77
- dt = isoparse(self._cb_data["lastUpdate"])
78
- dt = dt.replace(tzinfo=self._tz.value)
79
- return dt
80
- except (KeyError, ValueError, TypeError):
81
- logger.debug("No last updated found for %s", self.channel_id)
82
- return self._cb_data_pull_time
83
-
84
39
  @disney_property()
85
40
  def all_closed(self) -> typing.Optional[list[dict]]:
86
41
  """The list of closed facilities.
@@ -1,20 +1,16 @@
1
1
  import logging
2
- from datetime import datetime, timedelta
3
- from enum import Enum
4
2
  from typing import Optional
5
3
 
6
4
  from dateutil.parser import isoparse
7
5
 
8
- from mousetools.channels import CouchbaseChannel
9
- from mousetools.channels.enums import CouchbaseChannels, DestinationTimezones
6
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
7
+ from mousetools.channels.enums import CouchbaseChannels
10
8
  from mousetools.decorators import disney_property
11
- from mousetools.enums import DestinationShort
12
- from mousetools.mixins.couchbase import CouchbaseMixin
13
9
 
14
10
  logger = logging.getLogger(__name__)
15
11
 
16
12
 
17
- class CharactersChildChannel(CouchbaseMixin):
13
+ class CharactersChildChannel(CouchbaseChildChannel):
18
14
  def __init__(
19
15
  self,
20
16
  channel_id: str,
@@ -25,52 +21,11 @@ class CharactersChildChannel(CouchbaseMixin):
25
21
  channel_id (str): Forecasted Wait Times Channel ID
26
22
  lazy_load (bool, optional): If True, will not pull data until a method or property is called. Defaults to True.
27
23
  """
28
- if isinstance(channel_id, Enum):
29
- channel_id = channel_id.value
30
-
31
- self.channel_id: str = channel_id
32
- self.entity_id: str = channel_id.rsplit(".", 1)[-1]
33
-
34
- self._destination_short: DestinationShort = self.channel_id.split(".")[0]
35
- self._tz: DestinationTimezones = (
36
- DestinationTimezones.WALT_DISNEY_WORLD
37
- if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
38
- else DestinationTimezones.DISNEYLAND_RESORT
39
- )
40
- self._refresh_interval: timedelta = timedelta(minutes=30)
41
-
42
- self._cb_data: Optional[dict] = None
43
- self._cb_data_pull_time: Optional[datetime] = datetime.now(tz=self._tz.value)
44
- if not lazy_load:
45
- self.refresh()
24
+ super().__init__(channel_id, lazy_load=lazy_load)
46
25
 
47
26
  def __repr__(self):
48
27
  return f"{self.__class__.__name__}(channel_id='{self.channel_id}')"
49
28
 
50
- def refresh(self) -> None:
51
- """Pulls initial data if none exists or if it is older than the refresh interval"""
52
- if self._cb_data is None or datetime.now(tz=self._tz.value) - self.last_update > self._refresh_interval:
53
- self._cb_data = self.get_channel_data(self.channel_id)
54
- self._cb_data_pull_time = datetime.now(tz=self._tz.value)
55
-
56
- @property
57
- def last_update(self) -> datetime:
58
- """The last time the data was updated.
59
-
60
- Returns:
61
- (datetime): The last time the entity's data was updated, or None if no such data exists.
62
- """
63
- if self._cb_data is None:
64
- self._cb_data = self.get_channel_data(self.channel_id)
65
-
66
- try:
67
- dt = isoparse(self._cb_data["lastUpdate"])
68
- dt = dt.replace(tzinfo=self._tz.value)
69
- return dt
70
- except (KeyError, TypeError, ValueError):
71
- logger.debug("No last updated found for %s", self.channel_id)
72
- return self._cb_data_pull_time
73
-
74
29
  @disney_property()
75
30
  def name(self) -> Optional[str]:
76
31
  """The name of the entity.
@@ -2,18 +2,15 @@ import logging
2
2
  import os
3
3
  import typing
4
4
  from datetime import datetime, time, timedelta
5
- from enum import Enum
6
5
  from zoneinfo import ZoneInfo
7
6
 
8
7
  import httpx
9
- from dateutil.parser import isoparse
10
8
 
11
9
  from mousetools.api.menu import Menus
12
- from mousetools.channels import CouchbaseChannel
10
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
13
11
  from mousetools.channels.calendar import CalendarChildChannel
14
12
  from mousetools.channels.enums import (
15
13
  CouchbaseChannels,
16
- DestinationTimezones,
17
14
  DLRCouchbaseChannels,
18
15
  WDWCouchbaseChannels,
19
16
  )
@@ -21,12 +18,11 @@ from mousetools.channels.facilitystatus import FacilityStatusChildChannel
21
18
  from mousetools.channels.forecastedwaittimes import ForecastedWaitTimesChildChannel
22
19
  from mousetools.decorators import disney_property
23
20
  from mousetools.enums import DestinationShort, EntityType
24
- from mousetools.mixins.couchbase import CouchbaseMixin
25
21
 
26
22
  logger = logging.getLogger(__name__)
27
23
 
28
24
 
29
- class FacilityChildChannel(CouchbaseMixin):
25
+ class FacilityChildChannel(CouchbaseChildChannel):
30
26
  """Base class for all Facility Child Channels. Subclasses like Attraction, Restaurant, Entertainment, etc. extend this class.
31
27
 
32
28
  Example:
@@ -51,27 +47,12 @@ class FacilityChildChannel(CouchbaseMixin):
51
47
  channel_id (str): Facility Channel ID
52
48
  lazy_load (bool, optional): If True, will not pull data until a method or property is called. Defaults to True.
53
49
  """
54
- if isinstance(channel_id, Enum):
55
- channel_id = channel_id.value
50
+ super().__init__(channel_id, lazy_load=lazy_load)
56
51
 
57
- self.channel_id: str = channel_id
58
- self.entity_id: str = channel_id.rsplit(".", 1)[-1]
59
-
60
- self._destination_short: DestinationShort = self.channel_id.split(".")[0]
61
- self._tz: DestinationTimezones = (
62
- DestinationTimezones.WALT_DISNEY_WORLD
63
- if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
64
- else DestinationTimezones.DISNEYLAND_RESORT
65
- )
66
52
  self._refresh_interval: timedelta = timedelta(
67
53
  hours=12
68
54
  ) # properties are rarely updated, no need to spam the API
69
55
 
70
- self._cb_data: typing.Optional[dict] = None
71
- self._cb_data_pull_time: datetime = datetime.now(tz=self._tz.value)
72
- if not lazy_load:
73
- self.refresh()
74
-
75
56
  self._today_calendar: typing.Optional[CalendarChildChannel] = None
76
57
 
77
58
  def refresh(self) -> None:
@@ -392,30 +373,6 @@ class FacilityChildChannel(CouchbaseMixin):
392
373
 
393
374
  return FacilityStatusChildChannel(facility_status_channel_id)
394
375
 
395
- @property
396
- def last_update(self) -> datetime:
397
- """
398
- The last time the data was updated.
399
-
400
- Returns:
401
- (datetime): The last time the entity's data was updated, or None if no such data exists.
402
- """
403
- if self._cb_data is None:
404
- self._cb_data = self.get_channel_data(self.channel_id)
405
-
406
- try:
407
- tz = (
408
- DestinationTimezones.WALT_DISNEY_WORLD
409
- if "wdw" in self.channel_id
410
- else DestinationTimezones.DISNEYLAND_RESORT
411
- )
412
- dt = isoparse(self._cb_data["lastUpdate"])
413
- dt = dt.replace(tzinfo=tz.value)
414
- return dt
415
- except (KeyError, TypeError, ValueError):
416
- logger.debug("No last updated found for %s", self.channel_id)
417
- return self._cb_data_pull_time
418
-
419
376
  @disney_property()
420
377
  def sponsor_name(self) -> typing.Optional[str]:
421
378
  """The sponsor name of the entity.
@@ -1,45 +1,25 @@
1
1
  import logging
2
2
  import typing
3
- from datetime import datetime, timedelta
3
+ from datetime import datetime
4
4
 
5
5
  from dateutil.parser import isoparse
6
6
 
7
- from mousetools.channels import CouchbaseChannel
8
- from mousetools.channels.enums import CouchbaseChannels, DestinationTimezones
7
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
8
+ from mousetools.channels.enums import CouchbaseChannels
9
9
  from mousetools.decorators import disney_property
10
- from mousetools.enums import DestinationShort, EntityType
11
- from mousetools.mixins.couchbase import CouchbaseMixin
10
+ from mousetools.enums import EntityType
12
11
 
13
12
  logger = logging.getLogger(__name__)
14
13
 
15
14
 
16
- class FacilityStatusChildChannel(CouchbaseMixin):
15
+ class FacilityStatusChildChannel(CouchbaseChildChannel):
17
16
  def __init__(self, channel_id: str, lazy_load: bool = True):
18
17
  """
19
18
  Args:
20
19
  channel_id (typing.Union[WDWCouchbaseChannels, DLRCouchbaseChannels]): Channel ID from the enum
21
20
  lazy_load (bool, optional): If True, will not pull data until a method or property is called. Defaults to True.
22
21
  """
23
- self.channel_id = channel_id
24
-
25
- self._destination_short: DestinationShort = channel_id.split(".")[0]
26
- self._tz: DestinationTimezones = (
27
- DestinationTimezones.WALT_DISNEY_WORLD
28
- if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
29
- else DestinationTimezones.DISNEYLAND_RESORT
30
- )
31
- self._refresh_interval: timedelta = timedelta(minutes=10)
32
- self._cb_data: typing.Optional[dict] = None
33
- self._cb_data_pull_time: datetime = datetime.now(tz=self._tz.value)
34
-
35
- if not lazy_load:
36
- self.refresh()
37
-
38
- def refresh(self) -> None:
39
- """Pulls initial data if none exists or if it is older than the refresh interval"""
40
- if self._cb_data is None or datetime.now(tz=self._tz.value) - self.last_update > self._refresh_interval:
41
- self._cb_data = self.get_channel_data(self.channel_id)
42
- self._cb_data_pull_time = datetime.now(tz=self._tz.value)
22
+ super().__init__(channel_id, lazy_load=lazy_load)
43
23
 
44
24
  def get_status(self) -> typing.Optional[str]:
45
25
  """Get the operating status of the facility
@@ -69,24 +49,6 @@ class FacilityStatusChildChannel(CouchbaseMixin):
69
49
  logger.debug("No wait time found for %s", self.channel_id)
70
50
  return None
71
51
 
72
- @property
73
- def last_update(self) -> datetime:
74
- """The last time the data was updated.
75
-
76
- Returns:
77
- (datetime): The last time the entity's data was updated, or None if no such data exists.
78
- """
79
- if self._cb_data is None:
80
- self._cb_data = self.get_channel_data(self.channel_id)
81
-
82
- try:
83
- dt = isoparse(self._cb_data["lastUpdate"])
84
- dt = dt.replace(tzinfo=self._tz.value)
85
- return dt
86
- except (KeyError, TypeError, ValueError):
87
- logger.debug("No last updated found for %s", self.channel_id)
88
- return self._cb_data_pull_time
89
-
90
52
  @disney_property()
91
53
  def fast_pass_available(self) -> typing.Optional[bool]:
92
54
  return self._cb_data["fastPassAvailable"]
@@ -157,6 +119,25 @@ class FacilityStatusChannel(CouchbaseChannel):
157
119
  channels.append(FacilityStatusChildChannel(i["id"]))
158
120
  return channels
159
121
 
122
+ def get_all_statuses(self) -> dict[str, dict[str, typing.Any]]:
123
+ """Get all statuses for the channel
124
+
125
+ Returns:
126
+ (dict[str, dict[str, typing.Any]]): A dictionary of all statuses for the channel
127
+ """
128
+ logger.info("Getting all children statuses for %s", self.channel_id)
129
+ children = self.get_children_channels()
130
+ logger.debug("Got %d children for %s", len(children), self.channel_id)
131
+
132
+ statuses = {}
133
+ for child in children:
134
+ tmp = {}
135
+ tmp["status"] = child.get_status()
136
+ tmp["wait_time"] = child.get_wait_time()
137
+ statuses[child.entity_id] = tmp
138
+
139
+ return statuses
140
+
160
141
  def get_children_attractions(self) -> list[AttractionFacilityStatusChild]: # type: ignore
161
142
  """Get AttractionFacilityStatusChild Children of a Facility
162
143
 
@@ -1,19 +1,14 @@
1
1
  import logging
2
- import typing
3
- from datetime import datetime, timedelta
4
- from enum import Enum
5
2
 
6
3
  from dateutil.parser import isoparse
7
4
 
8
- from mousetools.channels import CouchbaseChannel
9
- from mousetools.channels.enums import CouchbaseChannels, DestinationTimezones
10
- from mousetools.enums import DestinationShort
11
- from mousetools.mixins.couchbase import CouchbaseMixin
5
+ from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
6
+ from mousetools.channels.enums import CouchbaseChannels
12
7
 
13
8
  logger = logging.getLogger(__name__)
14
9
 
15
10
 
16
- class ForecastedWaitTimesChildChannel(CouchbaseMixin):
11
+ class ForecastedWaitTimesChildChannel(CouchbaseChildChannel):
17
12
  def __init__(
18
13
  self,
19
14
  channel_id: str,
@@ -24,52 +19,11 @@ class ForecastedWaitTimesChildChannel(CouchbaseMixin):
24
19
  channel_id (str): Forecasted Wait Times Channel ID
25
20
  lazy_load (bool, optional): If True, will not pull data until a method or property is called. Defaults to True.
26
21
  """
27
- if isinstance(channel_id, Enum):
28
- channel_id = channel_id.value
29
-
30
- self.channel_id: str = channel_id
31
- self.entity_id: str = channel_id.rsplit(".", 1)[-1]
32
-
33
- self._destination_short: DestinationShort = self.channel_id.split(".")[0]
34
- self._tz: DestinationTimezones = (
35
- DestinationTimezones.WALT_DISNEY_WORLD
36
- if self._destination_short == DestinationShort.WALT_DISNEY_WORLD
37
- else DestinationTimezones.DISNEYLAND_RESORT
38
- )
39
- self._refresh_interval: timedelta = timedelta(minutes=30)
40
-
41
- self._cb_data: typing.Optional[dict] = None
42
- self._cb_data_pull_time: datetime = datetime.now(tz=self._tz.value)
43
- if not lazy_load:
44
- self.refresh()
22
+ super().__init__(channel_id, lazy_load=lazy_load)
45
23
 
46
24
  def __repr__(self):
47
25
  return f"{self.__class__.__name__}(channel_id='{self.channel_id}')"
48
26
 
49
- def refresh(self) -> None:
50
- """Pulls initial data if none exists or if it is older than the refresh interval"""
51
- if self._cb_data is None or datetime.now(tz=self._tz.value) - self.last_update > self._refresh_interval:
52
- self._cb_data = self.get_channel_data(self.channel_id)
53
- self._cb_data_pull_time = datetime.now(tz=self._tz.value)
54
-
55
- @property
56
- def last_update(self) -> datetime:
57
- """The last time the data was updated.
58
-
59
- Returns:
60
- (datetime): The last time the entity's data was updated, or None if no such data exists.
61
- """
62
- if self._cb_data is None:
63
- self._cb_data = self.get_channel_data(self.channel_id)
64
-
65
- try:
66
- dt = isoparse(self._cb_data["lastUpdate"])
67
- dt = dt.replace(tzinfo=self._tz.value)
68
- return dt
69
- except (KeyError, TypeError, ValueError):
70
- logger.debug("No last updated found for %s", self.channel_id)
71
- return self._cb_data_pull_time
72
-
73
27
  def get_forecast(self) -> list[dict]:
74
28
  """Returns a list of forecasted wait times sorted by timestamp
75
29
 
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
11
11
 
12
12
 
13
13
  class CouchbaseMixin:
14
- _couchbase_url = "https://" + auth_obj._environments["syncGatewayUrl"].split("//")[1]
14
+ _couchbase_url = "https://" + auth_obj._environments["syncGatewayUrl"].split("//")[1].rstrip("/")
15
15
  _headers: dict = auth_obj.get_couchbase_headers()
16
16
 
17
17
  def get_channel_data(self, channel_name: str) -> typing.Union[dict, None]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.2.0
3
+ Version: 4.3.0
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mousetools"
3
- version = "4.2.0"
3
+ version = "4.3.0"
4
4
  authors = [{name = "Scott Caratozzolo"}]
5
5
  description = "An unofficial Python wrapper for Disney's API"
6
6
  readme = "README.md"
File without changes
File without changes
File without changes