Compare commits
8 Commits
59dfd08c54
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ad17b905c4 | |||
| 4ba5bfdfee | |||
| 8121899d32 | |||
| a79ba69443 | |||
| 3fa432a2bb | |||
| d102ed124c | |||
| e07d604d12 | |||
| e56d78a757 |
@@ -1,3 +0,0 @@
|
||||
include LICENSE
|
||||
include README.md
|
||||
global-exclude *.meta
|
||||
@@ -10,7 +10,7 @@ class IModel(ABC):
|
||||
pass
|
||||
|
||||
|
||||
class IDataModel(ABC, IModel):
|
||||
class IDataModel(IModel):
|
||||
@abstractmethod
|
||||
def Save(self) -> str:
|
||||
pass
|
||||
@@ -131,15 +131,16 @@ class Architecture:
|
||||
if slot in cls._RegisteringRuntime:
|
||||
raise InvalidOperationError("Illegal duplicate registrations")
|
||||
cls._RegisteringRuntime[slot] = Architecture.Registering(slot, target, DependenceModel(Architecture.TypeQuery(dependence) for dependence in dependences), action)
|
||||
dependences = cls._RegisteringRuntime[slot].dependences
|
||||
cls._InternalRegisteringComplete()
|
||||
return cls._RegisteringRuntime[slot].dependences
|
||||
return dependences
|
||||
|
||||
@classmethod
|
||||
def Contains(cls, type_:type) -> bool:
|
||||
return type_ in cls._RegisteredObjects
|
||||
|
||||
@classmethod
|
||||
def Get(cls, type_:type) -> Any:
|
||||
def Get[T](cls, type_:Typen[T]) -> T:
|
||||
return cls._RegisteredObjects[type_]
|
||||
|
||||
@classmethod
|
||||
@@ -417,6 +417,22 @@ class PlatformIndicator:
|
||||
IsPlatformX64 : bool = True
|
||||
CompanyName : str = "DefaultCompany"
|
||||
ProductName : str = "DefaultProject"
|
||||
PrettyFace : str = r"""
|
||||
⣇⣿⠘⣿⣿⣿⡿⡿⣟⣟⢟⢟⢝⠵⡝⣿⡿⢂⣼⣿⣷⣌⠩⡫⡻⣝⠹⢿⣿⣷
|
||||
⡆⣿⣆⠱⣝⡵⣝⢅⠙⣿⢕⢕⢕⢕⢝⣥⢒⠅⣿⣿⣿⡿⣳⣌⠪⡪⣡⢑⢝⣇
|
||||
⡆⣿⣿⣦⠹⣳⣳⣕⢅⠈⢗⢕⢕⢕⢕⢕⢈⢆⠟⠋⠉⠁⠉⠉⠁⠈⣸⢐⢕⢽
|
||||
⡗⢰⣶⣶⣦⣝⢝⢕⢕⠅⡆⢕⢕⢕⢕⢕⣴⠏⣠⡶⠛⡉⡉⡛⢶⣦⡀⠐⣕⢕
|
||||
⡝⡄⢻⢟⣿⣿⣷⣕⣕⣅⣿⣔⣕⣵⣵⣿⣿⢠⣿⢠⣮⡈⣌⠨⠅⠹⣷⡀⢱⢕
|
||||
⡝⡵⠟⠈⠀⠀⠀⠀⠉⢿⣿⣿⣿⣿⣿⣿⣿⣼⣿⢈⡋⠴⢿⡟⣡⡇⣿⡇⢀⢕
|
||||
⡝⠁⣠⣾⠟⡉⡉⡉⠻⣦⣻⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣦⣥⣿⡇⡿⣰⢗⢄
|
||||
⠁⢰⣿⡏⣴⣌⠈⣌⠡⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⣉⣉⣁⣄⢖⢕⢕⢕
|
||||
⡀⢻⣿⡇⢙⠁⠴⢿⡟⣡⡆⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣵⣵⣿
|
||||
⡻⣄⣻⣿⣌⠘⢿⣷⣥⣿⠇⣿⣿⣿⣿⣿⣿⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣷⢄⠻⣿⣟⠿⠦⠍⠉⣡⣾⣿⣿⣿⣿⣿⣿⢸⣿⣦⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟
|
||||
⡕⡑⣑⣈⣻⢗⢟⢞⢝⣻⣿⣿⣿⣿⣿⣿⣿⠸⣿⠿⠃⣿⣿⣿⣿⣿⣿⡿⠁⣠
|
||||
⡝⡵⡈⢟⢕⢕⢕⢕⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⣀⣈⠙
|
||||
⡝⡵⡕⡀⠑⠳⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⡠⡲⡫⡪⡪⡣
|
||||
""".strip()
|
||||
|
||||
@staticmethod
|
||||
def GetFileSeparator(is_not_this_platform:bool = False) -> str:
|
||||
@@ -327,7 +327,7 @@ class ToolFile(BaseModel):
|
||||
except:
|
||||
pass
|
||||
with open(self.OriginFullPath, 'w', encoding='utf-8') as f:
|
||||
json.dump(json_data, f, indent=4)
|
||||
json.dump(json_data, f, indent=4, ensure_ascii=False)
|
||||
return self
|
||||
def SaveAsCsv(self, csv_data:"pd.DataFrame"):
|
||||
'''
|
||||
@@ -504,12 +504,11 @@ class ToolFile(BaseModel):
|
||||
return result
|
||||
def DirWalk(
|
||||
self,
|
||||
top,
|
||||
topdown: bool = True,
|
||||
onerror: Optional[Callable] = None,
|
||||
followlinks: bool = False
|
||||
) -> Iterator[tuple[dir_name_type, list[dir_name_type], list[file_name_type]]]:
|
||||
return os.walk(self.OriginFullPath, top=top, topdown=topdown, onerror=onerror, followlinks=followlinks)
|
||||
return os.walk(self.OriginFullPath, topdown=topdown, onerror=onerror, followlinks=followlinks)
|
||||
|
||||
|
||||
def bool(self):
|
||||
@@ -228,7 +228,7 @@ class GlobalConfig:
|
||||
return self
|
||||
|
||||
# 配置查找
|
||||
def FindItem(self, key: str, default: Any = None) -> Any:
|
||||
def FindItem[T](self, key: str, default: Optional[T] = None) -> Optional[T]:
|
||||
"""查找配置项,支持默认值"""
|
||||
if key in self._data_pair:
|
||||
return self._data_pair[key]
|
||||
@@ -264,6 +264,78 @@ class ToolURL(BaseModel):
|
||||
callback(None)
|
||||
return False
|
||||
|
||||
def PostJson(self, callback: Callable[[Optional[Any]], None],
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
headers: Optional[Dict[str, str]] = None) -> bool:
|
||||
"""
|
||||
同步JSON POST请求
|
||||
|
||||
Args:
|
||||
callback: 响应回调函数,成功时接收响应对象,失败时接收None
|
||||
json_data: JSON数据字典
|
||||
headers: 自定义请求头字典
|
||||
|
||||
Returns:
|
||||
是否请求成功
|
||||
"""
|
||||
if not self.IsValid:
|
||||
callback(None)
|
||||
return False
|
||||
|
||||
try:
|
||||
data = None
|
||||
if json_data:
|
||||
data = json.dumps(json_data).encode('utf-8')
|
||||
|
||||
req = urllib.request.Request(self.url, data=data, method='POST')
|
||||
|
||||
# 设置默认请求头
|
||||
req.add_header('Content-Type', 'application/json')
|
||||
|
||||
# 添加自定义请求头
|
||||
if headers:
|
||||
for key, value in headers.items():
|
||||
req.add_header(key, value)
|
||||
|
||||
with urllib.request.urlopen(req) as response:
|
||||
callback(response)
|
||||
return True
|
||||
except Exception as e:
|
||||
callback(None)
|
||||
return False
|
||||
|
||||
async def PostJsonAsync(self, callback: Callable[[Optional[Any]], None],
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
headers: Optional[Dict[str, str]] = None) -> bool:
|
||||
"""
|
||||
异步JSON POST请求
|
||||
|
||||
Args:
|
||||
callback: 响应回调函数,成功时接收响应对象,失败时接收None
|
||||
json_data: JSON数据字典
|
||||
headers: 自定义请求头字典
|
||||
|
||||
Returns:
|
||||
是否请求成功
|
||||
"""
|
||||
if not self.IsValid:
|
||||
callback(None)
|
||||
return False
|
||||
|
||||
try:
|
||||
# 准备请求头
|
||||
request_headers = {'Content-Type': 'application/json'}
|
||||
if headers:
|
||||
request_headers.update(headers)
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(self.url, json=json_data, headers=request_headers) as response:
|
||||
callback(response)
|
||||
return True
|
||||
except Exception as e:
|
||||
callback(None)
|
||||
return False
|
||||
|
||||
# 内容加载方法
|
||||
def LoadAsText(self) -> str:
|
||||
"""
|
||||
@@ -1,9 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
from time import sleep
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from Convention.Runtime.Config import *
|
||||
|
||||
PrintColorful(ConsoleFrontColor.RED, "Hello, World!")
|
||||
|
||||
27
setup.py
27
setup.py
@@ -1,27 +0,0 @@
|
||||
from setuptools import setup, find_packages
|
||||
import io
|
||||
|
||||
setup(
|
||||
name="Convention",
|
||||
version="0.1.0",
|
||||
author="LiuBai",
|
||||
description="A python version code repository for implementing the agreements and implementations in the Convention-Template.",
|
||||
long_description=io.open("README.md", encoding="utf-8").read(),
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/NINEMINEsigma/Convention-Python",
|
||||
packages=find_packages(),
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
python_requires=">=3.12",
|
||||
install_requires=[
|
||||
"colorama",
|
||||
"pydantic",
|
||||
"python-docx",
|
||||
"Pillow",
|
||||
"pydub"
|
||||
],
|
||||
exclude_package_data={"": ["*.meta"]},
|
||||
)
|
||||
Reference in New Issue
Block a user