update dependency and fix issue with tomli

This commit is contained in:
shenjack 2023-12-31 02:32:40 +08:00
parent ecd08c373a
commit 0ce43f5992
Signed by: shenjack
GPG Key ID: 7B1134A979775551
13 changed files with 26 additions and 25 deletions

View File

@ -6,7 +6,7 @@
import os
import sys
import rtoml
import tomlkit
import io
@ -35,7 +35,7 @@ if sys.argv == [__file__]: # 没有输入参数,直接输出默认信息并
config_file = tools.load_file("./config/main.toml")
config_file["window"]["width"] = 1024
config_file["window"]["height"] = 768
rtoml.dump(config_file, open("./config/main.toml", "w"))
tomlkit.dump(config_file, open("./config/main.toml", "w"))
elif os.path.abspath(os.curdir) in sys.path and "-github" in sys.argv:
print(f"DR_version={DR_status.DR_version}")

1
.gitignore vendored
View File

@ -85,6 +85,7 @@ coverage.xml
*.pot
# Environments
env*
.env
.venv
env/

View File

@ -79,7 +79,7 @@ DR_status = _DRStatus()
def load_logger():
log_config_path = Path("./config/lndl-logger.toml")
import rtoml
import tomli
warn_config = False
if not log_config_path.is_file():
@ -91,11 +91,11 @@ def load_logger():
except (FileNotFoundError, OSError, PermissionError):
print("\033[31mFailed to write default log config file\033[0m")
warn_config = True
logger_config = rtoml.loads(log_config.default_config)
logger_config = tomli.loads(log_config.default_config)
else:
# 读取配置文件
with open(log_config_path, encoding="utf-8") as f:
logger_config = rtoml.load(f)
with open(log_config_path, 'rb') as f:
logger_config = tomli.load(f)
# 输入 lndl 进行配置
from lib_not_dr.loggers.config import read_config, get_logger

View File

@ -16,7 +16,7 @@ from decimal import Decimal
from typing import Callable, Dict, List, TYPE_CHECKING, Type
# third function
import rtoml
import tomlkit
import pyglet
# from pyglet import gl
@ -330,7 +330,7 @@ class ClientWindow(Window):
config_file["window"]["width"] = self.width
config_file["window"]["height"] = self.height
config_file["runtime"]["language"] = DR_runtime.language
rtoml.dump(config_file, open("./config/main.toml", "w"))
tomlkit.dump(config_file, open("./config/main.toml", "w"))
self.logger.info(tr().client.config.save.done())
"""

View File

@ -37,10 +37,10 @@ class _DRRuntime(Options):
def load_file(self) -> bool:
with contextlib.suppress(FileNotFoundError):
with open("./config/main.toml", "r", encoding="utf-8") as f:
import rtoml
with open("./config/main.toml", "rb") as f:
import tomli
config_file = rtoml.load(f)
config_file = tomli.load(f)
self.language = config_file["runtime"]["language"]
self.mod_path = config_file["game"]["mods"]["path"]
self.main_config = config_file

View File

@ -16,7 +16,8 @@ import sys
import time
import math
import json
import rtoml
import tomli
import tomlkit
import configparser
from pathlib import Path
@ -62,8 +63,8 @@ def load_file(
if stack:
get_file = get_file[stack]
elif f_type == "toml":
with open(file_name, mode="r", encoding=encoding) as file:
get_file = rtoml.load(file)
with open(file_name, mode="rb") as file:
get_file = tomli.load(file)
if stack is not None:
get_file = get_file[stack]
elif f_type == "json":
@ -102,7 +103,7 @@ def save_dict_file(file_name: str, data: dict, encoding: str = "utf-8") -> bool:
return False
elif f_type == "toml":
with open(file_name, mode="w", encoding=encoding) as file:
rtoml.dump(data, file)
tomlkit.dump(data, file)
elif f_type == "json":
with open(file_name, mode="w", encoding=encoding) as file:
json.dump(data, file)

View File

@ -56,7 +56,8 @@ git clone git@github.com:shenjackyuanjie/Difficult-Rocket.git
### 2. 安装依赖
```bash title="install.sh"
python -m pip install -r requirement.txt
python gen_require.py 0
python -m pip install -r requirements.txt
git submodule update --init --recursive
cd libs
python -m pip install ./lib_not_dr

View File

@ -21,5 +21,6 @@ background_color = [21, 22, 23, 0]
width = 1024
height = 768
gui_scale = 1
[game.mods]
path = "mods"

View File

@ -56,6 +56,7 @@ git clone git@github.com:shenjackyuanjie/Difficult-Rocket.git
### 2. Install requirements
```bash title="install.sh"
python gen_require.py 0
python -m pip install -r requirements.txt
git submodule update --init --recursive
cd libs
@ -84,14 +85,10 @@ python DR.py
> python gen_require.py [-h] {0,1,2}
> run / build / compile
- `pyglet` (pre-installed V2.0.8 path:`./libs/pyglet`)
- `pyglet` (pre-installed V2.x path:`./libs/pyglet`)
- `xmltodict` (pre-installed V0.12.0 path:`./libs/xmltodict`)
- `pyperclip` (pre-installed V1.8.2 path: `./libs/pyperclip`)
[requirement.txt](requirement.txt)
[requirement-build.txt](requirement-build.txt)
[requirement-dev.txt](requirement-dev.txt)
## Credits
- Open Source Projects

View File

@ -34,7 +34,7 @@ dev = {
"debug": [
"objprint >= 0.2.3",
"viztracer >= 0.16.0; platform_python_implementation != \"PyPy\"",
"vizplugin >= 0.1.3; platform_python_implementation != \"PyPy\""
"vizplugins >= 0.1.3; platform_python_implementation != \"PyPy\""
]
}
# fmt: on

@ -1 +1 @@
Subproject commit 6b586c72a7c17aa7b140db3a0549897cc73f9959
Subproject commit c50c697b40c31361f499d88e83a9a0980d8fb2c0

View File

@ -2,7 +2,7 @@ import json
import pprint
import sys
import rtoml as toml
import tomlkit as toml
with open(sys.argv[1], encoding="utf-8", mode="r") as f:
if sys.argv[2] == "parse":

View File

@ -16,7 +16,7 @@ from Difficult_Rocket.api.types import Options, Version
from lib_not_dr import loggers
DR_rust_version = Version("0.3.0") # DR_mod 的 Rust 编写部分的兼容版本
DR_rust_version = Version("0.3.1") # DR_mod 的 Rust 编写部分的兼容版本
logger = loggers.config.get_logger_from_old("client.dr_game", "client")