alkaid_release_platform/core/defines.py
ekko.bao 0a0f6a6054 初次创建仓库提交代码
1. 已经构建好了架子了。
2. 添加了示例的插件
2025-04-21 06:37:06 +00:00

86 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from enum import Enum
import json
class ReleasePhase(str, Enum):
ENV = "PhaseEnv"
CONFIG = "PhaseConfig"
BUILD = "PhaseBuild"
CHECK = "PhaseCheck"
PACKAGE = "PhasePackage"
VERIFY = "PhaseVerify"
class ProcessStep(str, Enum):
"""
ReleaseFlow中每个阶段的几个执行步骤顺序执行
"""
PRE = "Pre"
PROCESS = "Process"
POST = "Post"
class ReleaseErr(Exception):
"""Release tool专用异常基类包含错误信息和上下文"""
def __init__(self, message: str, ctx: dict = None):
self.message = message
self.ctx = ctx or {}
super().__init__(message)
def __str__(self):
return f"{self.message} (context: {self.ctx})" if self.ctx else self.message
class Dict(dict):
"""
一个字典支持点号访问从xxx[xxx][xxx] 的方式转化为 xxx.xxx.xxx 的形式访问字典中的值
如果key不存在返回一个空的字典
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# 将字典中的所有值递归转换为 Dict
for key, value in self.items():
if isinstance(value, dict):
self[key] = Dict(value)
@classmethod
def from_dict(cls, data: dict) -> "Dict":
"""
从普通字典创建一个 Dict 对象
:param data: 要转换的字典
:return: Dict 对象
"""
return cls(data)
def __getattr__(self, key):
if key in self:
value = self[key]
# 如果值是字典,递归转换为 Dict
if isinstance(value, dict):
return Dict(value)
return value
# 如果key不存在返回None
# return Dict()
raise AttributeError(f"In object not found '{key}'")
def __setattr__(self, key, value):
self[key] = value
def __str__(self):
string = json.dumps(self, indent=4)
return string
def __repr__(self):
return self.__str__()
class List(list):
def __str__(self):
return json.dumps(self, indent=4)
def __repr__(self):
return self.__str__()