MeUtils 2024.12.12.18.26.47__py3-none-any.whl → 2024.12.12.19.7.5__py3-none-any.whl

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.1
2
2
  Name: MeUtils
3
- Version: 2024.12.12.18.26.47
3
+ Version: 2024.12.12.19.7.5
4
4
  Summary: description
5
5
  Home-page: https://github.com/yuanjie-ai/MeUtils
6
6
  Author: yuanjie
@@ -62,42 +62,42 @@ Requires-Dist: sse-starlette ; extra == 'ai'
62
62
  Requires-Dist: openai ; extra == 'ai'
63
63
  Requires-Dist: langchain ; extra == 'ai'
64
64
  Provides-Extra: all
65
- Requires-Dist: pretty-errors ; extra == 'all'
66
- Requires-Dist: gunicorn ; extra == 'all'
67
65
  Requires-Dist: pymongo ; extra == 'all'
68
- Requires-Dist: pymysql ; extra == 'all'
66
+ Requires-Dist: seaborn ; extra == 'all'
67
+ Requires-Dist: gunicorn ; extra == 'all'
68
+ Requires-Dist: polars ; extra == 'all'
69
+ Requires-Dist: sse-starlette ; extra == 'all'
70
+ Requires-Dist: schedule ; extra == 'all'
71
+ Requires-Dist: fastapi ; extra == 'all'
69
72
  Requires-Dist: geopy ; extra == 'all'
70
- Requires-Dist: iteration-utilities ; extra == 'all'
71
- Requires-Dist: openai ; extra == 'all'
72
- Requires-Dist: pyarrow ; extra == 'all'
73
- Requires-Dist: redis-py-cluster ; extra == 'all'
73
+ Requires-Dist: simplejson ; extra == 'all'
74
+ Requires-Dist: jieba ; extra == 'all'
75
+ Requires-Dist: pretty-errors ; extra == 'all'
76
+ Requires-Dist: uvicorn ; extra == 'all'
77
+ Requires-Dist: dataframe-image ; extra == 'all'
74
78
  Requires-Dist: jinja2 ; extra == 'all'
75
- Requires-Dist: pandas-summary ; extra == 'all'
76
79
  Requires-Dist: fastapi[all] ; extra == 'all'
77
- Requires-Dist: schedule ; extra == 'all'
78
- Requires-Dist: jmespath ; extra == 'all'
79
- Requires-Dist: seaborn ; extra == 'all'
80
- Requires-Dist: pymupd ; extra == 'all'
80
+ Requires-Dist: reportlab ; extra == 'all'
81
+ Requires-Dist: iteration-utilities ; extra == 'all'
82
+ Requires-Dist: redis-py-cluster ; extra == 'all'
83
+ Requires-Dist: faiss-cpu ; extra == 'all'
81
84
  Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
85
+ Requires-Dist: pandas-summary ; extra == 'all'
86
+ Requires-Dist: filetype ; extra == 'all'
87
+ Requires-Dist: cachetools ; extra == 'all'
82
88
  Requires-Dist: missingno ; extra == 'all'
83
- Requires-Dist: reportlab ; extra == 'all'
84
- Requires-Dist: sse-starlette ; extra == 'all'
85
- Requires-Dist: polars ; extra == 'all'
86
89
  Requires-Dist: langchain ; extra == 'all'
87
- Requires-Dist: asyncmy ; extra == 'all'
88
- Requires-Dist: simplejson ; extra == 'all'
89
- Requires-Dist: jieba ; extra == 'all'
90
- Requires-Dist: cachetools ; extra == 'all'
91
- Requires-Dist: faiss-cpu ; extra == 'all'
92
- Requires-Dist: pymilvus ; extra == 'all'
90
+ Requires-Dist: pymupd ; extra == 'all'
91
+ Requires-Dist: pyarrow ; extra == 'all'
93
92
  Requires-Dist: thriftpy2 ; extra == 'all'
94
- Requires-Dist: streamlit ; extra == 'all'
95
- Requires-Dist: uvicorn ; extra == 'all'
96
- Requires-Dist: sqlalchemy ; extra == 'all'
97
- Requires-Dist: fastapi ; extra == 'all'
98
- Requires-Dist: dataframe-image ; extra == 'all'
93
+ Requires-Dist: asyncmy ; extra == 'all'
99
94
  Requires-Dist: thefuck ; extra == 'all'
