zpdatafetch 2.3.1__tar.gz → 2.3.2__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 (84) hide show
  1. {zpdatafetch-2.3.1/src/zpdatafetch.egg-info → zpdatafetch-2.3.2}/PKG-INFO +16 -4
  2. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/README.md +15 -3
  3. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/pyproject.toml +1 -1
  4. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2/src/zpdatafetch.egg-info}/PKG-INFO +16 -4
  5. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/async_zr.py +46 -2
  6. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/cli.py +2 -0
  7. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/LICENSE +0 -0
  8. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/setup.cfg +0 -0
  9. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/__init__.py +0 -0
  10. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/cli.py +0 -0
  11. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/config.py +0 -0
  12. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/error_helpers.py +0 -0
  13. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/exceptions.py +0 -0
  14. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/http_client.py +0 -0
  15. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/json_helpers.py +0 -0
  16. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/logging.py +0 -0
  17. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/shared/validation.py +0 -0
  18. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/__init__.py +0 -0
  19. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/activity.py +0 -0
  20. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/auth.py +0 -0
  21. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/cli.py +0 -0
  22. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/config.py +0 -0
  23. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/followers.py +0 -0
  24. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/logging_config.py +0 -0
  25. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/profile.py +0 -0
  26. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/rideons.py +0 -0
  27. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/ridersinworld.py +0 -0
  28. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zdatafetch/worlds.py +0 -0
  29. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/__init__.py +0 -0
  30. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/async_zp.py +0 -0
  31. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/cli.py +0 -0
  32. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/config.py +0 -0
  33. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/logging_config.py +0 -0
  34. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zp.py +0 -0
  35. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zp_obj.py +0 -0
  36. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zp_utils.py +0 -0
  37. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpcyclist.py +0 -0
  38. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpcyclistfetch.py +0 -0
  39. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpleague.py +0 -0
  40. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpleaguefetch.py +0 -0
  41. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpprime.py +0 -0
  42. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpprimesfetch.py +0 -0
  43. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpracefinish.py +0 -0
  44. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpracelog.py +0 -0
  45. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpraceresult.py +0 -0
  46. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpracesignup.py +0 -0
  47. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpracesprint.py +0 -0
  48. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpresultfetch.py +0 -0
  49. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpsignupfetch.py +0 -0
  50. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpsprintsfetch.py +0 -0
  51. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpteam.py +0 -0
  52. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch/zpteamfetch.py +0 -0
  53. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch.egg-info/SOURCES.txt +0 -0
  54. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch.egg-info/dependency_links.txt +0 -0
  55. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch.egg-info/entry_points.txt +0 -0
  56. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch.egg-info/requires.txt +0 -0
  57. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zpdatafetch.egg-info/top_level.txt +0 -0
  58. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/__init__.py +0 -0
  59. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/config.py +0 -0
  60. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/logging_config.py +0 -0
  61. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/rate_limiter.py +0 -0
  62. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zr.py +0 -0
  63. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zr_utils.py +0 -0
  64. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrraceresult.py +0 -0
  65. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrresultfetch.py +0 -0
  66. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrrider.py +0 -0
  67. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrriderfetch.py +0 -0
  68. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrteamfetch.py +0 -0
  69. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zrdatafetch/zrteamroster.py +0 -0
  70. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/__init__.py +0 -0
  71. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/async_zs.py +0 -0
  72. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/cli.py +0 -0
  73. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/logging_config.py +0 -0
  74. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/__init__.py +0 -0
  75. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/component.py +0 -0
  76. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/incident.py +0 -0
  77. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/maintenance.py +0 -0
  78. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/page.py +0 -0
  79. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/status.py +0 -0
  80. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/models/summary.py +0 -0
  81. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/zs.py +0 -0
  82. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/zsincidentfetch.py +0 -0
  83. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/zsmaintenancefetch.py +0 -0
  84. {zpdatafetch-2.3.1 → zpdatafetch-2.3.2}/src/zsdatafetch/zssummaryfetch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zpdatafetch
