wbapi-async 0.6.0__tar.gz → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbapi-async
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: Asynchronous client for Wildberries API
5
5
  Project-URL: Documentation, https://serdukow.github.io/wbapi-async/
6
6
  Project-URL: Repository, https://github.com/serdukow/wbapi-async
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "wbapi-async"
7
- version = "0.6.0"
7
+ version = "0.6.2"
8
8
  description = "Asynchronous client for Wildberries API"
9
9
  authors = [
10
10
  { name = "Andrei Serdiukov", email = "asyncdf@gmail.com" },
@@ -477,8 +477,30 @@ def _get_limiter(path: str) -> AsyncLimiter:
477
477
  return _limiters[key]
478
478
 
479
479
 
480
+ _EXTRA_ALLOWED_HOSTS: frozenset[str] = frozenset(
481
+ {
482
+ "card.wb.ru",
483
+ }
484
+ )
485
+
486
+
480
487
  def resolve_url(path: str) -> str:
481
- """Resolve full URL for a spec path like /api/v3/supplies."""
488
+ """Resolve full URL for a spec path like /api/v3/supplies.
489
+
490
+ If a full URL is passed, it is returned as-is provided its host is a known
491
+ wildberries.ru domain or is listed in ``_EXTRA_ALLOWED_HOSTS``.
492
+ """
493
+ from urllib.parse import urlparse
494
+
495
+ from .exceptions import WbAPIError
496
+
497
+ if path.startswith("https://") or path.startswith("http://"):
498
+ host = urlparse(path).netloc
499
+ known_hosts = {urlparse(v).netloc for v in _PATH_TO_BASE.values()} | _EXTRA_ALLOWED_HOSTS
500
+ if host not in known_hosts:
501
+ raise WbAPIError(detail=f"Unknown host {host!r}.")
502
+ return path
503
+
482
504
  base = _PATH_TO_BASE.get(path)
483
505
  if base:
484
506
  return base + path
@@ -489,8 +511,6 @@ def resolve_url(path: str) -> str:
489
511
  candidate = "/".join(parts[:i])
490
512
  if candidate in _PATH_TO_BASE:
491
513
  return _PATH_TO_BASE[candidate] + path
492
- from .exceptions import WbAPIError
493
-
494
514
  raise WbAPIError(detail=f"Unknown path {path!r}. Check available paths at https://dev.wildberries.ru")
495
515
 
496
516
 
@@ -504,6 +524,11 @@ def _extract_list(raw: Any) -> list[Any] | None:
504
524
  for v in raw.values():
505
525
  if isinstance(v, list):
506
526
  return v
527
+ for v in raw.values():
528
+ if isinstance(v, dict):
529
+ found = _extract_list(v)
530
+ if found is not None:
531
+ return found
507
532
  return None
508
533
 
509
534
 
File without changes
File without changes
File without changes