100
- Requires-Dist: filetype ; extra == 'all'
95
+ Requires-Dist: openai ; extra == 'all'
96
+ Requires-Dist: pymysql ; extra == 'all'
97
+ Requires-Dist: sqlalchemy ; extra == 'all'
98
+ Requires-Dist: jmespath ; extra == 'all'
99
+ Requires-Dist: streamlit ; extra == 'all'
100
+ Requires-Dist: pymilvus ; extra == 'all'
101
101
  Provides-Extra: ann
102
102
  Requires-Dist: pymilvus ; extra == 'ann'
103
103
  Requires-Dist: faiss-cpu ; extra == 'ann'
@@ -138,6 +138,7 @@ examples/cache_demo/__init__.py,sha256=zYdsVkzlPyaHOyG9HpW_AMriiEH_Pi8AmLUOS7Jbg
138
138
  examples/cache_demo/acacge.py,sha256=rlwMWUO4tWi9Y-gXnFUsRn__N_AaPP0icDlwDAYcf1Y,577
139
139
  examples/cache_demo/demo.py,sha256=iGuQTfV23eqtGIB8QqfQYa7qRNGPxqkUNAcws-fsh60,2528
140
140
  examples/cache_demo/test.py,sha256=gWY_oMf76RSqXdTHGOCcd-7cObkw8X1hovSVPHeyjkk,427
141
+ examples/cache_demo/x.py,sha256=AC51p_wCrWJYa56t7Cx-G2pUTJi7XCvW6VlnXM8fy7k,489
141
142
  examples/caches/__init__.py,sha256=vUpPT-UpH1mFDO2gv5mI7hACcBJYMiIgmb2r4Pr2yUo,271
142
143
  examples/celery_demo/__init__.py,sha256=d3jEYE9LZjFyMly5Djp5vVMlDcmWL5IE6vQoK-tVgK0,271
143
144
  examples/celery_demo/producer.py,sha256=py3Tjcb140zc5mzOGbxf2QIV6ZsXLPX1gjOnHXGysvk,342
@@ -449,8 +450,8 @@ meutils/async_utils/asyncer_.py,sha256=S1Sp5WZx_uKM7kJyRVYU8QhmbjOh61JmfN2IN_PJN
449
450
  meutils/async_utils/background.py,sha256=dl6UaMIFBZDB1uxSZzGFJdSnpt3Xo0flK7gwsokVy78,1464
450
451
  meutils/async_utils/common.py,sha256=WIQ7CVaZiaUeFA3IInM_4uaehJQiTdr_g3Q_8_yQrgc,4899
451
452
  meutils/async_utils/test.py,sha256=lkZdgSzzgVg8hYVcaBNEJ3KBvFTEfjbXZVvtknQZsRQ,1155
452
- meutils/cache/__init__.py,sha256=7ke7BKRUkp1raYrsgOIojHHdeHYNstw9APIdBNDNRzc,2129
453
- meutils/cache/hcache.py,sha256=AgiYUjKO8cfm6uuxQ2nWeaRmf9jkv2AIMvkbMvh_nkU,1139
453
+ meutils/cache/__init__.py,sha256=2JSElkhHh0vhUCvpBhTEsglw7WdkYj2HsAQutbqiBUM,242
454
+ meutils/cache/redis_cache.py,sha256=AgiYUjKO8cfm6uuxQ2nWeaRmf9jkv2AIMvkbMvh_nkU,1139
454
455
  meutils/clis/__init__.py,sha256=2Fhn43X8kFP6FpAnnAMiPcdnjUwQaukiIr2uGB6mGAY,279
455
456
  meutils/clis/browser.py,sha256=eMQ-7LlFJN_Sqs0DMnCVulfdUv9aGhHm5drCViQm4CY,4511
456
457
  meutils/clis/check_api.py,sha256=WKsLupPlM0PI6SzfVOwoqoYNEmOj_Jb-bsRDYA_SXsE,2367
@@ -471,7 +472,7 @@ meutils/cmds/subprocess_demo.py,sha256=oTeTIx8k6XwtOT6hZpmy9XNcRErzilqWcdoxcrVcH
471
472
  meutils/comp_utils/__init__.py,sha256=Q4BW-gHnOUiSSpupHsprsOAPp4kuBLcH60sL1RfS3PQ,361
472
473
  meutils/comp_utils/reverse_metric.py,sha256=qwcGgiHhaupIJER4gO0HQhhO07FDLFv-vfFhg6K6Q4s,1705
473
474
  meutils/config_utils/__init__.py,sha256=GhgsStfGJDC8F_YgC6X5Jnj9HkgXJXxeYiJWTAkWKTo,271
