MouseTools 4.5.0__tar.gz → 4.5.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 (33) hide show
  1. {mousetools-4.5.0 → mousetools-4.5.1}/PKG-INFO +2 -1
  2. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/manager.py +22 -12
  3. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/mixins/couchbase.py +17 -4
  4. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools.egg-info/PKG-INFO +2 -1
  5. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools.egg-info/requires.txt +1 -0
  6. {mousetools-4.5.0 → mousetools-4.5.1}/pyproject.toml +2 -1
  7. {mousetools-4.5.0 → mousetools-4.5.1}/LICENSE +0 -0
  8. {mousetools-4.5.0 → mousetools-4.5.1}/README.md +0 -0
  9. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/__init__.py +0 -0
  10. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/api/__init__.py +0 -0
  11. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/api/menu.py +0 -0
  12. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/api/search.py +0 -0
  13. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/auth.py +0 -0
  14. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/__init__.py +0 -0
  15. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/calendar/__init__.py +0 -0
  16. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/characters/__init__.py +0 -0
  17. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/enums.py +0 -0
  18. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/facilities/__init__.py +0 -0
  19. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/facilities/enums.py +0 -0
  20. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/facilitystatus/__init__.py +0 -0
  21. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/forecastedwaittimes/__init__.py +0 -0
  22. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/channels/today/__init__.py +0 -0
  23. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/decorators.py +0 -0
  24. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/enums.py +0 -0
  25. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/mixins/__init__.py +0 -0
  26. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/mixins/disney.py +0 -0
  27. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools/resources/environments.bin +0 -0
  28. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools.egg-info/SOURCES.txt +0 -0
  29. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools.egg-info/dependency_links.txt +0 -0
  30. {mousetools-4.5.0 → mousetools-4.5.1}/mousetools.egg-info/top_level.txt +0 -0
  31. {mousetools-4.5.0 → mousetools-4.5.1}/setup.cfg +0 -0
  32. {mousetools-4.5.0 → mousetools-4.5.1}/tests/test_manager.py +0 -0
  33. {mousetools-4.5.0 → mousetools-4.5.1}/tests/test_mixins.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.5.0
3
+ Version: 4.5.1
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: <4.0,>=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: more-itertools>=10.7.0
20
21
  Requires-Dist: pycryptodome>=3.22.0
21
22
  Requires-Dist: python-dateutil>=2.9.0.post0
22
23
  Requires-Dist: requests>=2.32.3
@@ -1,6 +1,8 @@
1
1
  import logging
2
2
  from typing import Optional, Union
3
3
 
4
+ from more_itertools import batched
5
+
4
6
  from mousetools.channels import CouchbaseChannel, CouchbaseChildChannel
5
7
  from mousetools.mixins.couchbase import CouchbaseMixin
6
8
 
@@ -84,20 +86,28 @@ class ChannelManager(CouchbaseMixin):
84
86
  "Refreshing %d children channels and %d parent channels", len(children_channels), len(parent_channels)
85
87
  )
86
88
 
89
+ self._refresh_children(children_channels)
90
+
91
+ self._refresh_parents(parent_channels)
92
+
93
+ def _refresh_children(self, children_channels: dict[str, CouchbaseChildChannel]) -> None:
87
94
  if children_channels:
88
95
  logger.debug("Refreshing children channels")
89
- children_results = self.get_channel_data(list(children_channels.keys()))
90
- for children_channel, result in zip(children_channels.values(), children_results):
91
- children_channel._refresh_from_manager(result)
96
+ for _channels in batched(children_channels, 100):
97
+ children_results = self.get_channel_data(_channels)
98
+ for channel_id, result in zip(_channels, children_results):
99
+ children_channels[channel_id]._refresh_from_manager(result)
92
100
 
101
+ def _refresh_parents(self, parent_channels: dict[str, CouchbaseChannel]) -> None:
93
102
  if parent_channels:
94
103
  logger.debug("Refreshing parent channels")
