mods and MCDR!
This commit is contained in:
parent
2715755316
commit
b40d6fb30b
@ -11,7 +11,7 @@ github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
from libs.semver.semver import VersionInfo
|
||||
from libs.semver import VersionInfo
|
||||
|
||||
game_version = '0.6.2'
|
||||
__version__ = game_version
|
||||
|
@ -13,7 +13,8 @@ from enum import EnumMeta
|
||||
from threading import Lock
|
||||
from typing import Union, TypeVar, List, Dict, Type, get_type_hints, Any
|
||||
|
||||
from semver import VersionInfo
|
||||
from semver import VersionInfo as semver_VersionInfo
|
||||
from libs.semver import VersionInfo as lib_semver_VersionInfo
|
||||
|
||||
"""
|
||||
This part of code come from MCDReforged(https://github.com/Fallen-Breath/MCDReforged)
|
||||
@ -46,13 +47,13 @@ def _get_args(cls: Type) -> tuple:
|
||||
return getattr(cls, '__args__', ())
|
||||
|
||||
|
||||
_BASIC_CLASSES = (type(None), bool, int, float, str, list, dict, VersionInfo)
|
||||
_BASIC_CLASSES = (type(None), bool, int, float, str, list, dict, lib_semver_VersionInfo, semver_VersionInfo)
|
||||
|
||||
|
||||
def serialize(obj) -> _BASIC_CLASSES:
|
||||
if type(obj) in (type(None), int, float, str, bool):
|
||||
return obj
|
||||
elif isinstance(obj, VersionInfo):
|
||||
elif isinstance(obj, lib_semver_VersionInfo) or isinstance(obj, semver_VersionInfo):
|
||||
return obj
|
||||
elif isinstance(obj, list) or isinstance(obj, tuple):
|
||||
return list(map(serialize, obj))
|
||||
@ -67,7 +68,7 @@ def serialize(obj) -> _BASIC_CLASSES:
|
||||
if attr_name.startswith('_'):
|
||||
attr_dict.pop(attr_name)
|
||||
except:
|
||||
raise TypeError('Unsupported input type {}'.format(type(obj))) from None
|
||||
raise TypeError(f'Unsupported input type {type(obj)}') from None
|
||||
else:
|
||||
return serialize(attr_dict)
|
||||
|
||||
|
@ -15,7 +15,7 @@ gitee: @shenjackyuanjie
|
||||
from typing import Tuple
|
||||
|
||||
# from libs
|
||||
from libs.semver.semver import VersionInfo
|
||||
from libs.semver import VersionInfo
|
||||
|
||||
# from DR
|
||||
from Difficult_Rocket import semver_game_version
|
||||
@ -54,8 +54,7 @@ class MODInfo(Serializable):
|
||||
write_loader_version: VersionInfo # mod编写的加载器版本
|
||||
compatible_version: Tuple[VersionInfo, VersionInfo] = (semver_game_version, semver_game_version) # mod兼容版本
|
||||
# 第一个是最低兼容版本,第二个是最高兼容版本
|
||||
# 例如: ("1.0.0", "1.1.0")
|
||||
# 例如: ("1.0.0", "1.1.0")
|
||||
# 例如: ("1.0.0", "1.1.0") 表示从1.0.0版本开始兼容,到1.1.0版本结束兼容
|
||||
|
||||
|
||||
MOD_info = MODInfo(
|
||||
@ -66,6 +65,8 @@ MOD_info = MODInfo(
|
||||
write_loader_version=semver_loader_version
|
||||
)
|
||||
|
||||
print(MOD_info.serialize())
|
||||
|
||||
"""
|
||||
一些重置用函数
|
||||
"""
|
||||
|
@ -71,7 +71,7 @@ EXCEPT_MSG = """
|
||||
|
||||
PY2 = sys.version_info[0] == 2
|
||||
|
||||
STR_OR_UNICODE = unicode if PY2 else str # For paste(): Python 3 uses str, Python 2 uses unicode.
|
||||
STR_OR_UNICODE = str
|
||||
|
||||
ENCODING = 'utf-8'
|
||||
|
||||
@ -104,7 +104,7 @@ class PyperclipTimeoutException(PyperclipException):
|
||||
|
||||
def _stringifyText(text):
|
||||
if PY2:
|
||||
acceptedTypes = (unicode, str, int, float, bool)
|
||||
acceptedTypes = (str, int, float, bool)
|
||||
else:
|
||||
acceptedTypes = (str, int, float, bool)
|
||||
if not isinstance(text, acceptedTypes):
|
||||
|
@ -9,11 +9,9 @@ import re
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
|
||||
PY2 = sys.version_info[0] == 2
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
|
||||
__version__ = "2.13.0"
|
||||
__author__ = "Kostiantyn Rybnikov"
|
||||
__author_email__ = "k-bx@k-bx.com"
|
||||
@ -56,22 +54,21 @@ __all__ = (
|
||||
#: Contains the implemented semver.org version of the spec
|
||||
SEMVER_SPEC_VERSION = "2.0.0"
|
||||
|
||||
|
||||
if not hasattr(__builtins__, "cmp"):
|
||||
|
||||
def cmp(a, b):
|
||||
"""Return negative if a<b, zero if a==b, positive if a>b."""
|
||||
return (a > b) - (a < b)
|
||||
|
||||
|
||||
if PY3: # pragma: no cover
|
||||
string_types = str, bytes
|
||||
text_type = str
|
||||
binary_type = bytes
|
||||
|
||||
|
||||
def b(s):
|
||||
return s.encode("latin-1")
|
||||
|
||||
|
||||
def u(s):
|
||||
return s
|
||||
|
||||
@ -81,9 +78,11 @@ else: # pragma: no cover
|
||||
text_type = unicode
|
||||
binary_type = str
|
||||
|
||||
|
||||
def b(s):
|
||||
return s
|
||||
|
||||
|
||||
# Workaround for standalone backslash
|
||||
def u(s):
|
||||
return unicode(s.replace(r"\\", r"\\\\"), "unicode_escape")
|
Loading…
Reference in New Issue
Block a user