pymecli 0.4.5__tar.gz → 0.4.6__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.
- {pymecli-0.4.5 → pymecli-0.4.6}/PKG-INFO +2 -1
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/fast.py +18 -9
- pymecli-0.4.6/core/config.py +40 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/core/redis_client.py +1 -1
- {pymecli-0.4.5 → pymecli-0.4.6}/pyproject.toml +2 -1
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/pyredis.py +2 -2
- pymecli-0.4.5/core/config.py +0 -23
- {pymecli-0.4.5 → pymecli-0.4.6}/.gitignore +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/README.md +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/api/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/api/v1/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/api/v1/clash.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/api/v1/redis.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/baidu.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/bitget.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/dst.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/example.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/gate.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/redis_csv.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/cli/util.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/core/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/core/clash.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/crypto/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/crypto/bitget.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/crypto/gate.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/data/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/data/dou_dict.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/data/dou_list.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/data/main.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/data/template.yaml +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/models/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/models/douzero_model.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/models/ocr_model.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/models/response.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/__init__.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/elapsed.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/helper.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/logger.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/mysql.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/path.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/pd.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/sleep.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/text.py +0 -0
- {pymecli-0.4.5 → pymecli-0.4.6}/utils/toml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pymecli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: My CLI
|
|
5
5
|
Project-URL: Homepage, https://pypi.org/project/pymecli
|
|
6
6
|
Project-URL: Repository, https://github.com/meme2046/pymecli
|
|
@@ -16,6 +16,7 @@ Requires-Dist: dotenv>=0.9.9
|
|
|
16
16
|
Requires-Dist: fastapi>=0.127.0
|
|
17
17
|
Requires-Dist: numpy<2.0.0
|
|
18
18
|
Requires-Dist: pandas>=2.3.3
|
|
19
|
+
Requires-Dist: pydantic-settings>=2.14.2
|
|
19
20
|
Requires-Dist: pymysql>=1.1.2
|
|
20
21
|
Requires-Dist: pytz>=2025.2
|
|
21
22
|
Requires-Dist: pyyaml>=6.0.3
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import os
|
|
2
1
|
from contextlib import asynccontextmanager
|
|
3
2
|
|
|
4
3
|
import redis.asyncio as redis
|
|
@@ -20,10 +19,10 @@ from models.response import SuccessResponse
|
|
|
20
19
|
async def lifespan(app: FastAPI):
|
|
21
20
|
"""管理应用生命周期的上下文管理器"""
|
|
22
21
|
redis_pool = redis.ConnectionPool(
|
|
23
|
-
host=
|
|
24
|
-
port=
|
|
25
|
-
db=
|
|
26
|
-
password=
|
|
22
|
+
host=settings.REDIS_HOST,
|
|
23
|
+
port=settings.REDIS_PORT,
|
|
24
|
+
db=settings.REDIS_DB,
|
|
25
|
+
password=settings.REDIS_PASSWORD,
|
|
27
26
|
max_connections=20, # 根据需要调整最大连接数
|
|
28
27
|
decode_responses=True,
|
|
29
28
|
)
|
|
@@ -41,9 +40,9 @@ typer_app = typer.Typer()
|
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
app = FastAPI(
|
|
44
|
-
title=settings.
|
|
45
|
-
description=settings.
|
|
46
|
-
version=settings.
|
|
43
|
+
title=settings.PROJECT_NAME,
|
|
44
|
+
description=settings.PROJECT_DESCRIPTION,
|
|
45
|
+
version=settings.PROJECT_VERSION,
|
|
47
46
|
lifespan=lifespan,
|
|
48
47
|
)
|
|
49
48
|
|
|
@@ -104,7 +103,7 @@ async def general_exception_handler(request, exc):
|
|
|
104
103
|
|
|
105
104
|
@app.get("/")
|
|
106
105
|
async def root():
|
|
107
|
-
return SuccessResponse(data=f"Welcome to {settings.
|
|
106
|
+
return SuccessResponse(data=f"Welcome to {settings.PROJECT_DESCRIPTION}")
|
|
108
107
|
|
|
109
108
|
|
|
110
109
|
@app.get("/ping", response_class=PlainTextResponse)
|
|
@@ -153,7 +152,17 @@ def run_app(
|
|
|
153
152
|
"-p",
|
|
154
153
|
help="服务器代理,传入则通过代理转换Clash订阅,比如:socks5://127.0.0.1:7897",
|
|
155
154
|
),
|
|
155
|
+
redis_host: str = typer.Option(
|
|
156
|
+
None,
|
|
157
|
+
"--redis-host",
|
|
158
|
+
"-r",
|
|
159
|
+
help="redis host",
|
|
160
|
+
),
|
|
156
161
|
):
|
|
162
|
+
settings.reload()
|
|
163
|
+
if redis_host is not None:
|
|
164
|
+
settings.REDIS_HOST = redis_host
|
|
165
|
+
|
|
157
166
|
clash_config = ClashConfig(rule, my_rule, proxy)
|
|
158
167
|
init_generator(clash_config)
|
|
159
168
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import importlib.metadata
|
|
2
|
+
|
|
3
|
+
from pydantic_settings import BaseSettings
|
|
4
|
+
|
|
5
|
+
metadata = importlib.metadata.metadata("pymecli")
|
|
6
|
+
# module_dir = Path(__file__).resolve().parent.parent
|
|
7
|
+
|
|
8
|
+
# project = read_toml(str(module_dir / "./pyproject.toml"))["project"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Settings(BaseSettings):
|
|
12
|
+
# API配置
|
|
13
|
+
API_V1_STR: str = "/api/v1"
|
|
14
|
+
PROJECT_NAME: str = metadata["Name"]
|
|
15
|
+
|
|
16
|
+
REDIS_HOST: str = "192.168.124.7"
|
|
17
|
+
REDIS_PORT: int = 6379
|
|
18
|
+
REDIS_DB: int = 0
|
|
19
|
+
REDIS_PASSWORD: str = ""
|
|
20
|
+
|
|
21
|
+
PROJECT_DESCRIPTION: str = (
|
|
22
|
+
f"{metadata['Summary']}, FastAPI提供: clash订阅转换、baidu.gushitong api"
|
|
23
|
+
)
|
|
24
|
+
PROJECT_VERSION: str = metadata["Version"]
|
|
25
|
+
|
|
26
|
+
class Config:
|
|
27
|
+
env_prefix = "PYME_CLI_" # 添加环境变量前缀
|
|
28
|
+
case_sensitive = True
|
|
29
|
+
|
|
30
|
+
def reload(self):
|
|
31
|
+
new_settings = Settings()
|
|
32
|
+
for field in Settings.model_fields:
|
|
33
|
+
setattr(self, field, getattr(new_settings, field))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
settings = Settings()
|
|
37
|
+
|
|
38
|
+
print(f"project: {settings.PROJECT_NAME}")
|
|
39
|
+
print(f"version: {settings.PROJECT_VERSION}")
|
|
40
|
+
print(f"description: {settings.PROJECT_DESCRIPTION}")
|
|
@@ -8,7 +8,7 @@ import redis
|
|
|
8
8
|
class RedisClient:
|
|
9
9
|
def __init__(
|
|
10
10
|
self,
|
|
11
|
-
host=os.getenv("REDIS_HOST", "192.168.
|
|
11
|
+
host=os.getenv("REDIS_HOST", "192.168.124.7"),
|
|
12
12
|
port=int(os.getenv("REDIS_PORT", 6379)),
|
|
13
13
|
db=int(os.getenv("REDIS_DB", 0)),
|
|
14
14
|
password=os.getenv("REDIS_PASSWORD"),
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"typer>=0.20.1",
|
|
27
27
|
"uvicorn>=0.40.0",
|
|
28
28
|
"webdriver-manager>=4.0.2",
|
|
29
|
+
"pydantic-settings>=2.14.2",
|
|
29
30
|
]
|
|
30
31
|
description = "My CLI"
|
|
31
32
|
license = { text = "MIT" }
|
|
32
33
|
name = "pymecli"
|
|
33
34
|
readme = "README.md"
|
|
34
35
|
requires-python = ">=3.10"
|
|
35
|
-
version = "0.4.
|
|
36
|
+
version = "0.4.6"
|
|
36
37
|
|
|
37
38
|
[project.urls]
|
|
38
39
|
Homepage = "https://pypi.org/project/pymecli"
|
|
@@ -5,7 +5,7 @@ import redis.asyncio as redis
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def get_redis_client(
|
|
8
|
-
host=os.getenv("REDIS_HOST", "192.168.
|
|
8
|
+
host=os.getenv("REDIS_HOST", "192.168.124.7"),
|
|
9
9
|
port=int(os.getenv("REDIS_PORT", 6379)),
|
|
10
10
|
db=int(os.getenv("REDIS_DB", 0)),
|
|
11
11
|
password=os.getenv("REDIS_PASSWORD"),
|
|
@@ -21,7 +21,7 @@ def get_redis_client(
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def get_redis_client_sync(
|
|
24
|
-
host=os.getenv("REDIS_HOST", "192.168.
|
|
24
|
+
host=os.getenv("REDIS_HOST", "192.168.124.7"),
|
|
25
25
|
port=int(os.getenv("REDIS_PORT", 6379)),
|
|
26
26
|
db=int(os.getenv("REDIS_DB", 0)),
|
|
27
27
|
password=os.getenv("REDIS_PASSWORD"),
|
pymecli-0.4.5/core/config.py
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import importlib.metadata
|
|
2
|
-
|
|
3
|
-
metadata = importlib.metadata.metadata("pymecli")
|
|
4
|
-
# module_dir = Path(__file__).resolve().parent.parent
|
|
5
|
-
|
|
6
|
-
# project = read_toml(str(module_dir / "./pyproject.toml"))["project"]
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Settings:
|
|
10
|
-
# API配置
|
|
11
|
-
API_V1_STR: str = "/api/v1"
|
|
12
|
-
NAME: str = metadata["Name"]
|
|
13
|
-
DESCRIPTION: str = (
|
|
14
|
-
f"{metadata['Summary']}, FastAPI提供: clash订阅转换、baidu.gushitong api"
|
|
15
|
-
)
|
|
16
|
-
VERSION: str = metadata["Version"]
|
|
17
|
-
|
|
18
|
-
print(f"project: {NAME}")
|
|
19
|
-
print(f"version: {VERSION}")
|
|
20
|
-
print(f"description: {DESCRIPTION}")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
settings = Settings()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|