This commit is contained in:
shenjack 2022-06-27 16:51:14 +08:00
parent 3b799ed98c
commit 3b9848fd20
40 changed files with 171 additions and 125 deletions

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
@ -12,19 +12,3 @@ gitee: @shenjackyuanjie
""" """
from Difficult_Rocket.api.Exp.main import Error from Difficult_Rocket.api.Exp.main import Error
from Difficult_Rocket.api.Exp.command import CommandError, CommandParseError, CommandQMarkPosError, \
CommandQMarkConflict, CommandQMarkMissing, CommandQMarkPreMissing, CommandQMarkSufMissing
from Difficult_Rocket.api.Exp.unsupport import NoMoreJson5, Nope418ImTeapot, ThinkError, BrainError, \
BrainTimeoutError, BigBrainError
class TexturesError(Error):
"""材质相关 error"""
class LanguageError(Error):
"""语言相关 error"""
class TestError(Error):
"""就像名字一样 用于测试的 error"""

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
@ -13,42 +13,3 @@ gitee: @shenjackyuanjie
from . import Error from . import Error
class CommandError(Error):
"""命令解析相关 error"""
class CommandParseError(CommandError):
"""命令解析时出现错误"""
# QMark -> Quotation marks
# Pos -> Position
class CommandQMarkPosError(CommandParseError):
"""命令中,引号位置不正确
例如 /command "aabcc "awdawd"""
class CommandQMarkMissing(CommandParseError):
"""命令中引号缺失
例如: /command "aawwdawda awdaw """
class CommandQMarkConflict(CommandParseError):
"""命令中引号位置冲突
例如: /command "aaaa "aaaa aaaa"""
first_qmark_pos = None
conflict_qmark_pos = None
class CommandQMarkPreMissing(CommandQMarkMissing):
"""命令中 前面的引号缺失
例如: /command aaaa" aaaaaa"""
suf_qmark_pos = None
class CommandQMarkSufMissing(CommandQMarkMissing):
"""命令中 后面的引号缺失(引号未闭合)
例如: /command "aaaawaa some command"""
pre_qmark_pos = None

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
@ -11,9 +11,3 @@ github: @shenjackyuanjie
gitee: @shenjackyuanjie gitee: @shenjackyuanjie
""" """
class Error(Exception):
"""基础 Exception"""
def __bool__(self):
return False

View File

@ -0,0 +1,9 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
from Difficult_Rocket.api.Exp import Error

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
@ -13,26 +13,3 @@ gitee: @shenjackyuanjie
from Difficult_Rocket.api.Exp.main import Error from Difficult_Rocket.api.Exp.main import Error
class NoMoreJson5(Error):
"""说什么我也不用Json5了"""
class Nope418ImTeapot(Error):
"""我只是个茶壶而已,我不能煮咖啡!"""
class ThinkError(Error):
"""进不去,进不去,怎么想都进不去!"""
class BrainError(Error):
"""clever brain.png"""
class BigBrainError(BrainError):
"""bigbrain.png"""
class BrainTimeoutError(BrainError, ThinkError):
"""脑子····超时·······················啦!"""

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -0,0 +1,111 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
"""
main.py
"""
class Error(Exception):
"""基础 Exception"""
def __bool__(self):
return False
class TexturesError(Error):
"""材质相关 error"""
class LanguageError(Error):
"""语言相关 error"""
class TestError(Error):
"""就像名字一样 用于测试的 error"""
"""
unsupport.py
"""
class NoMoreJson5(Error):
"""说什么我也不用Json5了"""
class Nope418ImATeapot(Error):
"""我只是个茶壶而已,我不能煮咖啡!"""
class ThinkError(Error):
"""进不去,进不去,怎么想都进不去!"""
class BrainError(Error):
"""clever brain.png"""
class BigBrainError(BrainError):
"""bigbrain.png"""
class BrainTimeoutError(BrainError, ThinkError):
"""脑子····超时·······················啦!"""
"""
command.py
"""
class CommandError(Error):
"""命令解析相关 error"""
class CommandParseError(CommandError):
"""命令解析时出现错误"""
# QMark -> Quotation marks
# Pos -> Position
class CommandQMarkPosError(CommandParseError):
"""命令中,引号位置不正确
例如 /command "aabcc "awdawd"""
class CommandQMarkMissing(CommandParseError):
"""命令中引号缺失
例如: /command "aawwdawda awdaw """
class CommandQMarkConflict(CommandParseError):
"""命令中引号位置冲突
例如: /command "aaaa "aaaa aaaa"""
first_qmark_pos = None
conflict_qmark_pos = None
class CommandQMarkPreMissing(CommandQMarkMissing):
"""命令中 前面的引号缺失
例如: /command aaaa" aaaaaa"""
suf_qmark_pos = None
class CommandQMarkSufMissing(CommandQMarkMissing):
"""命令中 后面的引号缺失(引号未闭合)
例如: /command "aaaawaa some command"""
pre_qmark_pos = None
"""
threading.py
"""
class LockTimeOutError(Error):
"""没有特殊指定的 ”某个“ 锁超时了"""

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,9 +1,8 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------
# 本文件以 GNU Lesser General Public License v3.0GNU LGPL v3) 开源协议进行授权 (谢谢狐狸写出这么好的MCDR)
import functools import functools
import inspect import inspect

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -1,6 +1,6 @@
# ------------------------------- # -------------------------------
# Difficult Rocket # Difficult Rocket
# Copyright © 2021-2022 by shenjackyuanjie # Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com
# All rights reserved # All rights reserved
# ------------------------------- # -------------------------------

View File

@ -3,6 +3,8 @@ import threading
from time import strftime from time import strftime
from typing import Optional from typing import Optional
from Difficult_Rocket.api.Exp.threading import
color_reset_suffix = "\033[0m" color_reset_suffix = "\033[0m"
@ -11,7 +13,7 @@ class LogFileCache:
def __init__(self, file_name: str = 'logs//log.log', flush_time: Optional[int, float] = 1, cache_entries_num: int = 10): def __init__(self, file_name: str = 'logs//log.log', flush_time: Optional[int, float] = 1, cache_entries_num: int = 10):
# 配置相关 # 配置相关
self.log_file_name = file_name # log 文件名称 self._logfile_name = file_name # log 文件名称
self.flush_time = flush_time # 缓存刷新时长 self.flush_time = flush_time # 缓存刷新时长
self.cache_entries_num = cache_entries_num self.cache_entries_num = cache_entries_num
# 写入缓存数 # 写入缓存数
@ -19,8 +21,17 @@ class LogFileCache:
# 日志缓存表 # 日志缓存表
self.log_caches = [] self.log_caches = []
# 同步锁 # 同步锁
self.thread_log = threading.Lock self.thread_lock = threading.Lock()
@property
def logfile_name(self) -> str:
return self._logfile_name
@logfile_name.setter
def logfile_name(self, value: str) -> None:
self.thread_lock.acquire(timeout=1/60)
if not self.thread_lock.locked():
...
def _log_file_time_write(self) -> None: def _log_file_time_write(self) -> None:
"""使用 threading.Timer 调用的定时写入日志文件的函数""" """使用 threading.Timer 调用的定时写入日志文件的函数"""
@ -30,7 +41,7 @@ class LogFileCache:
def make_log(self, string: str, wait_for_cache: bool = True) -> None: def make_log(self, string: str, wait_for_cache: bool = True) -> None:
if wait_for_cache: if wait_for_cache:
with open(file=self.log_file_name, encoding='utf-8', mode='a') as log_file: with open(file=self.logfile_name, encoding='utf-8', mode='a') as log_file:
log_file.writelines(self.log_caches) log_file.writelines(self.log_caches)
log_file.write(string) log_file.write(string)
... ...