From d2e4c2f706abcbf3835376eb008119fc1b87c655 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 7 Jul 2022 18:28:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=9C=A8=E5=81=9Ac=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- Difficult_Rocket/main.py | 1 - Difficult_Rocket/utils/cprint/CMakeLists.txt | 19 ++++++ Difficult_Rocket/utils/cprint/color_print.py | 66 ++++++++++++++++++ Difficult_Rocket/utils/cprint/colors.py | 11 +++ Difficult_Rocket/utils/cprint/compile.py | 41 ++++++++++++ Difficult_Rocket/utils/cprint/cprint.c | 30 +++++++++ Difficult_Rocket/utils/cprint/dll_load.py | 9 +++ Difficult_Rocket/utils/cprint/py_cprint.c | 44 ++++++++++++ Difficult_Rocket/utils/cprint/py_cprint.py | 9 +++ Difficult_Rocket/utils/cprint/pycprint.pyi | 7 ++ Difficult_Rocket/utils/cprint/setup.py | 30 +++++++++ docs/字体展示.pptx | Bin 46576 -> 46554 bytes libs/msdnicrosoft_logger/shenjack.py | 67 +++++++++++-------- mods/DR/__init__.py | 12 ---- mods/DR/type_data.py | 12 ---- mods/mod_test.py | 32 --------- 17 files changed, 307 insertions(+), 86 deletions(-) create mode 100644 Difficult_Rocket/utils/cprint/CMakeLists.txt create mode 100644 Difficult_Rocket/utils/cprint/color_print.py create mode 100644 Difficult_Rocket/utils/cprint/colors.py create mode 100644 Difficult_Rocket/utils/cprint/compile.py create mode 100644 Difficult_Rocket/utils/cprint/cprint.c create mode 100644 Difficult_Rocket/utils/cprint/dll_load.py create mode 100644 Difficult_Rocket/utils/cprint/py_cprint.c create mode 100644 Difficult_Rocket/utils/cprint/py_cprint.py create mode 100644 Difficult_Rocket/utils/cprint/pycprint.pyi create mode 100644 Difficult_Rocket/utils/cprint/setup.py delete mode 100644 mods/DR/__init__.py delete mode 100644 mods/DR/type_data.py delete mode 100644 mods/mod_test.py diff --git a/.gitignore b/.gitignore index 53a5781..1b93862 100644 --- a/.gitignore +++ b/.gitignore @@ -149,5 +149,4 @@ dmypy.json other things/ .git-/ -try/cprint/cmake-build-debug -try/c/cmake-build-debug +*cmake-build-debug diff --git a/Difficult_Rocket/main.py b/Difficult_Rocket/main.py index 800ce44..3b103d5 100644 --- a/Difficult_Rocket/main.py +++ b/Difficult_Rocket/main.py @@ -26,7 +26,6 @@ from Difficult_Rocket import client, server from Difficult_Rocket.utils import tools from Difficult_Rocket.utils.translate import tr - class Game: def __init__(self): # basic config diff --git a/Difficult_Rocket/utils/cprint/CMakeLists.txt b/Difficult_Rocket/utils/cprint/CMakeLists.txt new file mode 100644 index 0000000..f943b99 --- /dev/null +++ b/Difficult_Rocket/utils/cprint/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.22) +project(cprint VERSION 0.0.1 LANGUAGES C) +# 环境 +set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_C_STANDARD 99) +# 编译选项 +add_compile_options(-O3) +add_compile_options(-Wall) +add_compile_options(-Werror) +#add_compile_options(-shared) +#add_compile_options(-o ../../cprint.dll) +# 加一下py3.8的 path +include_directories(.) +include_directories(C:\\Users\\shenjack.SHENJACK-5600X\\AppData\\Local\\Programs\\Python\\Python38\\include\\.) +# 编译可执行 +#add_executable(cprint cprint.c) +# 编译动态链接库 +#add_executable(cprint cprint.c) +add_executable(py_cprint py_cprint.c) diff --git a/Difficult_Rocket/utils/cprint/color_print.py b/Difficult_Rocket/utils/cprint/color_print.py new file mode 100644 index 0000000..22b243b --- /dev/null +++ b/Difficult_Rocket/utils/cprint/color_print.py @@ -0,0 +1,66 @@ +import _winapi +import subprocess +import os + +os.system('') + +reset = '\033[0m' + +print('A 000') + +do = False + + +def rgb(r, g, b): + return 2, r, g, b + + +# i_list = list(range(30, 39, 1)) +# # i_list = [39] +# j_list = list(range(40, 49, 1)) +# # j_list = [49] +# +# for i in i_list: +# for j in j_list: +# print(f'\033[{i};{j}m{i}|{j} {reset}', end='|') +# print() +# print() + + +def color_print(*args): + args = [str(i) for i in args] + out = '|'.join(args) + line = ';'.join(args) + print(f'\033[{line}m{out}\033[0m') + + +if os.name == "nt": + from ctypes import windll + from ctypes.wintypes import BOOL, HANDLE, WORD + + handle = _winapi.GetStdHandle(_winapi.STD_OUTPUT_HANDLE) + kernel32 = windll.LoadLibrary("Kernel32.dll") + SetConsoleAttribute = kernel32.SetConsoleTextAttribute + SetConsoleAttribute.argtypes = (HANDLE, WORD) + SetConsoleAttribute.restype = BOOL + # FOREGROUND_INTENSITY|FOREGROUND_RED + res: bool = SetConsoleAttribute(handle, 5) + print(res) + string = "Hello World!" + _winapi.WriteFile(handle, string.encode("utf-8"), 0) +else: + pass + +# exit(0) + +color_print(94) +color_print(41, 93) +color_print(36, 40) +print() +color_print(48, *rgb(200, 100, 20), 34) +color_print(48, *rgb(255, 161, 72)) +color_print(48, *rgb(255, 161, 72), 38, *rgb(1, 50, 255)) +color_print(48, *rgb(178, 112, 50), 38, *rgb(98, 96, 167)) +print() +color_print(48, *rgb(100, 10, 10), ) +exit(0) diff --git a/Difficult_Rocket/utils/cprint/colors.py b/Difficult_Rocket/utils/cprint/colors.py new file mode 100644 index 0000000..1d95fea --- /dev/null +++ b/Difficult_Rocket/utils/cprint/colors.py @@ -0,0 +1,11 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- +from colorama import Fore, Back, Style +print(Fore.RED + 'some red text') +print(Back.GREEN + 'and with a green background') +print(Style.DIM + 'and in dim text') +print(Style.RESET_ALL) +print('back to normal now') \ No newline at end of file diff --git a/Difficult_Rocket/utils/cprint/compile.py b/Difficult_Rocket/utils/cprint/compile.py new file mode 100644 index 0000000..dad5791 --- /dev/null +++ b/Difficult_Rocket/utils/cprint/compile.py @@ -0,0 +1,41 @@ + +import os + +# include 目录 +include_paths = ["C:\\Users\\shenjack.SHENJACK-5600X\\AppData\\Local\\Programs\\Python\\Python38\\include\\."] + +# 编译选项 +compile_options = { + "-shared": None, + "-O3": None, + "-Wall": None, + "-Werror": None, + "-o": "./py_cprint.dll" +} + +include_command = "-I " + +# 处理 include 目录命令 +for path in include_paths: + include_command = "{}, {}".format(include_command, path) +else: + if len(include_paths) != 0: + include_command = include_command[:3] + include_command[4:] + +compile_option_command = "" + +# 处理编译选项 +for option, key in compile_options.items(): + if key is None: + compile_option_command = "{} {} ".format(compile_option_command, option) + else: + compile_option_command = "{} {} {}".format(compile_option_command, option, key) + +print(include_command, compile_option_command) + +compile_command = "gcc.exe ./py_cprint.c {}{}".format(include_command, compile_option_command) + +print(compile_command) + +os.system(compile_command) + diff --git a/Difficult_Rocket/utils/cprint/cprint.c b/Difficult_Rocket/utils/cprint/cprint.c new file mode 100644 index 0000000..78c294d --- /dev/null +++ b/Difficult_Rocket/utils/cprint/cprint.c @@ -0,0 +1,30 @@ +// +// Created by shenjack on 2022/6/24. +// + +//#define PY_SSIZE_T_CLEAN +#include "Python.h" +#include +#include +#include +#include + + +int CcPrint(PyObject *self, PyObject *args, PyObject *kwargs){ + char *print_str; + char *line_end = NULL; // 准备参数 + static char *kwlist[] = {"some_stuf", "end", NULL}; // 准备参数列表 + if(!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &print_str, &line_end)){ + return 0; + }; + return 1; +}; + +// 如果你非得调用我····· +int main(){ + printf("aaaa"); + if(false){ + CcPrint(PyLong_FromLong(1), PyLong_FromLong(1), PyLong_FromLong(1)); + }; + return 0; +}; \ No newline at end of file diff --git a/Difficult_Rocket/utils/cprint/dll_load.py b/Difficult_Rocket/utils/cprint/dll_load.py new file mode 100644 index 0000000..f61baed --- /dev/null +++ b/Difficult_Rocket/utils/cprint/dll_load.py @@ -0,0 +1,9 @@ + +from objprint import objprint + +from ctypes import cdll + +cprint = cdll.LoadLibrary("./cprint.dll") + +# objprint(cprint) + diff --git a/Difficult_Rocket/utils/cprint/py_cprint.c b/Difficult_Rocket/utils/cprint/py_cprint.c new file mode 100644 index 0000000..00bef71 --- /dev/null +++ b/Difficult_Rocket/utils/cprint/py_cprint.c @@ -0,0 +1,44 @@ +// +// Created by shenjack on 2022/7/6. +// + +#define PY_SSIZE_T_CLEAN +#include +#include + +static PyObject *pycprint_print(PyObject *self, PyObject *args){ + const char *text; + if(!PyArg_ParseTuple(args, "s", &text)){ // 解析 text + return NULL; + }; + printf("%s", text); + Py_RETURN_NONE; +}; + +static PyObject *pycpint_printf(PyObject *self, PyObject *args, PyObject *kwargs){ + PyObject *a; + if(!PyArg_ParseTuple(args, "O", &a)){ + return NULL; + }; + Py_ssize_t text_len = PyTuple_Size(args); + Py_RETURN_NONE; +}; + +static PyMethodDef PyCprintMethods[] = { + {"print", pycprint_print, METH_VARARGS, "直接使用c的printf输出"}, + {"printf", (PyCFunction)(void(*))pycpint_printf, METH_VARARGS | METH_KEYWORDS, + "传入类似py print然后进行format的print"}, + {NULL, NULL, 0, NULL} +}; + +static struct PyModuleDef pycprintmodule = { + PyModuleDef_HEAD_INIT, + "pycprint", + "直接调用c的printf", + -1, + PyCprintMethods +}; + +PyMODINIT_FUNC PyInit_pycprint(void){ + return PyModule_Create(&pycprintmodule); +} diff --git a/Difficult_Rocket/utils/cprint/py_cprint.py b/Difficult_Rocket/utils/cprint/py_cprint.py new file mode 100644 index 0000000..010a7d4 --- /dev/null +++ b/Difficult_Rocket/utils/cprint/py_cprint.py @@ -0,0 +1,9 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +from build import pycprint + +pycprint.print("aaa\n") diff --git a/Difficult_Rocket/utils/cprint/pycprint.pyi b/Difficult_Rocket/utils/cprint/pycprint.pyi new file mode 100644 index 0000000..2203386 --- /dev/null +++ b/Difficult_Rocket/utils/cprint/pycprint.pyi @@ -0,0 +1,7 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2021-2022 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +def print(text: str) -> None: ... # 直接调用fprint diff --git a/Difficult_Rocket/utils/cprint/setup.py b/Difficult_Rocket/utils/cprint/setup.py new file mode 100644 index 0000000..38dcfca --- /dev/null +++ b/Difficult_Rocket/utils/cprint/setup.py @@ -0,0 +1,30 @@ +from setuptools import setup, Extension +import shutil +import os + +pycprint = Extension('pycprint', + sources=['py_cprint.c']) + +setup(name='PyCprint', + version='0.0.1', + author='shenjack', + author_email='3695888@qq.com', + description='这是一个用于直接调用c的printf的库', + ext_modules=[pycprint]) + + +def dir_not_temp(path: str): + return path.find('temp') and os.path.isdir(os.path.join('build', path)) + + +build_dir = os.listdir('./build') +build_dir = list(filter(dir_not_temp, build_dir)) +# 用列表推导式把 是文件夹 且 名字里没有 temp 的抽出来 +print(build_dir) + +os.chdir('build') +# 把运行路径迁移过去,方便copy + +for build in build_dir: + copy = os.listdir(build) + shutil.copy(os.path.join(build, copy[0]), './') diff --git a/docs/字体展示.pptx b/docs/字体展示.pptx index 226eaa543e55f17e67252c1327dd2890ad61aea1..7d1c364f4386b2c2d8579764a3b64ca61ae245a7 100644 GIT binary patch delta 4179 zcmYM1by$>57smI2B^H!!=@g};MPaE$!bMPWmlP0@TuRbMq$C7%2~m&|TvBjpkWQCQ zNl`#jV5t|SKJdM+_nUv_p6kpXbDcSJ?%!;!kxZ_UlnM(&t5RIc@mGZLP%togMx&u3 zq)VFuU7k5@nPSl9Q{8meVrwSjl=v$WOv3=?h7zT9CAPbP5pKLWg^X2>YZ3#`HgSmIo(s?qCc+@jvmXF)RSV}*a9H_F45w?J9w@pWQcPK-6HK*%tQx-H?E9+KI^x%zu zrXOt+u&n)AwMu`M3(Zf=!K-h;nFi#|A!(o1Re|(5w>$0=+%8GSnU17t47BVD8K8r- zpDep|;SV2xz|?wO!&1(e zH&Wueu_4tUW+wNb7Y`mU^y0@AN*Q8el&Fo&`B27gfmVc$hP4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~59MxMEJ~Aat0!3y<X0@nUUqSLcMG%J&1R5Y1E<}d9b|cG4WCA(!<80{1 z{OvWCD%Tb%505m2&mlZABfpA`iq^DX(@lL#C|;R=Z3$RPg;#lptWEA95~=ApVDbcPmLE%>wA~~^Ti;Dh9Z({tSU`dq>$M9` z?ew)TIV8&N=Fx3kwqxc&CpGs@cK_rZPB7H(9xDYDG-`X5 zO2aTPwe<6avgMpMd!q&%hBE}0tzn|k=s*S3Im-66>vlm2v@JVzJh~yKm27)pudfCR zkegFTcjG_T6t&5@1tV?(hpdqw!~g6Y-3+DjbxBjvYu+f>qSdqB|MuCw^5QmfZSxE{ zWfIloJ%-VT-lpQUcr7;U9PReQwbWti8mlXZcmDI}AY8j6`w{t`i-T(s`>{xu$RlT+ zquyzMBX)C=g`U&THdhKm62pxPiNdzzO94?C+N+ZK6EM3U>N_mM-WFB5+6)_qRQtj) z@0xAzq-p$LB`qn>n(pLAN&c*s#0|Oe- ze6bGbO3*Q}m*Gk>F@(!-<&+q~5}m(#gh5`0D=orwUWO|R!Z4NU{Iws9!)3T)IOfx3 zxI#7tSoYvAelP}?;V*V_%A!F3@ None: """使用 threading.Timer 调用的定时写入日志文件的函数""" with self.with_thread_lock: - ... if self.cache_count == 0: return None ... @@ -93,7 +101,7 @@ class Logger: else: ... - def make_log(self, level: str, + def make_log(self, level: int, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', @@ -104,61 +112,45 @@ class Logger: sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - self.make_log(level='detail', *values, sep=sep, end=end, flush=flush) + self.make_log(level=DETAIL, *values, sep=sep, end=end, flush=flush) def debug(self, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - ... + self.make_log(level=DEBUG, *values, sep=sep, end=end, flush=flush) def info(self, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - ... + self.make_log(level=INFO, *values, sep=sep, end=end, flush=flush) def warning(self, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - ... + self.make_log(level=WARNING, *values, sep=sep, end=end, flush=flush) def error(self, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - ... + self.make_log(level=ERROR, *values, sep=sep, end=end, flush=flush) def fatal(self, *values: object, sep: Optional[str] = ' ', end: Optional[str] = '\n', flush: Optional[bool] = False) -> None: - ... + self.make_log(level=FATAL, *values, sep=sep, end=end, flush=flush) -# class LoggerManager: -# """shenjack牌logger""" -# -# def __init__(self): -# self.configs = {} -# -# def add_config(self, name: str, config: dict) -> dict: -# self.configs[name] = config -# return self.configs -# -# def get_logger(self, name: str = 'root', config: dict = None) -> Logger: -# """相当于 logging.getLogger(name='root')""" -# if config is not None: -# self.add_config(name, config) -# return Logger(config=self.configs) - -global_configs = { +logger_configs = { 'root': { 'level': DEBUG, 'color': { @@ -171,3 +163,24 @@ global_configs = { ...: ... } } + + +def add_dict_config_to_global(some_dict: dict, name: str) -> dict: + """ + + @param some_dict: 一个你丢进来的 logger 设置 + @param name: 这个 logger 设置的名称 + @return: 修改过的 logger 配置 + """ + logger_configs[name] = some_dict + return logger_configs + + +def add_kwargs_to_global(**kwargs) -> dict: + """ + + @param kwargs: + @return: + """ + ... + diff --git a/mods/DR/__init__.py b/mods/DR/__init__.py deleted file mode 100644 index 43badfc..0000000 --- a/mods/DR/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -# ------------------------------- -# Difficult Rocket -# Copyright © 2021-2022 by shenjackyuanjie -# All rights reserved -# ------------------------------- - -""" -writen by shenjackyuanjie -mail: 3695888@qq.com -github: @shenjackyuanjie -gitee: @shenjackyuanjie -""" diff --git a/mods/DR/type_data.py b/mods/DR/type_data.py deleted file mode 100644 index 43badfc..0000000 --- a/mods/DR/type_data.py +++ /dev/null @@ -1,12 +0,0 @@ -# ------------------------------- -# Difficult Rocket -# Copyright © 2021-2022 by shenjackyuanjie -# All rights reserved -# ------------------------------- - -""" -writen by shenjackyuanjie -mail: 3695888@qq.com -github: @shenjackyuanjie -gitee: @shenjackyuanjie -""" diff --git a/mods/mod_test.py b/mods/mod_test.py deleted file mode 100644 index ff8d819..0000000 --- a/mods/mod_test.py +++ /dev/null @@ -1,32 +0,0 @@ -# ------------------------------- -# Difficult Rocket -# Copyright © 2021 by shenjackyuanjie -# All rights reserved -# ------------------------------- - -""" -writen by shenjackyuanjie -mail: 3695888@qq.com -github: @shenjackyuanjie -gitee: @shenjackyuanjie -""" - -""" -this is a test of modding in Difficult Rocket -just a test -只是一个DR的mod测试 -""" - -# from libs -import semver - -# from DR -from Difficult_Rocket import semver_game_version -from Difficult_Rocket.mods import MODInfo, semver_loader_version - -mod_info = MODInfo(name="test mod", - version=semver.VersionInfo.parse("0.0.1"), - write_version=semver_game_version, - write_loader_version=semver_loader_version) - -print(mod_info.serialize())