litequant 3.0.1__tar.gz → 3.0.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.
@@ -29,6 +29,7 @@ import io
29
29
  import json
30
30
  import logging
31
31
  import os
32
+ import fnmatch
32
33
  import time
33
34
  import threading
34
35
  from typing import Any, Dict, List, Optional, Literal
@@ -75,6 +76,7 @@ class DataTicket:
75
76
  expires_at: datetime
76
77
  datasets: List[str]
77
78
  key_patterns: List[str]
79
+ category_patterns: Optional[List[str]] = None
78
80
  redis_username: Optional[str] = None
79
81
  redis_ssl: bool = False
80
82
 
@@ -312,7 +314,7 @@ class LiteQuantClient:
312
314
  try:
313
315
  data = self._api_post_json(
314
316
  "/api/v1/data/ticket/",
315
- {"client_version": "3.0.1"},
317
+ {"client_version": "3.0.2"},
316
318
  timeout=30,
317
319
  )
318
320
 
@@ -330,6 +332,7 @@ class LiteQuantClient:
330
332
  expires_at=datetime.now() + timedelta(seconds=data["expires_in"]),
331
333
  datasets=scope.get("datasets", []),
332
334
  key_patterns=scope.get("key_patterns", []),
335
+ category_patterns=scope.get("category_patterns", []),
333
336
  redis_username=redis_username,
334
337
  redis_ssl=redis_ssl,
335
338
  )
@@ -650,13 +653,20 @@ class LiteQuantClient:
650
653
  all_categories = [str(x) for x in categories]
651
654
 
652
655
  # 过滤:只保留授权数据集的类别
653
- if self._ticket and self._ticket.datasets:
656
+ if self._ticket and self._ticket.category_patterns:
657
+ authorized_patterns = [str(x) for x in self._ticket.category_patterns]
658
+ filtered_categories = [
659
+ cat for cat in all_categories
660
+ if any(fnmatch.fnmatchcase(cat, pattern) for pattern in authorized_patterns)
661
+ ]
662
+ self.logger.debug("??????: %s -> %s", len(all_categories), len(filtered_categories))
663
+ elif self._ticket and self._ticket.datasets:
654
664
  authorized_datasets = set(self._ticket.datasets)
655
665
  filtered_categories = [
656
666
  cat for cat in all_categories
657
667
  if any(cat.startswith(f"{ds}#") for ds in authorized_datasets)
658
668
  ]
659
- self.logger.debug("过滤类别: %s -> %s", len(all_categories), len(filtered_categories))
669
+ self.logger.debug("??????: %s -> %s", len(all_categories), len(filtered_categories))
660
670
  else:
661
671
  filtered_categories = all_categories
662
672
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: litequant
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: LiteQuant Python client SDK
5
5
  Author: LiteQuant Team
6
6
  License: MIT
@@ -26,7 +26,7 @@ from .exceptions import (
26
26
  APIError,
27
27
  )
28
28
 
29
- __version__ = "3.0.1"
29
+ __version__ = "3.0.2"
30
30
  __all__ = [
31
31
  # Client
32
32
  "LiteQuantClient",
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "litequant"
7
- version = "3.0.1"
7
+ version = "3.0.2"
8
8
  description = "LiteQuant Python client SDK"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes