Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobr committed Nov 16, 2024
1 parent 5c4dc2a commit 2d2480f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 32 deletions.
5 changes: 4 additions & 1 deletion interface/CLI/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def FilenameStep(name: str) -> str:
skuId, skuSelected = SkuStep(screenId=self.config["screenId"])
self.config["skuId"] = skuId

self.conf.Save(FilenameStep(name=f"{self.info.Project()['name']} ({skuSelected})"), self.config)
self.conf.Save(
FilenameStep(name=f"{self.info.Project()['name']} ({skuSelected})"),
self.config,
)
logger.info("【商品配置初始化】配置已保存!")
return self.config
6 changes: 5 additions & 1 deletion interface/CLI/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ def FilenameStep() -> str:
"""
文件名
"""
default = re.sub(r'[\\/*?:"<>|]', "_", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
default = re.sub(
r'[\\/*?:"<>|]',
"_",
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
)
filename = self.data.Inquire(
type="Text",
message="保存的设置文件名称",
Expand Down
6 changes: 5 additions & 1 deletion interface/CLI/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,9 @@ def FilenameStep(name: str) -> str:
self.config["deliver"] = DeliverStep()
self.config["phone"] = PhoneStep()
self.config["userinfo"] = self.info.Userinfo()
self.conf.Save(FilenameStep(name=self.config["buyer"][0]["name"]), self.config, encrypt=self.isEncrypt)
self.conf.Save(
FilenameStep(name=self.config["buyer"][0]["name"]),
self.config,
encrypt=self.isEncrypt,
)
return self.config
14 changes: 0 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ pygraphviz = "^1.13"
[tool.ruff]
line-length = 190

[tool.ruff.lint]
select = ["B", "C4", "C9", "E", "F", "I", "PL", "S", "SIM", "U", "W", "YTT"]
ignore = ["B006", "S311", "S501"]

[tool.ruff.lint.mccabe]
max-complexity = 20

[tool.ruff.lint.pylint]
max-args = 10
max-statements = 72
max-returns = 7
max-branches = 13
allow-magic-value-types = ["int","str"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
16 changes: 9 additions & 7 deletions util/Bilibili/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ def QueryPrice(self) -> None:
url = f"https://show.bilibili.com/api/ticket/project/getV2?version=134&id={self.projectId}&project_id={self.projectId}&requestSource={self.scene}"
res = self.net.Response(method="get", url=url)
code = res["errno"]
msg = res["msg"]


match code:
# 成功
case 0:
Expand All @@ -297,16 +296,15 @@ def QueryPrice(self) -> None:

# 没保存Screen/Sku位置
else:
for i, screen in enumerate(data["screen_list"]):
for _i, screen in enumerate(data["screen_list"]):
if screen["id"] == self.screenId:

self.deliverFee = max(screen["express_fee"], 0)

for j, sku in enumerate(screen["ticket_list"]):
for _j, sku in enumerate(screen["ticket_list"]):
if sku["id"] == self.skuId:

self.cost = sku["price"]
break

break
case _:
self.cost = 0
Expand Down Expand Up @@ -374,7 +372,11 @@ def CreateOrder(self) -> tuple:
# 未预填收货联系人信息
case 209001:
self.ContactNeed = True
tmp = self.net.Response(method="post", url="https://show.bilibili.com/api/ticket/buyer/saveContactInfo", params={"username": self.userinfo["username"], "tel": self.phone})
tmp = self.net.Response(
method="post",
url="https://show.bilibili.com/api/ticket/buyer/saveContactInfo",
params={"username": self.userinfo["username"], "tel": self.phone},
)
if tmp["errno"] == 0:
logger.info("【创建订单】已自动设置收货联系人信息")

Expand Down
6 changes: 5 additions & 1 deletion util/Notice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ def Ding(self, token: str) -> None:
钉钉
"""
url = f"https://oapi.dingtalk.com/robot/send?access_token={token}"
data = {"msgtype": "text", "text": {"content": self.message}, "at": {"isAtAll": False}}
data = {
"msgtype": "text",
"text": {"content": self.message},
"at": {"isAtAll": False},
}
self.net.Response(method="post", url=url, params=data)

@logger.catch
Expand Down
24 changes: 20 additions & 4 deletions util/Request/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,33 @@ def Response(self, method: str, url: str, params: dict = {}, isJson: bool = True

try:
if isJson:
dist = methods[method](url=url, **({"params": params} if method == "get" else {"data": params}))
dist = methods[method](
url=url,
**({"params": params} if method == "get" else {"data": params}),
)
if dist.status_code == 200:
return dist.json()
else:
return {"code": 114514, "errno": 114514, "msg": f"请求错误: {dist.status_code}", "message": f"请求错误: {dist.status_code}"}
return {
"code": 114514,
"errno": 114514,
"msg": f"请求错误: {dist.status_code}",
"message": f"请求错误: {dist.status_code}",
}
else:
methods[method](url=url, **({"params": params} if method == "get" else {"data": params}))
methods[method](
url=url,
**({"params": params} if method == "get" else {"data": params}),
)
return {}

except (httpx.RequestError, httpx.HTTPStatusError, httpx.StreamError) as e:
return {"code": 114514, "errno": 114514, "msg": f"请求错误: {e}", "message": f"请求错误: {e}"}
return {
"code": 114514,
"errno": 114514,
"msg": f"请求错误: {e}",
"message": f"请求错误: {e}",
}

@logger.catch
def GetCookie(self) -> dict:
Expand Down
5 changes: 2 additions & 3 deletions util/Task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def WaitAvailableAction(self) -> None:
if countdown > 0:
logger.warning("【等待开票】请确保本机时间是北京时间, 服务器用户尤其要注意!")
self.countdownOver = False

while countdown > 0:
countdown = start_time - int(time())

Expand Down Expand Up @@ -283,7 +283,7 @@ def WaitAvailableAction(self) -> None:
elif countdown < 1:
logger.info("【等待开票】即将开票!")
sleep(countdown)

# 预处理
if countdown == 30:
self.api.QueryPrice()
Expand Down Expand Up @@ -337,7 +337,6 @@ def QueryTokenAction(self) -> None:
self.queryCache = True
logger.info("【获取Token】已缓存商品信息")


@logger.catch
def RiskProcessAction(self) -> None:
"""
Expand Down

0 comments on commit 2d2480f

Please sign in to comment.