474
- meutils/config_utils/manager.py,sha256=ZnvD_09tk2i2idA5vEXn9Jf4KWQkjYYlFN3LvXY0_Mk,3082
475
+ meutils/config_utils/manager.py,sha256=li3NgSfbO3-QTo5NPkMD3Hl5dnEr5q_J5F2WgmyhRqk,3106
475
476
  meutils/config_utils/nacosx.py,sha256=5x6WlCvjExaA7R9moBxc3DV9l1oFTtNazC6pObaYjMg,1110
476
477
  meutils/config_utils/lark_utils/__init__.py,sha256=Gf-5Y8uZiqY9jdbfiIboL92MQjOTOo0ZZ245PGxCbaY,297
477
478
  meutils/config_utils/lark_utils/common.py,sha256=WB1VKB3vdYyzqWosp5T-7uBIupNXl1L7SM3Lf5GRaOU,14274
@@ -479,7 +480,7 @@ meutils/config_utils/lark_utils/demo.py,sha256=3g0Fs7oLaeW75T60gYWMLgyNg1OnfOjfH
479
480
  meutils/config_utils/lark_utils/x.py,sha256=MlMQGhehP9xMEgetxVCX68XFaosfKoW1JA5cZ3JqN2w,1857
480
481
  meutils/crawlers/__init__.py,sha256=TBU4xA-IOsHV-0yIkW7YXxn_QT7TT8NncqxO7IykEfs,271
481
482
  meutils/data/SimHei.ttf,sha256=-XEnekS5yHP_URkT4XBI2w22ylV-KxudhkeIYFbrILA,10062565
482
- meutils/data/VERSION,sha256=42IqFYRQ3sEMgJnjcb-z4aClOyDXkUd8LqXnEfq0R7s,19
483
+ meutils/data/VERSION,sha256=ySgDen9uEnZP5as6GwTlN8BgeSo69B0ACD4GA6kpaiM,19
483
484
  meutils/data/_FLAG,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
484
485
  meutils/data/_SUCCESS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
485
486
  meutils/data/__init__.py,sha256=Hfwkkxs4zHqKhxht0YrhS566a9P5axtmgNvM5wF8ceQ,243
@@ -816,9 +817,9 @@ meutils/tools/seize.py,sha256=nOKAS63w-Lbi48I0m2MPhdsokUTwxco0laPxYVmW4Mw,1064
816
817
  meutils/tools/service_monitor.py,sha256=ibsLtBN2g2DL7ZnLJ8vhiZOiOcqTAyx711djDdBK-3M,1255
817
818
  meutils/tools/sys_monitor.py,sha256=6MoyzrItqDUOSjfHcMJmMofQkEPTW36CT_aKui0rg84,429
818
819
  meutils/tools/token_monitor.py,sha256=Np-YK-R4P4IPAXyZvMxwvXI4sFmNJQAQK1lSegNaYpA,997
819
- MeUtils-2024.12.12.18.26.47.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
820
- MeUtils-2024.12.12.18.26.47.dist-info/METADATA,sha256=47mIhTXw8ebO5fkvgSQju4Gqdllvf_z2P5Ctda6yRfM,6171
821
- MeUtils-2024.12.12.18.26.47.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
822
- MeUtils-2024.12.12.18.26.47.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
823
- MeUtils-2024.12.12.18.26.47.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
824
- MeUtils-2024.12.12.18.26.47.dist-info/RECORD,,
820
+ MeUtils-2024.12.12.19.7.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
821
+ MeUtils-2024.12.12.19.7.5.dist-info/METADATA,sha256=aJTc0trtJu222lHLpsSDBKaetlb6mWz3Q8x0jLnDgog,6169
822
+ MeUtils-2024.12.12.19.7.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
823
+ MeUtils-2024.12.12.19.7.5.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
824
+ MeUtils-2024.12.12.19.7.5.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
825
+ MeUtils-2024.12.12.19.7.5.dist-info/RECORD,,
@@ -0,0 +1,27 @@
1
+
2
+ #!/usr/bin/env python
3
+ # -*- coding: utf-8 -*-
4
+ # @Project : AI. @by PyCharm
5
+ # @File : x
6
+ # @Time : 2024/12/12 19:05
7
+ # @Author : betterme
8
+ # @WeChat : meutils
9
+ # @Software : PyCharm
10
+ # @Description :
11
+
12
+ from meutils.pipe import *
13
+ from meutils.cache.redis_cache import cache
14
+
15
+
16
+
17
+
18
+ if __name__ == '__main__':
19
+ class Request(BaseModel):
20
+ a: str = "a"
21
+
22
+ class Config:
23
+ frozen = True
24
+
25
+
26
+ arun(func(1))
27
+ # arun(func_ignore(1, 11))
meutils/cache/__init__.py CHANGED
@@ -6,77 +6,4 @@
6
6
  # @Author : betterme