3
- Version: 2.3.1
3
+ Version: 2.3.2
4
4
  Summary: A package for fetching data from Zwiftpower and Zwiftracing.app
5
5
  Author-email: Doug Morris <doug@mhost.com>
6
6
  License-Expression: MIT
@@ -704,7 +704,8 @@ status = ZRRider().rate_limiter.get_status() if hasattr(ZRRider(), 'rate_limiter
704
704
 
705
705
  #### Async Rate Limiting
706
706
 
707
- Async operations also respect rate limits with automatic throttling:
707
+ Async operations also respect rate limits with automatic throttling. As with
708
+ the sync API, the tier can be set globally and per call:
708
709
 
709
710
  ```python
710
711
  import anyio
@@ -717,12 +718,23 @@ async def main():
717
718
  rider.set_session(zr)
718
719
  await rider.fetch(12345) # Auto-throttled to standard limits
719
720
 
720
- # Premium tier
721
- async with AsyncZR_obj(premium=True) as zr:
721
+ # Premium tier - set globally (applies to existing and new instances)
722
+ AsyncZR_obj.set_premium_mode(True)
723
+ async with AsyncZR_obj() as zr:
722
724
  rider = AsyncZRRider()
723
725
  rider.set_session(zr)
724
726
  await rider.fetch(12345) # Auto-throttled to premium limits
725
727
 
728
+ # Premium tier - per call
729
+ async with AsyncZR_obj() as zr:
730
+ await zr.fetch_json('/public/riders/12345', premium=True)
731
+
732
+ # Premium tier - per instance
733
+ async with AsyncZR_obj(premium=True) as zr:
734
+ rider = AsyncZRRider()
735
+ rider.set_session(zr)
736
+ await rider.fetch(12345)
737
+
726
738
  anyio.run(main)
727
739
  ```
728
740
 
@@ -675,7 +675,8 @@ status = ZRRider().rate_limiter.get_status() if hasattr(ZRRider(), 'rate_limiter
675
675
 
676
676
  #### Async Rate Limiting
677
677
 
678
- Async operations also respect rate limits with automatic throttling:
678
+ Async operations also respect rate limits with automatic throttling. As with
679
+ the sync API, the tier can be set globally and per call:
679
680
 
680
681
  ```python
681
682
  import anyio
@@ -688,12 +689,23 @@ async def main():
688
689
  rider.set_session(zr)
689
690
  await rider.fetch(12345) # Auto-throttled to standard limits
690
691
 
691
- # Premium tier
692
- async with AsyncZR_obj(premium=True) as zr:
692
+ # Premium tier - set globally (applies to existing and new instances)
693
+ AsyncZR_obj.set_premium_mode(True)
694
+ async with AsyncZR_obj() as zr:
693
695
  rider = AsyncZRRider()
694
696
  rider.set_session(zr)
695
697
  await rider.fetch(12345) # Auto-throttled to premium limits
696
698
 
699
+ # Premium tier - per call
700
+ async with AsyncZR_obj() as zr:
701
+ await zr.fetch_json('/public/riders/12345', premium=True)
702
+
703
+ # Premium tier - per instance
704
+ async with AsyncZR_obj(premium=True) as zr:
705
+ rider = AsyncZRRider()
706
+ rider.set_session(zr)
707
+ await rider.fetch(12345)
708
+
697
709
  anyio.run(main)
698
710
  ```
699
711
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "zpdatafetch"
3
- version = "2.3.1"
3
+ version = "2.3.2"
4
4
  description = "A package for fetching data from Zwiftpower and Zwiftracing.app"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zpdatafetch
3
- Version: 2.3.1
3
+ Version: 2.3.2
4
4
  Summary: A package for fetching data from Zwiftpower and Zwiftracing.app
5
5
  Author-email: Doug Morris <doug@mhost.com>
6
6
  License-Expression: MIT
@@ -704,7 +704,8 @@ status = ZRRider().rate_limiter.get_status() if hasattr(ZRRider(), 'rate_limiter
704
704
 
705
705
  #### Async Rate Limiting
706
706
 
707
- Async operations also respect rate limits with automatic throttling:
707
+ Async operations also respect rate limits with automatic throttling. As with
708
+ the sync API, the tier can be set globally and per call:
708
709
 
709
710
  ```python
710
711
  import anyio
@@ -717,12 +718,23 @@ async def main():
717
718
  rider.set_session(zr)
718
719
  await rider.fetch(12345) # Auto-throttled to standard limits
719
720
 
720
- # Premium tier
721
- async with AsyncZR_obj(premium=True) as zr:
721
+ # Premium tier - set globally (applies to existing and new instances)
722
+ AsyncZR_obj.set_premium_mode(True)
723
+ async with AsyncZR_obj() as zr:
722
724
  rider = AsyncZRRider()
723
725
  rider.set_session(zr)
724
726
  await rider.fetch(12345) # Auto-throttled to premium limits
725
727
 
728
+ # Premium tier - per call
729
+ async with AsyncZR_obj() as zr:
730
+ await zr.fetch_json('/public/riders/12345', premium=True)
731
+
732
+ # Premium tier - per instance
733
+ async with AsyncZR_obj(premium=True) as zr:
734
+ rider = AsyncZRRider()
735
+ rider.set_session(zr)
736
+ await rider.fetch(12345)
737
+
726
738
  anyio.run(main)
727
739
  ```
728
740
 
@@ -4,7 +4,7 @@ This module provides async/await compatible interfaces for the Zwiftracing API,
4
4
  allowing for concurrent requests and better performance in async applications.
5
5
  """
6
6
 
7
- from typing import Any
7
+ from typing import Any, ClassVar
8
8
 
9
9
  import anyio
10
10
  import httpx2
@@ -36,11 +36,38 @@ class AsyncZR_obj:
36
36
  Attributes:
37
37
  _base_url: Base URL for Zwiftracing API
38
38
  _client: httpx2.AsyncClient instance
39
+ _premium_mode: Class-level setting for premium tier rate limits
39
40
  """
40
41
 
41
42
  _base_url: str = 'https://api.zwiftracing.app/api'
42
43
  _shared_client: httpx2.AsyncClient | None = None
43
44
  _owns_client: bool = False
45
+ _premium_mode: ClassVar[bool] = False # Default to standard tier
46
+
47
+ # ----------------------------------------------------------------------------
48
+ @classmethod
49
+ def set_premium_mode(cls, premium: bool) -> None:
50
+ """Set the global premium tier rate limit mode.
51
+
52
+ Applies to all async instances, including ones already created: the
53
+ effective tier is recomputed on each request.
54
+
55
+ Args:
56
+ premium: True for premium tier (higher limits), False for standard tier
57
+ """
58
+ cls._premium_mode = premium
59
+ tier = 'premium' if premium else 'standard'
60
+ logger.info(f'Rate limit tier set to: {tier}')
61
+
62
+ # ----------------------------------------------------------------------------
63
+ @classmethod
64
+ def get_premium_mode(cls) -> bool:
65
+ """Get the current premium tier mode setting.
66
+
67
+ Returns:
68
+ True if premium tier is enabled, False for standard tier
69
+ """
70
+ return cls._premium_mode
44
71
 
45
72
  # ----------------------------------------------------------------------------
46
73
  def __init__(
@@ -59,7 +86,11 @@ class AsyncZR_obj:
59
86
  """
60
87
  self._client: httpx2.AsyncClient | None = None
61
88
  self._owns_client = not shared_client
62
- self.rate_limiter = RateLimiter(tier='premium' if premium else 'standard')
89
+ self._premium = premium
90
+ use_premium = premium or self._premium_mode
91
+ self.rate_limiter = RateLimiter(
92
+ tier='premium' if use_premium else 'standard',
93
+ )
63
94
 
64
95
  if shared_client and AsyncZR_obj._shared_client is None:
65
96
  logger.debug('Creating shared async HTTP client for connection pooling')
@@ -107,6 +138,7 @@ class AsyncZR_obj:
107
138
  method: str = 'GET',
108
139
  max_retries: int = 3,
109
140
  backoff_factor: float = 1.0,
141
+ premium: bool = False,
110
142
  **kwargs: Any,
111
143
  ) -> httpx2.Response:
112
144
  """Fetch endpoint with exponential backoff retry logic (async).
@@ -120,6 +152,7 @@ class AsyncZR_obj:
120
152
  method: HTTP method (default: 'GET')
121
153
  max_retries: Maximum number of retry attempts (default: 3)
122
154
  backoff_factor: Multiplier for exponential backoff (default: 1.0)
155
+ premium: Force premium tier for this request (default: False)
123
156
  **kwargs: Additional arguments to pass to httpx client method
124
157
 
125
158
  Returns:
@@ -132,6 +165,12 @@ class AsyncZR_obj:
132
165
  await self.init_client()
133
166
  assert self._client is not None
134
167
 
168
+ # Resolve effective tier: per-call, per-instance, then class-level mode
169
+ use_premium = premium or self._premium or self._premium_mode
170
+ desired_tier = 'premium' if use_premium else 'standard'
171
+ if self.rate_limiter.tier != desired_tier:
172
+ self.rate_limiter.set_tier(desired_tier)
173
+
135
174
  # Check rate limits before attempting request
136
175
  endpoint_type = RateLimiter.get_endpoint_type(method, endpoint)
137
176
  await self.rate_limiter.wait_if_needed(endpoint_type)
@@ -222,6 +261,7 @@ class AsyncZR_obj:
222
261
  endpoint: str,
223
262
  method: str = 'GET',
224
263
  max_retries: int = 3,
264
+ premium: bool = False,
225
265
  **kwargs: Any,
226
266
  ) -> str:
227
267
  """Fetch JSON data from Zwiftracing endpoint, return raw string (async).
@@ -234,6 +274,9 @@ class AsyncZR_obj:
234
274
  endpoint: API endpoint path (e.g., '/public/riders/123')
235
275
  method: HTTP method ('GET' or 'POST'). Default: 'GET'
236
276
  max_retries: Maximum number of retry attempts for transient errors
277
+ premium: Force premium tier rate limits for this request
278
+ (default: False). The effective tier is also taken from the instance
279
+ and the class-level mode set by set_premium_mode().
237
280
  **kwargs: Additional arguments passed to httpx request method
238
281
  (e.g., headers, params, json, etc.)
239
282
 
@@ -264,6 +307,7 @@ class AsyncZR_obj:
264
307
  endpoint,
265
308
  method=method,
266
309
  max_retries=max_retries,
310
+ premium=premium,
267
311
  **kwargs,
268
312
  )
269
313
 
@@ -25,6 +25,7 @@ from shared.cli import (
25
25
  )
26
26
  from shared.validation import ValidationError, parse_datetime_to_epoch
27
27
  from zrdatafetch import (
28
+ AsyncZR_obj,
28
29
  Config,
29
30
  ZRResultFetch,
30
31
  ZRRiderFetch,
@@ -112,6 +113,7 @@ Module for fetching Zwiftracing data using the Zwiftracing API
112
113
  # Set premium tier mode if requested
113
114
  if args.premium:
114
115
  ZR_obj.set_premium_mode(True)
116
+ AsyncZR_obj.set_premium_mode(True)
115
117
 
116
118
  # Handle --sync flag (enable synchronous mode)
117
119
  if args.sync:
File without changes
File without changes