0.6.1!
This commit is contained in:
parent
93036a8640
commit
693497c9ba
@ -338,4 +338,5 @@ def decode_text2HTML(text: str,
|
|||||||
if style.show: # 如果这个字符显示
|
if style.show: # 如果这个字符显示
|
||||||
formatted_HTML_text += style.prefix + style.text + style.suffix # 文本的后面附加一下
|
formatted_HTML_text += style.prefix + style.text + style.suffix # 文本的后面附加一下
|
||||||
del style_list # 主动删掉style_list 释放内存
|
del style_list # 主动删掉style_list 释放内存
|
||||||
|
print(formatted_HTML_text)
|
||||||
return formatted_HTML_text # 返回,DONE!
|
return formatted_HTML_text # 返回,DONE!
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[runtime]
|
[runtime]
|
||||||
fps = 60
|
fps = 60
|
||||||
version = 0.6.0
|
version = 0.6.1
|
||||||
language = zh-CN
|
language = zh-CN
|
||||||
date_fmt = %%Y-%%m-%%d %%H-%%M-%%S
|
date_fmt = %%Y-%%m-%%d %%H-%%M-%%S
|
||||||
write_py_v = 3.8.10
|
write_py_v = 3.8.10
|
||||||
@ -9,7 +9,7 @@ fonts_folder = libs/fonts
|
|||||||
[window]
|
[window]
|
||||||
style = None
|
style = None
|
||||||
width = 1299
|
width = 1299
|
||||||
height = 942
|
height = 931
|
||||||
visible = true
|
visible = true
|
||||||
caption = Difficult Rocket {version}
|
caption = Difficult Rocket {version}
|
||||||
resizable = true
|
resizable = true
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Difficult Rocket Update Logs
|
# Difficult Rocket Update Logs
|
||||||
|
|
||||||
- 感谢 `Github copilot` 的翻译(甚至这句话也是`copilot`翻译的)
|
- 感谢 `Github copilot` 的翻译(甚至这句话也是`copilot`翻译的)
|
||||||
- 也就意味着以后的更新日志是中文记录+`copilot`翻译的
|
- 也就意味着以后的更新日志是中文记录+`copilot`翻译的(当然,也有可能是`Easy Translate`翻译的)
|
||||||
- Thanks `Github copilot` for translate (lazy yes!)
|
- Thanks `Github copilot` for translate (lazy yes!)
|
||||||
- Means the update logs will lodge in Chinese and translated by `copilot`
|
- Means the update logs will lodge in Chinese and translated by `copilot`
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
- [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](README-cn.md)
|
- [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](README-cn.md)
|
||||||
- Using [SemVer 2.0.0](https://semver.org/) to manage version
|
- Using [SemVer 2.0.0](https://semver.org/) to manage version
|
||||||
|
|
||||||
## ~~202111 202112xx~~ 202201 V 0.6.1
|
## ~~202111 202112xx~~ 20220119 V 0.6.1
|
||||||
|
|
||||||
~~争取12月内发一个release~~
|
~~争取12月内发一个release~~
|
||||||
|
|
||||||
@ -79,6 +79,8 @@
|
|||||||
- 同时为他写了一个 `decode_text2HTML` 工具(这也是咕咕咕的一大部分原因)
|
- 同时为他写了一个 `decode_text2HTML` 工具(这也是咕咕咕的一大部分原因)
|
||||||
- add a `HTMLformatedLabel` Label based on `HTMLLabel`
|
- add a `HTMLformatedLabel` Label based on `HTMLLabel`
|
||||||
- also write a `decode_text2HTML` tool (also a big reason why lazy)
|
- also write a `decode_text2HTML` tool (also a big reason why lazy)
|
||||||
|
- 增加内置模块 `toml` 和对应的 `LICENSE.txt`
|
||||||
|
- Added built-in module `toml` and corresponding `LICENSE.txt`
|
||||||
|
|
||||||
## 20211025 V 0.6.0
|
## 20211025 V 0.6.0
|
||||||
|
|
||||||
|
27
libs/toml/LICENSE.txt
Normal file
27
libs/toml/LICENSE.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright 2013-2019 William Pearson
|
||||||
|
Copyright 2015-2016 Julien Enselme
|
||||||
|
Copyright 2016 Google Inc.
|
||||||
|
Copyright 2017 Samuel Vasko
|
||||||
|
Copyright 2017 Nate Prewitt
|
||||||
|
Copyright 2017 Jack Evans
|
||||||
|
Copyright 2019 Filippo Broggini
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
25
libs/toml/__init__.py
Normal file
25
libs/toml/__init__.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
"""Python module which parses and emits TOML.
|
||||||
|
|
||||||
|
Released under the MIT license.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from toml import encoder
|
||||||
|
from toml import decoder
|
||||||
|
|
||||||
|
__version__ = "0.10.2"
|
||||||
|
_spec_ = "0.5.0"
|
||||||
|
|
||||||
|
load = decoder.load
|
||||||
|
loads = decoder.loads
|
||||||
|
TomlDecoder = decoder.TomlDecoder
|
||||||
|
TomlDecodeError = decoder.TomlDecodeError
|
||||||
|
TomlPreserveCommentDecoder = decoder.TomlPreserveCommentDecoder
|
||||||
|
|
||||||
|
dump = encoder.dump
|
||||||
|
dumps = encoder.dumps
|
||||||
|
TomlEncoder = encoder.TomlEncoder
|
||||||
|
TomlArraySeparatorEncoder = encoder.TomlArraySeparatorEncoder
|
||||||
|
TomlPreserveInlineDictEncoder = encoder.TomlPreserveInlineDictEncoder
|
||||||
|
TomlNumpyEncoder = encoder.TomlNumpyEncoder
|
||||||
|
TomlPreserveCommentEncoder = encoder.TomlPreserveCommentEncoder
|
||||||
|
TomlPathlibEncoder = encoder.TomlPathlibEncoder
|
1057
libs/toml/decoder.py
Normal file
1057
libs/toml/decoder.py
Normal file
File diff suppressed because it is too large
Load Diff
304
libs/toml/encoder.py
Normal file
304
libs/toml/encoder.py
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
import datetime
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
from toml.decoder import InlineTableDict
|
||||||
|
|
||||||
|
if sys.version_info >= (3,):
|
||||||
|
unicode = str
|
||||||
|
|
||||||
|
|
||||||
|
def dump(o, f, encoder=None):
|
||||||
|
"""Writes out dict as toml to a file
|
||||||
|
|
||||||
|
Args:
|
||||||
|
o: Object to dump into toml
|
||||||
|
f: File descriptor where the toml should be stored
|
||||||
|
encoder: The ``TomlEncoder`` to use for constructing the output string
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
String containing the toml corresponding to dictionary
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
TypeError: When anything other than file descriptor is passed
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not f.write:
|
||||||
|
raise TypeError("You can only dump an object to a file descriptor")
|
||||||
|
d = dumps(o, encoder=encoder)
|
||||||
|
f.write(d)
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def dumps(o, encoder=None):
|
||||||
|
"""Stringifies input dict as toml
|
||||||
|
|
||||||
|
Args:
|
||||||
|
o: Object to dump into toml
|
||||||
|
encoder: The ``TomlEncoder`` to use for constructing the output string
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
String containing the toml corresponding to dict
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```python
|
||||||
|
>>> import toml
|
||||||
|
>>> output = {
|
||||||
|
... 'a': "I'm a string",
|
||||||
|
... 'b': ["I'm", "a", "list"],
|
||||||
|
... 'c': 2400
|
||||||
|
... }
|
||||||
|
>>> toml.dumps(output)
|
||||||
|
'a = "I\'m a string"\nb = [ "I\'m", "a", "list",]\nc = 2400\n'
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
|
||||||
|
retval = ""
|
||||||
|
if encoder is None:
|
||||||
|
encoder = TomlEncoder(o.__class__)
|
||||||
|
addtoretval, sections = encoder.dump_sections(o, "")
|
||||||
|
retval += addtoretval
|
||||||
|
outer_objs = [id(o)]
|
||||||
|
while sections:
|
||||||
|
section_ids = [id(section) for section in sections.values()]
|
||||||
|
for outer_obj in outer_objs:
|
||||||
|
if outer_obj in section_ids:
|
||||||
|
raise ValueError("Circular reference detected")
|
||||||
|
outer_objs += section_ids
|
||||||
|
newsections = encoder.get_empty_table()
|
||||||
|
for section in sections:
|
||||||
|
addtoretval, addtosections = encoder.dump_sections(
|
||||||
|
sections[section], section)
|
||||||
|
|
||||||
|
if addtoretval or (not addtoretval and not addtosections):
|
||||||
|
if retval and retval[-2:] != "\n\n":
|
||||||
|
retval += "\n"
|
||||||
|
retval += "[" + section + "]\n"
|
||||||
|
if addtoretval:
|
||||||
|
retval += addtoretval
|
||||||
|
for s in addtosections:
|
||||||
|
newsections[section + "." + s] = addtosections[s]
|
||||||
|
sections = newsections
|
||||||
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
def _dump_str(v):
|
||||||
|
if sys.version_info < (3,) and hasattr(v, 'decode') and isinstance(v, str):
|
||||||
|
v = v.decode('utf-8')
|
||||||
|
v = "%r" % v
|
||||||
|
if v[0] == 'u':
|
||||||
|
v = v[1:]
|
||||||
|
singlequote = v.startswith("'")
|
||||||
|
if singlequote or v.startswith('"'):
|
||||||
|
v = v[1:-1]
|
||||||
|
if singlequote:
|
||||||
|
v = v.replace("\\'", "'")
|
||||||
|
v = v.replace('"', '\\"')
|
||||||
|
v = v.split("\\x")
|
||||||
|
while len(v) > 1:
|
||||||
|
i = -1
|
||||||
|
if not v[0]:
|
||||||
|
v = v[1:]
|
||||||
|
v[0] = v[0].replace("\\\\", "\\")
|
||||||
|
# No, I don't know why != works and == breaks
|
||||||
|
joinx = v[0][i] != "\\"
|
||||||
|
while v[0][:i] and v[0][i] == "\\":
|
||||||
|
joinx = not joinx
|
||||||
|
i -= 1
|
||||||
|
if joinx:
|
||||||
|
joiner = "x"
|
||||||
|
else:
|
||||||
|
joiner = "u00"
|
||||||
|
v = [v[0] + joiner + v[1]] + v[2:]
|
||||||
|
return unicode('"' + v[0] + '"')
|
||||||
|
|
||||||
|
|
||||||
|
def _dump_float(v):
|
||||||
|
return "{}".format(v).replace("e+0", "e+").replace("e-0", "e-")
|
||||||
|
|
||||||
|
|
||||||
|
def _dump_time(v):
|
||||||
|
utcoffset = v.utcoffset()
|
||||||
|
if utcoffset is None:
|
||||||
|
return v.isoformat()
|
||||||
|
# The TOML norm specifies that it's local time thus we drop the offset
|
||||||
|
return v.isoformat()[:-6]
|
||||||
|
|
||||||
|
|
||||||
|
class TomlEncoder(object):
|
||||||
|
|
||||||
|
def __init__(self, _dict=dict, preserve=False):
|
||||||
|
self._dict = _dict
|
||||||
|
self.preserve = preserve
|
||||||
|
self.dump_funcs = {
|
||||||
|
str: _dump_str,
|
||||||
|
unicode: _dump_str,
|
||||||
|
list: self.dump_list,
|
||||||
|
bool: lambda v: unicode(v).lower(),
|
||||||
|
int: lambda v: v,
|
||||||
|
float: _dump_float,
|
||||||
|
Decimal: _dump_float,
|
||||||
|
datetime.datetime: lambda v: v.isoformat().replace('+00:00', 'Z'),
|
||||||
|
datetime.time: _dump_time,
|
||||||
|
datetime.date: lambda v: v.isoformat()
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_empty_table(self):
|
||||||
|
return self._dict()
|
||||||
|
|
||||||
|
def dump_list(self, v):
|
||||||
|
retval = "["
|
||||||
|
for u in v:
|
||||||
|
retval += " " + unicode(self.dump_value(u)) + ","
|
||||||
|
retval += "]"
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def dump_inline_table(self, section):
|
||||||
|
"""Preserve inline table in its compact syntax instead of expanding
|
||||||
|
into subsection.
|
||||||
|
|
||||||
|
https://github.com/toml-lang/toml#user-content-inline-table
|
||||||
|
"""
|
||||||
|
retval = ""
|
||||||
|
if isinstance(section, dict):
|
||||||
|
val_list = []
|
||||||
|
for k, v in section.items():
|
||||||
|
val = self.dump_inline_table(v)
|
||||||
|
val_list.append(k + " = " + val)
|
||||||
|
retval += "{ " + ", ".join(val_list) + " }\n"
|
||||||
|
return retval
|
||||||
|
else:
|
||||||
|
return unicode(self.dump_value(section))
|
||||||
|
|
||||||
|
def dump_value(self, v):
|
||||||
|
# Lookup function corresponding to v's type
|
||||||
|
dump_fn = self.dump_funcs.get(type(v))
|
||||||
|
if dump_fn is None and hasattr(v, '__iter__'):
|
||||||
|
dump_fn = self.dump_funcs[list]
|
||||||
|
# Evaluate function (if it exists) else return v
|
||||||
|
return dump_fn(v) if dump_fn is not None else self.dump_funcs[str](v)
|
||||||
|
|
||||||
|
def dump_sections(self, o, sup):
|
||||||
|
retstr = ""
|
||||||
|
if sup != "" and sup[-1] != ".":
|
||||||
|
sup += '.'
|
||||||
|
retdict = self._dict()
|
||||||
|
arraystr = ""
|
||||||
|
for section in o:
|
||||||
|
section = unicode(section)
|
||||||
|
qsection = section
|
||||||
|
if not re.match(r'^[A-Za-z0-9_-]+$', section):
|
||||||
|
qsection = _dump_str(section)
|
||||||
|
if not isinstance(o[section], dict):
|
||||||
|
arrayoftables = False
|
||||||
|
if isinstance(o[section], list):
|
||||||
|
for a in o[section]:
|
||||||
|
if isinstance(a, dict):
|
||||||
|
arrayoftables = True
|
||||||
|
if arrayoftables:
|
||||||
|
for a in o[section]:
|
||||||
|
arraytabstr = "\n"
|
||||||
|
arraystr += "[[" + sup + qsection + "]]\n"
|
||||||
|
s, d = self.dump_sections(a, sup + qsection)
|
||||||
|
if s:
|
||||||
|
if s[0] == "[":
|
||||||
|
arraytabstr += s
|
||||||
|
else:
|
||||||
|
arraystr += s
|
||||||
|
while d:
|
||||||
|
newd = self._dict()
|
||||||
|
for dsec in d:
|
||||||
|
s1, d1 = self.dump_sections(d[dsec], sup +
|
||||||
|
qsection + "." +
|
||||||
|
dsec)
|
||||||
|
if s1:
|
||||||
|
arraytabstr += ("[" + sup + qsection +
|
||||||
|
"." + dsec + "]\n")
|
||||||
|
arraytabstr += s1
|
||||||
|
for s1 in d1:
|
||||||
|
newd[dsec + "." + s1] = d1[s1]
|
||||||
|
d = newd
|
||||||
|
arraystr += arraytabstr
|
||||||
|
else:
|
||||||
|
if o[section] is not None:
|
||||||
|
retstr += (qsection + " = " +
|
||||||
|
unicode(self.dump_value(o[section])) + '\n')
|
||||||
|
elif self.preserve and isinstance(o[section], InlineTableDict):
|
||||||
|
retstr += (qsection + " = " +
|
||||||
|
self.dump_inline_table(o[section]))
|
||||||
|
else:
|
||||||
|
retdict[qsection] = o[section]
|
||||||
|
retstr += arraystr
|
||||||
|
return (retstr, retdict)
|
||||||
|
|
||||||
|
|
||||||
|
class TomlPreserveInlineDictEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def __init__(self, _dict=dict):
|
||||||
|
super(TomlPreserveInlineDictEncoder, self).__init__(_dict, True)
|
||||||
|
|
||||||
|
|
||||||
|
class TomlArraySeparatorEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def __init__(self, _dict=dict, preserve=False, separator=","):
|
||||||
|
super(TomlArraySeparatorEncoder, self).__init__(_dict, preserve)
|
||||||
|
if separator.strip() == "":
|
||||||
|
separator = "," + separator
|
||||||
|
elif separator.strip(' \t\n\r,'):
|
||||||
|
raise ValueError("Invalid separator for arrays")
|
||||||
|
self.separator = separator
|
||||||
|
|
||||||
|
def dump_list(self, v):
|
||||||
|
t = []
|
||||||
|
retval = "["
|
||||||
|
for u in v:
|
||||||
|
t.append(self.dump_value(u))
|
||||||
|
while t != []:
|
||||||
|
s = []
|
||||||
|
for u in t:
|
||||||
|
if isinstance(u, list):
|
||||||
|
for r in u:
|
||||||
|
s.append(r)
|
||||||
|
else:
|
||||||
|
retval += " " + unicode(u) + self.separator
|
||||||
|
t = s
|
||||||
|
retval += "]"
|
||||||
|
return retval
|
||||||
|
|
||||||
|
|
||||||
|
class TomlNumpyEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def __init__(self, _dict=dict, preserve=False):
|
||||||
|
import numpy as np
|
||||||
|
super(TomlNumpyEncoder, self).__init__(_dict, preserve)
|
||||||
|
self.dump_funcs[np.float16] = _dump_float
|
||||||
|
self.dump_funcs[np.float32] = _dump_float
|
||||||
|
self.dump_funcs[np.float64] = _dump_float
|
||||||
|
self.dump_funcs[np.int16] = self._dump_int
|
||||||
|
self.dump_funcs[np.int32] = self._dump_int
|
||||||
|
self.dump_funcs[np.int64] = self._dump_int
|
||||||
|
|
||||||
|
def _dump_int(self, v):
|
||||||
|
return "{}".format(int(v))
|
||||||
|
|
||||||
|
|
||||||
|
class TomlPreserveCommentEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def __init__(self, _dict=dict, preserve=False):
|
||||||
|
from toml.decoder import CommentValue
|
||||||
|
super(TomlPreserveCommentEncoder, self).__init__(_dict, preserve)
|
||||||
|
self.dump_funcs[CommentValue] = lambda v: v.dump(self.dump_value)
|
||||||
|
|
||||||
|
|
||||||
|
class TomlPathlibEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def _dump_pathlib_path(self, v):
|
||||||
|
return _dump_str(str(v))
|
||||||
|
|
||||||
|
def dump_value(self, v):
|
||||||
|
if (3, 4) <= sys.version_info:
|
||||||
|
import pathlib
|
||||||
|
if isinstance(v, pathlib.PurePath):
|
||||||
|
v = str(v)
|
||||||
|
return super(TomlPathlibEncoder, self).dump_value(v)
|
15
libs/toml/ordered.py
Normal file
15
libs/toml/ordered.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from collections import OrderedDict
|
||||||
|
from toml import TomlEncoder
|
||||||
|
from toml import TomlDecoder
|
||||||
|
|
||||||
|
|
||||||
|
class TomlOrderedDecoder(TomlDecoder):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(self.__class__, self).__init__(_dict=OrderedDict)
|
||||||
|
|
||||||
|
|
||||||
|
class TomlOrderedEncoder(TomlEncoder):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(self.__class__, self).__init__(_dict=OrderedDict)
|
24
libs/toml/tz.py
Normal file
24
libs/toml/tz.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from datetime import tzinfo, timedelta
|
||||||
|
|
||||||
|
|
||||||
|
class TomlTz(tzinfo):
|
||||||
|
def __init__(self, toml_offset):
|
||||||
|
if toml_offset == "Z":
|
||||||
|
self._raw_offset = "+00:00"
|
||||||
|
else:
|
||||||
|
self._raw_offset = toml_offset
|
||||||
|
self._sign = -1 if self._raw_offset[0] == '-' else 1
|
||||||
|
self._hours = int(self._raw_offset[1:3])
|
||||||
|
self._minutes = int(self._raw_offset[4:6])
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
return self.__class__(self._raw_offset)
|
||||||
|
|
||||||
|
def tzname(self, dt):
|
||||||
|
return "UTC" + self._raw_offset
|
||||||
|
|
||||||
|
def utcoffset(self, dt):
|
||||||
|
return self._sign * timedelta(hours=self._hours, minutes=self._minutes)
|
||||||
|
|
||||||
|
def dst(self, dt):
|
||||||
|
return timedelta(0)
|
Loading…
Reference in New Issue
Block a user