95
- parent_results = self.get_channel_changes(list(parent_channels.keys()))
96
- for channel_id, parent_channel in parent_channels.items():
97
- copy_results = parent_results.copy()
98
- new_results = []
99
- for result in copy_results["results"]:
100
- if channel_id in result["id"]:
101
- new_results.append(result)
102
- copy_results["results"] = new_results
103
- parent_channel._refresh_from_manager(copy_results)
104
+ for _channels in batched(parent_channels, 100):
105
+ parent_results = self.get_channel_changes(_channels)
106
+ for channel_id in _channels:
107
+ copy_results = parent_results.copy()
108
+ new_results = []
109
+ for result in copy_results["results"]:
110
+ if channel_id in result["id"]:
111
+ new_results.append(result)
112
+ copy_results["results"] = new_results
113
+ parent_channels[channel_id]._refresh_from_manager(copy_results)
@@ -37,9 +37,15 @@ class CouchbaseMixin:
37
37
  "json": True,
38
38
  }
39
39
 
40
- logger.info("Sending request for channel data: %s", _channel_names)
40
+ logger.info(
41
+ "Sending request for channel data: %s", f"{len(channel_name)} channels" if return_list else _channel_names
42
+ )
41
43
  response = requests.post(self._couchbase_url + "/_bulk_get", json=payload, headers=self._headers, timeout=10)
42
- logger.debug("Response status for %s: %s", _channel_names, response.status_code)
44
+ logger.debug(
45
+ "Response status for %s: %s",
46
+ f"{len(channel_name)} channels" if return_list else _channel_names,
47
+ response.status_code,
48
+ )
43
49
  results = []
44
50
  try:
45
51
  response.raise_for_status()
@@ -93,9 +99,16 @@ class CouchbaseMixin:
93
99
  if since:
94
100
  payload["since"] = since
95
101
 
96
- logger.info("Sending request for channel changes: %s", channel_name)
102
+ logger.info(
103
+ "Sending request for channel changes: %s",
104
+ f"{len(channel_name)} channels" if len(channel_name) > 1 else channel_name[0],
105
+ )
97
106
  response = requests.post(self._couchbase_url + "/_changes", json=payload, headers=self._headers, timeout=10)
98
- logger.debug("Response status for %s: %s", channel_name, response.status_code)
107
+ logger.debug(
108
+ "Response status for %s: %s",
109
+ f"{len(channel_name)} channels" if len(channel_name) > 1 else channel_name[0],
110
+ response.status_code,
111
+ )
99
112
  response.raise_for_status()
100
113
  data = response.json()
101
114
  except requests.HTTPError as err:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mousetools
3
- Version: 4.5.0
3
+ Version: 4.5.1
4
4
  Summary: An unofficial Python wrapper for Disney's API
5
5
  Author: Scott Caratozzolo
6
6
  License-Expression: MIT
@@ -17,6 +17,7 @@ Classifier: Operating System :: OS Independent
17
17
  Requires-Python: <4.0,>=3.9
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
+ Requires-Dist: more-itertools>=10.7.0
20
21
  Requires-Dist: pycryptodome>=3.22.0
21
22
  Requires-Dist: python-dateutil>=2.9.0.post0
22
23
  Requires-Dist: requests>=2.32.3
@@ -1,3 +1,4 @@
1
+ more-itertools>=10.7.0
1
2
  pycryptodome>=3.22.0
2
3
  python-dateutil>=2.9.0.post0
3
4
  requests>=2.32.3
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mousetools"
3
- version = "4.5.0"
3
+ version = "4.5.1"
4
4
  authors = [{name = "Scott Caratozzolo"}]
5
5
  description = "An unofficial Python wrapper for Disney's API"
6
6
  readme = "README.md"
@@ -8,6 +8,7 @@ license = "MIT"
8
8
  license-files = ["LICENSE"]
9
9
  requires-python = ">=3.9, <4.0"
10
10
  dependencies = [
11
+ "more-itertools>=10.7.0",
11
12
  "pycryptodome>=3.22.0",
12
13
  "python-dateutil>=2.9.0.post0",
13
14
  "requests>=2.32.3",
File without changes
File without changes
File without changes