7
7
  # @WeChat : meutils
8
8
  # @Software : PyCharm
9
- # @Description :
10
-
11
- from meutils.pipe import *
12
-
13
- import time
14
- from functools import lru_cache, wraps
15
-
16
-
17
- def ttl_fn(ttl: int = 60):
18
- return time.time() // ttl # 缓存时间
19
-
20
-
21
- def lru_cache_with_ttls(maxsize=128, typed: bool = False, ttl: Optional[int] = None):
22
- cache = lru_cache(maxsize, typed)
23
-
24
- @wrapt.decorator # 主逻辑
25
- def inner(wrapped, instance, args, kwargs):
26
-
27
- @cache
28
- def _wrapped(_ttl):
29
- return wrapped(*args, **kwargs)
30
-
31
- return _wrapped(ttl_fn(ttl))
32
-
33
- return inner
34
-
35
-
36
- def lru_cache_with_ttl(maxsize=128, typed: bool = False, ttl: Optional[int] = None):
37
- def decorator(func):
38
- # 使用lru_cache作为基础缓存机制
39
- lru = lru_cache(maxsize=maxsize)(func)
40
- lru_cache_data = {}
41
-
42
- @wraps(func)
43
- def wrapper(*args, **kwargs):
44
- # 生成缓存键
45
- key = args + tuple(kwargs.items())
46
-
47
- # 检查是否在缓存中以及是否过期
48
- if key in lru_cache_data:
49
- entry, timestamp = lru_cache_data[key]
50
- if time.time() - timestamp < ttl:
51
- return entry
52
- else:
53
- # 如果过期,删除缓存
54
- del lru_cache_data[key]
55
-
56
- # 调用原始函数并缓存结果
57
- result = lru(*args, **kwargs)
58
- lru_cache_data[key] = (result, time.time())
59
- return result
60
-
61
- # 使用lru_cache的缓存信息函数
62
- wrapper.cache_info = lru.cache_info
63
- wrapper.cache_clear = lru.cache_clear
64
- return wrapper
65
-
66
- return decorator
67
-
68
-
69
- # 示例使用
70
-
71
-
72
- if __name__ == '__main__':
73
- @lru_cache_with_ttls(maxsize=128, ttl=3)
74
- def expensive_function(n):
75
- logger.debug("不走缓存")
76
- return n
77
-
78
-
79
- print(expensive_function(11))
80
- print(expensive_function(11))
81
- time.sleep(5)
82
- print(expensive_function(11))
9
+ # @Description :
@@ -12,7 +12,7 @@ import nacos
12
12
  from meutils.pipe import *
13
13
 
14
14
 
15
- class Manager:
15
+ class Manager(object):
16
16
  _instance = None
17
17
  _config: str = ""
18
18
 
@@ -67,41 +67,43 @@ class Manager:
67
67
 
68
68
  @property
69
69
  def json(self) -> Dict[str, Any]:
70
+ text = self._config
70
71
  try:
71
- return json.loads(self.text)
72
+ return json.loads(text)
72
73
  except json.decoder.JSONDecodeError as e:
73
74
  logger.warning(f"标准json 配置加载失败: {e}")
74
75
 
75
76
  logger.debug(f"尝试用json_repair解析")
76
- return json_repair.repair_json(self.text, return_objects=True)
77
+ return json_repair.repair_json(text, return_objects=True)
77
78
 
78
79
  @property
79
80
  def yaml(self) -> Dict[str, Any]:
81
+ text = self._config
82
+
80
83
  try:
81
- return yaml.safe_load(self.text)
84
+ return yaml.safe_load(text)
82
85
  except Exception as e:
83
86
  logger.error(f"yaml 配置加载失败: {e}")
84
87
 
85
88
  @property
86
89
  def xml(self):
87
- return self.text
90
+ return self._config
88
91
 
89
92
  @property
90
93
  def html(self):
91
- return self.text
94
+ return self._config
92
95
 
93
96
  @property
94
97
  def properties(self):
95
- return self.text
98
+ return self._config
96
99
 
97
100
 
98
101
  if __name__ == '__main__':
99
102
  # 初始化配置管理器
100
103
  namespace = 'test'
101
104
  data_id = "testdata"
102
- group = "DEFAULT_GROUP"
103
105
 
104
- manager = Manager(namespace, data_id, group)
106
+ manager = Manager(namespace, data_id)
105
107
  # manager_ = Manager(namespace, data_id, group)
106
108
 
107
109
  print(manager.text)
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2024.12.12.18.26.47
1
+ 2024.12.12.19.07.05
File without changes