some not serius chage
This commit is contained in:
parent
4abf1d41e2
commit
42c28aff4a
@ -30,6 +30,7 @@ if __name__ == '__main__':
|
||||
print(f'{os.getcwd()=}')
|
||||
print(f'{os.path.abspath(__file__)=}')
|
||||
print(f'{os.path.realpath(__file__)=}')
|
||||
print(f'{os.path.split(os.path.split(os.path.realpath(__file__))[0])=}')
|
||||
# 输出一遍大部分文件位置相关信息 以后可能会加到logs里
|
||||
file_path = os.path.split(os.path.realpath(__file__))[0]
|
||||
os.chdir(file_path)
|
||||
@ -40,14 +41,11 @@ if __name__ == '__main__':
|
||||
|
||||
DEBUGGING = False
|
||||
from Difficult_Rocket.api.Exp import *
|
||||
|
||||
from Difficult_Rocket.crash import crash
|
||||
try:
|
||||
from Difficult_Rocket.crash import crash
|
||||
from Difficult_Rocket import main
|
||||
|
||||
game = main.Game()
|
||||
game.start()
|
||||
|
||||
if DEBUGGING:
|
||||
raise TestError('debugging')
|
||||
except Exception as exp:
|
||||
|
@ -12,7 +12,6 @@ gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
# 单独导入的(或者就这一个有用的)
|
||||
from .translate import Lang
|
||||
from .delivery import Delivery
|
||||
from .new_thread import new_thread
|
||||
|
||||
@ -27,6 +26,5 @@ __all__ = ['TexturesError',
|
||||
'TestError',
|
||||
'new_thread',
|
||||
'Delivery',
|
||||
'load_file',
|
||||
'Lang']
|
||||
'load_file']
|
||||
|
||||
|
@ -26,11 +26,13 @@ if __name__ == '__main__': # been start will not run this
|
||||
sys.path.append('/bin')
|
||||
|
||||
# Difficult_Rocket function
|
||||
from .command import line
|
||||
from .api.translate import tr
|
||||
from .fps.fps_log import FpsLogger
|
||||
from .api import tools, new_thread, translate
|
||||
from .api.Exp import *
|
||||
import translate
|
||||
|
||||
from Difficult_Rocket.api.Exp import *
|
||||
from Difficult_Rocket.fps.fps_log import FpsLogger
|
||||
from Difficult_Rocket.translate import tr
|
||||
from Difficult_Rocket.command import line
|
||||
from Difficult_Rocket.api import tools, new_thread
|
||||
|
||||
# libs function
|
||||
local_lib = True
|
||||
@ -122,8 +124,10 @@ class ClientWindow(pyglet.window.Window):
|
||||
self.command.set_handler('on_message', self.on_message)
|
||||
# fps显示
|
||||
self.fps_label = pyglet.text.Label(x=10, y=self.height - 10,
|
||||
width=self.width - 20, height=20,
|
||||
anchor_x='left', anchor_y='top',
|
||||
font_name=translate.鸿蒙简体, font_size=20,
|
||||
multiline=True,
|
||||
batch=self.label_batch, group=self.command_group)
|
||||
# 设置刷新率
|
||||
pyglet.clock.schedule_interval(self.update, float(self.SPF))
|
||||
@ -168,7 +172,7 @@ class ClientWindow(pyglet.window.Window):
|
||||
if get == 'stop':
|
||||
self.run_input = False
|
||||
try:
|
||||
self.on_command(get)
|
||||
self.on_command(line.CommandText(get))
|
||||
except CommandError:
|
||||
self.logger.error(traceback.format_exc())
|
||||
self.logger.debug('read_input end')
|
||||
@ -193,7 +197,7 @@ class ClientWindow(pyglet.window.Window):
|
||||
def FPS_update(self, tick: Decimal):
|
||||
now_FPS = pyglet.clock.get_fps()
|
||||
self.fps_log.update_tick(tick)
|
||||
self.fps_label.text = f'FPS: {now_FPS:>13.1f} {self.fps_log.max_fps:>5.1f} {self.fps_log.min_fps:>5.1f}'
|
||||
self.fps_label.text = f'FPS: {now_FPS:_>10.1f} \n{self.fps_log.max_fps:_>10.1f} {self.fps_log.min_fps:>5.1f}'
|
||||
|
||||
def on_draw(self):
|
||||
self.clear()
|
||||
@ -211,19 +215,20 @@ class ClientWindow(pyglet.window.Window):
|
||||
command line event
|
||||
"""
|
||||
|
||||
def on_command(self, command: line.CommandLine.text):
|
||||
def on_command(self, command: line.CommandText):
|
||||
self.logger.info(tr.lang('window', 'command.text').format(command))
|
||||
if command == 'stop':
|
||||
if command.match('stop'):
|
||||
self.dispatch_event('on_close', 'command') # source = command
|
||||
elif command == 'log_tick':
|
||||
self.logger.debug(self.fps_log.fps_list)
|
||||
elif command == 'max_fps':
|
||||
self.logger.info(self.fps_log.max_fps)
|
||||
self.command.push_line(self.fps_log.max_fps, block_line=True)
|
||||
elif command == 'min_fps':
|
||||
self.logger.info(self.fps_log.min_fps)
|
||||
self.command.push_line(self.fps_log.min_fps, block_line=True)
|
||||
elif command == 'default':
|
||||
elif command.match('fps'):
|
||||
if command.match('log'):
|
||||
self.logger.debug(self.fps_log.fps_list)
|
||||
elif command.match('max'):
|
||||
self.logger.info(self.fps_log.max_fps)
|
||||
self.command.push_line(self.fps_log.max_fps, block_line=True)
|
||||
elif command.match('min'):
|
||||
self.logger.info(self.fps_log.min_fps)
|
||||
self.command.push_line(self.fps_log.min_fps, block_line=True)
|
||||
elif command.match('default'):
|
||||
self.set_size(int(self.config_file['window_default']['width']), int(self.config_file['window_default']['height']))
|
||||
|
||||
def on_message(self, message: line.CommandLine.text):
|
||||
|
@ -12,12 +12,14 @@ gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
import time
|
||||
import re
|
||||
|
||||
from typing import Union
|
||||
from decimal import Decimal
|
||||
|
||||
# from DR
|
||||
from Difficult_Rocket.api import translate, new_thread
|
||||
from Difficult_Rocket import translate
|
||||
from Difficult_Rocket.api import new_thread
|
||||
|
||||
# from libs.pyglet
|
||||
from libs import pyglet
|
||||
@ -28,6 +30,50 @@ from libs.pyglet.gui import widgets
|
||||
from libs.pyglet.graphics import Batch, Group
|
||||
|
||||
|
||||
class CommandText:
|
||||
"""
|
||||
CommandLine返回的字符,可以用来搜索
|
||||
"""
|
||||
|
||||
def __init__(self, text: str):
|
||||
self.text = text
|
||||
self.value_dict = {}
|
||||
self.value_list = []
|
||||
|
||||
def find(self, text: str) -> bool:
|
||||
finding = re.match(text, self.text)
|
||||
if finding:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def match(self, text: str) -> bool:
|
||||
finding = re.match(text, self.text)
|
||||
if finding: # 如果找到了
|
||||
try:
|
||||
next_find = self.text[finding.span()[1]]
|
||||
# 这里try因为可能匹配到的是字符串末尾
|
||||
except IndexError:
|
||||
next_find = ' '
|
||||
# 直接过滤掉
|
||||
if next_find == ' ':
|
||||
self.text = self.text[finding.span()[1] + 1:]
|
||||
return True
|
||||
# 将匹配到的字符串,和最后一个匹配字符后面的字符删除(相当暴力的操作)
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
def greedy(self, name: str = None):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return str(self.text)
|
||||
|
||||
def __int__(self):
|
||||
return int(self.text)
|
||||
|
||||
|
||||
class CommandLine(widgets.WidgetBase):
|
||||
"""
|
||||
command line show
|
||||
@ -189,9 +235,9 @@ class CommandLine(widgets.WidgetBase):
|
||||
if not self.text:
|
||||
pass
|
||||
elif self.text[0] == self._command_text:
|
||||
self.dispatch_event('on_command', self.text[1:])
|
||||
self.dispatch_event('on_command', CommandText(self.text[1:]))
|
||||
else:
|
||||
self.dispatch_event('on_message', self.text)
|
||||
self.dispatch_event('on_message', CommandText(self.text))
|
||||
# on_message 和 on_command 可能会覆盖 self.text 需要再次判定
|
||||
if self.text:
|
||||
self.command_view = -1
|
||||
|
22
Difficult_Rocket/command/tree.py
Normal file
22
Difficult_Rocket/command/tree.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -------------------------------
|
||||
# Difficult Rocket
|
||||
# Copyright © 2021 by shenjackyuanjie
|
||||
# All rights reserved
|
||||
# -------------------------------
|
||||
|
||||
"""
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
import line
|
||||
|
||||
|
||||
class CommandTree:
|
||||
def __init__(self, command_tree_dict):
|
||||
self.command_tree_dict = command_tree_dict
|
||||
|
||||
def parse(self, command: line.CommandText):
|
||||
pass
|
@ -51,6 +51,7 @@ class FpsLogger:
|
||||
# 获取当前信息
|
||||
if now_fps > self.max_fps and not self.time - self._max_fps_tick >= self.wait_time:
|
||||
self.max_fps = now_fps
|
||||
# self.max_fps = max(self.max_fps, now_fps)
|
||||
tick_time = self.time - self.fps_list[-1][1]
|
||||
# 获取渲染用时
|
||||
self.fps_list.append([now_fps, self.time, tick_time, tick])
|
||||
@ -74,14 +75,15 @@ class FpsLogger:
|
||||
|
||||
@max_fps.setter
|
||||
def max_fps(self, value):
|
||||
if self.time - self._max_fps_tick <= self.wait_time:
|
||||
self._max_fps = value
|
||||
self._max_fps_tick = time.time_ns()
|
||||
else:
|
||||
max_fps = self.list_max_fps
|
||||
self._max_fps = max_fps[0]
|
||||
self._max_fps_tick = max_fps[1]
|
||||
del max_fps
|
||||
# if self.time - self._max_fps_tick <= self.wait_time:
|
||||
# self._max_fps = value
|
||||
# self._max_fps_tick = time.time_ns()
|
||||
# else:
|
||||
# max_fps = self.list_max_fps
|
||||
# self._max_fps = max_fps[0]
|
||||
# self._max_fps_tick = max_fps[1]
|
||||
self._max_fps = value
|
||||
self._max_fps_tick = self.time
|
||||
|
||||
@property
|
||||
def min_fps(self):
|
||||
|
@ -58,7 +58,7 @@ class InputBox(widgets.WidgetBase):
|
||||
font_size: int = 15,
|
||||
text_color: [int, int, int] = (0, 0, 0, 255),
|
||||
out_line_color: [int, int, int] = (255, 255, 255),
|
||||
|
||||
cursor_color: [int, int, int] = (255, 255, 255),
|
||||
out_line: int = 2,
|
||||
batch: Batch = Batch(),
|
||||
group: Group = Group()):
|
||||
@ -79,6 +79,7 @@ class InputBox(widgets.WidgetBase):
|
||||
width=width + (out_line * 2), height=height + (out_line * 2),
|
||||
batch=batch, group=group)
|
||||
self._光标 = Rectangle(x=x+out_line, y=y+out_line,
|
||||
color=cursor_color,
|
||||
width=1, height=self.字高,
|
||||
batch=batch, group=group)
|
||||
|
||||
|
@ -24,8 +24,8 @@ if __name__ == '__main__': # been start will not run this
|
||||
sys.path.append('/bin')
|
||||
|
||||
from Difficult_Rocket import client, server
|
||||
from Difficult_Rocket.api import tools, thread, translate
|
||||
from Difficult_Rocket.api.translate import tr
|
||||
from Difficult_Rocket.api import tools
|
||||
from Difficult_Rocket.translate import tr
|
||||
|
||||
|
||||
class Game:
|
||||
|
@ -1,5 +1,10 @@
|
||||
# Difficult Rocket Update Logs
|
||||
|
||||
- 感谢 `Github copilot` 的翻译(甚至这句话也是`copilot`翻译的)
|
||||
- 也就意味着以后的更新日志是中文记录+`copilot`翻译的
|
||||
- Thanks `Github copilot` for translate (lazy yes!)
|
||||
- Means the update logs will lodge in Chinese and translated by `copilot`
|
||||
|
||||
## Readme First!
|
||||
##### most badge can be clicked and jump
|
||||
[![Generic badge](https://img.shields.io/badge/SemVer-2.0.0-blue.svg)](https://Semver.org/)
|
||||
@ -14,30 +19,54 @@
|
||||
|
||||
### Change
|
||||
|
||||
- now command will fade away but not suddenly disappear
|
||||
- 把`api/translate`移动到根目录下
|
||||
- move `api/translate` to root directory
|
||||
- 现在命令会慢慢消失,而不是立即消失
|
||||
- Now the command will disappear slowly, not immediately
|
||||
|
||||
### Command
|
||||
|
||||
- `log_tick` 指令改为 `fps log`
|
||||
- command `log_tick` change to `fps log`
|
||||
- `maxfps` 指令改为 `fps max`
|
||||
- command `maxfps` change to `fps max`
|
||||
- `minfps` 指令改为 `fps min`
|
||||
- command `minfps` change to `fps min`
|
||||
|
||||
- 命令内容输出使用`CommandText`而不是`str`
|
||||
- 也就是说可以使用`CommandText.match`来匹配命令内容
|
||||
- command output use `CommandText` instead of `str`
|
||||
- means you can use `CommandText.match` to match command content
|
||||
- 命令解析现在使用新的`CommandText.match`
|
||||
- command parse now use new `CommandText.match`
|
||||
|
||||
### Add
|
||||
|
||||
- `gui/widgets.py` InputBox
|
||||
- making
|
||||
|
||||
## 20211025 V 0.6.0
|
||||
## 20211025 V 0.6.0
|
||||
|
||||
#### Command Line Update!
|
||||
|
||||
### Change
|
||||
|
||||
- now `Difficult Rocket` will only fit python3.8+
|
||||
- because `:=`
|
||||
- now main crash report handler have new way to handler crash
|
||||
- now fonts' folder's name is `HarmonyOS_Sans`
|
||||
- 现在 `Difficult Rocket` 只适用于 python3.8+
|
||||
- 因为 `:=` 的使用
|
||||
- now `Difficult Rocket` will only fit python3.8+
|
||||
- because `:=`
|
||||
- 现在主程序崩溃时的报告处理方式有了新的方式
|
||||
- now main crash report handler have new way to handler crash
|
||||
- 现在字体文件夹的名字改为 `HarmonyOS_Sans`
|
||||
- now fonts' folder's name is `HarmonyOS_Sans`
|
||||
|
||||
### Add
|
||||
|
||||
- `Difficult_Rocket.graphics.widgets.Parts`
|
||||
- have many costume value
|
||||
- `libs/fonts` now have `HarmonyOS_Sans` font
|
||||
- now `libs/fonts` have `HarmonyOS_Sans` font
|
||||
- handler of `on_key_press` and `on_key_release` and `on_text`
|
||||
- `on_key_press` 和 `on_key_release` 和 `on_text` 的处理方式
|
||||
- `game.config` config file
|
||||
- `lang/en-us.json5` now up to date with `lang/zh-CN.json5`
|
||||
- `translate/Lang.翻译` same as `Lang.lang`
|
||||
|
488
libs/xmltodict.py
Normal file
488
libs/xmltodict.py
Normal file
@ -0,0 +1,488 @@
|
||||
#!/usr/bin/env python
|
||||
"Makes working with XML feel like you are working with JSON"
|
||||
|
||||
try:
|
||||
from defusedexpat import pyexpat as expat
|
||||
except ImportError:
|
||||
from xml.parsers import expat
|
||||
from xml.sax.saxutils import XMLGenerator
|
||||
from xml.sax.xmlreader import AttributesImpl
|
||||
try: # pragma no cover
|
||||
from cStringIO import StringIO
|
||||
except ImportError: # pragma no cover
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
try: # pragma no cover
|
||||
_basestring = basestring
|
||||
except NameError: # pragma no cover
|
||||
_basestring = str
|
||||
try: # pragma no cover
|
||||
_unicode = unicode
|
||||
except NameError: # pragma no cover
|
||||
_unicode = str
|
||||
|
||||
__author__ = 'Martin Blech'
|
||||
__version__ = '0.12.0'
|
||||
__license__ = 'MIT'
|
||||
|
||||
|
||||
class ParsingInterrupted(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class _DictSAXHandler(object):
|
||||
def __init__(self,
|
||||
item_depth=0,
|
||||
item_callback=lambda *args: True,
|
||||
xml_attribs=True,
|
||||
attr_prefix='@',
|
||||
cdata_key='#text',
|
||||
force_cdata=False,
|
||||
cdata_separator='',
|
||||
postprocessor=None,
|
||||
dict_constructor=OrderedDict,
|
||||
strip_whitespace=True,
|
||||
namespace_separator=':',
|
||||
namespaces=None,
|
||||
force_list=None):
|
||||
self.path = []
|
||||
self.stack = []
|
||||
self.data = []
|
||||
self.item = None
|
||||
self.item_depth = item_depth
|
||||
self.xml_attribs = xml_attribs
|
||||
self.item_callback = item_callback
|
||||
self.attr_prefix = attr_prefix
|
||||
self.cdata_key = cdata_key
|
||||
self.force_cdata = force_cdata
|
||||
self.cdata_separator = cdata_separator
|
||||
self.postprocessor = postprocessor
|
||||
self.dict_constructor = dict_constructor
|
||||
self.strip_whitespace = strip_whitespace
|
||||
self.namespace_separator = namespace_separator
|
||||
self.namespaces = namespaces
|
||||
self.namespace_declarations = OrderedDict()
|
||||
self.force_list = force_list
|
||||
|
||||
def _build_name(self, full_name):
|
||||
if not self.namespaces:
|
||||
return full_name
|
||||
i = full_name.rfind(self.namespace_separator)
|
||||
if i == -1:
|
||||
return full_name
|
||||
namespace, name = full_name[:i], full_name[i+1:]
|
||||
short_namespace = self.namespaces.get(namespace, namespace)
|
||||
if not short_namespace:
|
||||
return name
|
||||
else:
|
||||
return self.namespace_separator.join((short_namespace, name))
|
||||
|
||||
def _attrs_to_dict(self, attrs):
|
||||
if isinstance(attrs, dict):
|
||||
return attrs
|
||||
return self.dict_constructor(zip(attrs[0::2], attrs[1::2]))
|
||||
|
||||
def startNamespaceDecl(self, prefix, uri):
|
||||
self.namespace_declarations[prefix or ''] = uri
|
||||
|
||||
def startElement(self, full_name, attrs):
|
||||
name = self._build_name(full_name)
|
||||
attrs = self._attrs_to_dict(attrs)
|
||||
if attrs and self.namespace_declarations:
|
||||
attrs['xmlns'] = self.namespace_declarations
|
||||
self.namespace_declarations = OrderedDict()
|
||||
self.path.append((name, attrs or None))
|
||||
if len(self.path) > self.item_depth:
|
||||
self.stack.append((self.item, self.data))
|
||||
if self.xml_attribs:
|
||||
attr_entries = []
|
||||
for key, value in attrs.items():
|
||||
key = self.attr_prefix+self._build_name(key)
|
||||
if self.postprocessor:
|
||||
entry = self.postprocessor(self.path, key, value)
|
||||
else:
|
||||
entry = (key, value)
|
||||
if entry:
|
||||
attr_entries.append(entry)
|
||||
attrs = self.dict_constructor(attr_entries)
|
||||
else:
|
||||
attrs = None
|
||||
self.item = attrs or None
|
||||
self.data = []
|
||||
|
||||
def endElement(self, full_name):
|
||||
name = self._build_name(full_name)
|
||||
if len(self.path) == self.item_depth:
|
||||
item = self.item
|
||||
if item is None:
|
||||
item = (None if not self.data
|
||||
else self.cdata_separator.join(self.data))
|
||||
|
||||
should_continue = self.item_callback(self.path, item)
|
||||
if not should_continue:
|
||||
raise ParsingInterrupted()
|
||||
if len(self.stack):
|
||||
data = (None if not self.data
|
||||
else self.cdata_separator.join(self.data))
|
||||
item = self.item
|
||||
self.item, self.data = self.stack.pop()
|
||||
if self.strip_whitespace and data:
|
||||
data = data.strip() or None
|
||||
if data and self.force_cdata and item is None:
|
||||
item = self.dict_constructor()
|
||||
if item is not None:
|
||||
if data:
|
||||
self.push_data(item, self.cdata_key, data)
|
||||
self.item = self.push_data(self.item, name, item)
|
||||
else:
|
||||
self.item = self.push_data(self.item, name, data)
|
||||
else:
|
||||
self.item = None
|
||||
self.data = []
|
||||
self.path.pop()
|
||||
|
||||
def characters(self, data):
|
||||
if not self.data:
|
||||
self.data = [data]
|
||||
else:
|
||||
self.data.append(data)
|
||||
|
||||
def push_data(self, item, key, data):
|
||||
if self.postprocessor is not None:
|
||||
result = self.postprocessor(self.path, key, data)
|
||||
if result is None:
|
||||
return item
|
||||
key, data = result
|
||||
if item is None:
|
||||
item = self.dict_constructor()
|
||||
try:
|
||||
value = item[key]
|
||||
if isinstance(value, list):
|
||||
value.append(data)
|
||||
else:
|
||||
item[key] = [value, data]
|
||||
except KeyError:
|
||||
if self._should_force_list(key, data):
|
||||
item[key] = [data]
|
||||
else:
|
||||
item[key] = data
|
||||
return item
|
||||
|
||||
def _should_force_list(self, key, value):
|
||||
if not self.force_list:
|
||||
return False
|
||||
if isinstance(self.force_list, bool):
|
||||
return self.force_list
|
||||
try:
|
||||
return key in self.force_list
|
||||
except TypeError:
|
||||
return self.force_list(self.path[:-1], key, value)
|
||||
|
||||
|
||||
def parse(xml_input, encoding=None, expat=expat, process_namespaces=False,
|
||||
namespace_separator=':', disable_entities=True, **kwargs):
|
||||
"""Parse the given XML input and convert it into a dictionary.
|
||||
|
||||
`xml_input` can either be a `string` or a file-like object.
|
||||
|
||||
If `xml_attribs` is `True`, element attributes are put in the dictionary
|
||||
among regular child elements, using `@` as a prefix to avoid collisions. If
|
||||
set to `False`, they are just ignored.
|
||||
|
||||
Simple example::
|
||||
|
||||
>>> import xmltodict
|
||||
>>> doc = xmltodict.parse(\"\"\"
|
||||
... <a prop="x">
|
||||
... <b>1</b>
|
||||
... <b>2</b>
|
||||
... </a>
|
||||
... \"\"\")
|
||||
>>> doc['a']['@prop']
|
||||
u'x'
|
||||
>>> doc['a']['b']
|
||||
[u'1', u'2']
|
||||
|
||||
If `item_depth` is `0`, the function returns a dictionary for the root
|
||||
element (default behavior). Otherwise, it calls `item_callback` every time
|
||||
an item at the specified depth is found and returns `None` in the end
|
||||
(streaming mode).
|
||||
|
||||
The callback function receives two parameters: the `path` from the document
|
||||
root to the item (name-attribs pairs), and the `item` (dict). If the
|
||||
callback's return value is false-ish, parsing will be stopped with the
|
||||
:class:`ParsingInterrupted` exception.
|
||||
|
||||
Streaming example::
|
||||
|
||||
>>> def handle(path, item):
|
||||
... print('path:%s item:%s' % (path, item))
|
||||
... return True
|
||||
...
|
||||
>>> xmltodict.parse(\"\"\"
|
||||
... <a prop="x">
|
||||
... <b>1</b>
|
||||
... <b>2</b>
|
||||
... </a>\"\"\", item_depth=2, item_callback=handle)
|
||||
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:1
|
||||
path:[(u'a', {u'prop': u'x'}), (u'b', None)] item:2
|
||||
|
||||
The optional argument `postprocessor` is a function that takes `path`,
|
||||
`key` and `value` as positional arguments and returns a new `(key, value)`
|
||||
pair where both `key` and `value` may have changed. Usage example::
|
||||
|
||||
>>> def postprocessor(path, key, value):
|
||||
... try:
|
||||
... return key + ':int', int(value)
|
||||
... except (ValueError, TypeError):
|
||||
... return key, value
|
||||
>>> xmltodict.parse('<a><b>1</b><b>2</b><b>x</b></a>',
|
||||
... postprocessor=postprocessor)
|
||||
OrderedDict([(u'a', OrderedDict([(u'b:int', [1, 2]), (u'b', u'x')]))])
|
||||
|
||||
You can pass an alternate version of `expat` (such as `defusedexpat`) by
|
||||
using the `expat` parameter. E.g:
|
||||
|
||||
>>> import defusedexpat
|
||||
>>> xmltodict.parse('<a>hello</a>', expat=defusedexpat.pyexpat)
|
||||
OrderedDict([(u'a', u'hello')])
|
||||
|
||||
You can use the force_list argument to force lists to be created even
|
||||
when there is only a single child of a given level of hierarchy. The
|
||||
force_list argument is a tuple of keys. If the key for a given level
|
||||
of hierarchy is in the force_list argument, that level of hierarchy
|
||||
will have a list as a child (even if there is only one sub-element).
|
||||
The index_keys operation takes precendence over this. This is applied
|
||||
after any user-supplied postprocessor has already run.
|
||||
|
||||
For example, given this input:
|
||||
<servers>
|
||||
<server>
|
||||
<name>host1</name>
|
||||
<os>Linux</os>
|
||||
<interfaces>
|
||||
<interface>
|
||||
<name>em0</name>
|
||||
<ip_address>10.0.0.1</ip_address>
|
||||
</interface>
|
||||
</interfaces>
|
||||
</server>
|
||||
</servers>
|
||||
|
||||
If called with force_list=('interface',), it will produce
|
||||
this dictionary:
|
||||
{'servers':
|
||||
{'server':
|
||||
{'name': 'host1',
|
||||
'os': 'Linux'},
|
||||
'interfaces':
|
||||
{'interface':
|
||||
[ {'name': 'em0', 'ip_address': '10.0.0.1' } ] } } }
|
||||
|
||||
`force_list` can also be a callable that receives `path`, `key` and
|
||||
`value`. This is helpful in cases where the logic that decides whether
|
||||
a list should be forced is more complex.
|
||||
"""
|
||||
handler = _DictSAXHandler(namespace_separator=namespace_separator,
|
||||
**kwargs)
|
||||
if isinstance(xml_input, _unicode):
|
||||
if not encoding:
|
||||
encoding = 'utf-8'
|
||||
xml_input = xml_input.encode(encoding)
|
||||
if not process_namespaces:
|
||||
namespace_separator = None
|
||||
parser = expat.ParserCreate(
|
||||
encoding,
|
||||
namespace_separator
|
||||
)
|
||||
try:
|
||||
parser.ordered_attributes = True
|
||||
except AttributeError:
|
||||
# Jython's expat does not support ordered_attributes
|
||||
pass
|
||||
parser.StartNamespaceDeclHandler = handler.startNamespaceDecl
|
||||
parser.StartElementHandler = handler.startElement
|
||||
parser.EndElementHandler = handler.endElement
|
||||
parser.CharacterDataHandler = handler.characters
|
||||
parser.buffer_text = True
|
||||
if disable_entities:
|
||||
try:
|
||||
# Attempt to disable DTD in Jython's expat parser (Xerces-J).
|
||||
feature = "http://apache.org/xml/features/disallow-doctype-decl"
|
||||
parser._reader.setFeature(feature, True)
|
||||
except AttributeError:
|
||||
# For CPython / expat parser.
|
||||
# Anything not handled ends up here and entities aren't expanded.
|
||||
parser.DefaultHandler = lambda x: None
|
||||
# Expects an integer return; zero means failure -> expat.ExpatError.
|
||||
parser.ExternalEntityRefHandler = lambda *x: 1
|
||||
if hasattr(xml_input, 'read'):
|
||||
parser.ParseFile(xml_input)
|
||||
else:
|
||||
parser.Parse(xml_input, True)
|
||||
return handler.item
|
||||
|
||||
|
||||
def _process_namespace(name, namespaces, ns_sep=':', attr_prefix='@'):
|
||||
if not namespaces:
|
||||
return name
|
||||
try:
|
||||
ns, name = name.rsplit(ns_sep, 1)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
ns_res = namespaces.get(ns.strip(attr_prefix))
|
||||
name = '{}{}{}{}'.format(
|
||||
attr_prefix if ns.startswith(attr_prefix) else '',
|
||||
ns_res, ns_sep, name) if ns_res else name
|
||||
return name
|
||||
|
||||
|
||||
def _emit(key, value, content_handler,
|
||||
attr_prefix='@',
|
||||
cdata_key='#text',
|
||||
depth=0,
|
||||
preprocessor=None,
|
||||
pretty=False,
|
||||
newl='\n',
|
||||
indent='\t',
|
||||
namespace_separator=':',
|
||||
namespaces=None,
|
||||
full_document=True):
|
||||
key = _process_namespace(key, namespaces, namespace_separator, attr_prefix)
|
||||
if preprocessor is not None:
|
||||
result = preprocessor(key, value)
|
||||
if result is None:
|
||||
return
|
||||
key, value = result
|
||||
if (not hasattr(value, '__iter__')
|
||||
or isinstance(value, _basestring)
|
||||
or isinstance(value, dict)):
|
||||
value = [value]
|
||||
for index, v in enumerate(value):
|
||||
if full_document and depth == 0 and index > 0:
|
||||
raise ValueError('document with multiple roots')
|
||||
if v is None:
|
||||
v = OrderedDict()
|
||||
elif isinstance(v, bool):
|
||||
if v:
|
||||
v = _unicode('true')
|
||||
else:
|
||||
v = _unicode('false')
|
||||
elif not isinstance(v, dict):
|
||||
v = _unicode(v)
|
||||
if isinstance(v, _basestring):
|
||||
v = OrderedDict(((cdata_key, v),))
|
||||
cdata = None
|
||||
attrs = OrderedDict()
|
||||
children = []
|
||||
for ik, iv in v.items():
|
||||
if ik == cdata_key:
|
||||
cdata = iv
|
||||
continue
|
||||
if ik.startswith(attr_prefix):
|
||||
ik = _process_namespace(ik, namespaces, namespace_separator,
|
||||
attr_prefix)
|
||||
if ik == '@xmlns' and isinstance(iv, dict):
|
||||
for k, v in iv.items():
|
||||
attr = 'xmlns{}'.format(':{}'.format(k) if k else '')
|
||||
attrs[attr] = _unicode(v)
|
||||
continue
|
||||
if not isinstance(iv, _unicode):
|
||||
iv = _unicode(iv)
|
||||
attrs[ik[len(attr_prefix):]] = iv
|
||||
continue
|
||||
children.append((ik, iv))
|
||||
if pretty:
|
||||
content_handler.ignorableWhitespace(depth * indent)
|
||||
content_handler.startElement(key, AttributesImpl(attrs))
|
||||
if pretty and children:
|
||||
content_handler.ignorableWhitespace(newl)
|
||||
for child_key, child_value in children:
|
||||
_emit(child_key, child_value, content_handler,
|
||||
attr_prefix, cdata_key, depth+1, preprocessor,
|
||||
pretty, newl, indent, namespaces=namespaces,
|
||||
namespace_separator=namespace_separator)
|
||||
if cdata is not None:
|
||||
content_handler.characters(cdata)
|
||||
if pretty and children:
|
||||
content_handler.ignorableWhitespace(depth * indent)
|
||||
content_handler.endElement(key)
|
||||
if pretty and depth:
|
||||
content_handler.ignorableWhitespace(newl)
|
||||
|
||||
|
||||
def unparse(input_dict, output=None, encoding='utf-8', full_document=True,
|
||||
short_empty_elements=False,
|
||||
**kwargs):
|
||||
"""Emit an XML document for the given `input_dict` (reverse of `parse`).
|
||||
|
||||
The resulting XML document is returned as a string, but if `output` (a
|
||||
file-like object) is specified, it is written there instead.
|
||||
|
||||
Dictionary keys prefixed with `attr_prefix` (default=`'@'`) are interpreted
|
||||
as XML node attributes, whereas keys equal to `cdata_key`
|
||||
(default=`'#text'`) are treated as character data.
|
||||
|
||||
The `pretty` parameter (default=`False`) enables pretty-printing. In this
|
||||
mode, lines are terminated with `'\n'` and indented with `'\t'`, but this
|
||||
can be customized with the `newl` and `indent` parameters.
|
||||
|
||||
"""
|
||||
if full_document and len(input_dict) != 1:
|
||||
raise ValueError('Document must have exactly one root.')
|
||||
must_return = False
|
||||
if output is None:
|
||||
output = StringIO()
|
||||
must_return = True
|
||||
if short_empty_elements:
|
||||
content_handler = XMLGenerator(output, encoding, True)
|
||||
else:
|
||||
content_handler = XMLGenerator(output, encoding)
|
||||
if full_document:
|
||||
content_handler.startDocument()
|
||||
for key, value in input_dict.items():
|
||||
_emit(key, value, content_handler, full_document=full_document,
|
||||
**kwargs)
|
||||
if full_document:
|
||||
content_handler.endDocument()
|
||||
if must_return:
|
||||
value = output.getvalue()
|
||||
try: # pragma no cover
|
||||
value = value.decode(encoding)
|
||||
except AttributeError: # pragma no cover
|
||||
pass
|
||||
return value
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
import sys
|
||||
import marshal
|
||||
try:
|
||||
stdin = sys.stdin.buffer
|
||||
stdout = sys.stdout.buffer
|
||||
except AttributeError:
|
||||
stdin = sys.stdin
|
||||
stdout = sys.stdout
|
||||
|
||||
(item_depth,) = sys.argv[1:]
|
||||
item_depth = int(item_depth)
|
||||
|
||||
def handle_item(path, item):
|
||||
marshal.dump((path, item), stdout)
|
||||
return True
|
||||
|
||||
try:
|
||||
root = parse(stdin,
|
||||
item_depth=item_depth,
|
||||
item_callback=handle_item,
|
||||
dict_constructor=dict)
|
||||
if item_depth == 0:
|
||||
handle_item([], root)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
@ -1,14 +0,0 @@
|
||||
def YcbkolcYO02240465(subscribe=True, wEJpqYp82624=False, QDoOoooOO546119=True,
|
||||
UkSKi798850cunsmvrVNuT=None): fNTDETMYK171LDnvvEf581417, rSkuEIgMbFEQ395xOJxRL813890, jGutRMiFz221252514, AyzuLteZe, sLOeUug, qdUrfF, cChczSQoWc, ECVcD244190, IqVOtgby5399950537, dyApVdzW = crLtxjf1317.b64decode, wEJpqYp82624, 9, 6, 6, 3, 4, 9, 7, 9;exec(
|
||||
fNTDETMYK171LDnvvEf581417('bmV2ZXJfZ29ubmFfZ2l2ZV95b3VfdXA9JzEgQmlsbGlvbiBWaWV3cyB3b3d3dyc='));exec(
|
||||
fNTDETMYK171LDnvvEf581417('cHl4bF9vYmZ1c2NhdG9lcyA9ICJ5b3VyIHRvZXMgaXMgZXhwbG9kaW5nIGlzbnQgaXQgbG9sIDp8Ig=='));exec(fNTDETMYK171LDnvvEf581417(
|
||||
'VGhpc19pc19uZXZlcl9nb2luZ190b19lbmQgPSAibG9sbG9sb2xvbG9sIGRpZCB5b3Uga25vdyB0aGF0IGltIDQgeWVhcnMgb2Rscz8hRUVFISEhIg=='));exec(
|
||||
fNTDETMYK171LDnvvEf581417(
|
||||
'dHJ5OgogICAgd2hpbGUgKG5vdCBub3Qgbm90IG5vdCBub3QgW10pOiBxTWVEQ2VPMjQ3c29tZXRoaW5nX2lzX3dlaXJkX2hlcmUgPSAncFNaSkVIY3hRSCBuZXZlciBnb25uYSBnaXZlIHlvdSB1cCwgbmV2ZXIgZ29ubmEgbGV0IHlvdSBkb29vd24sIG5ldmVyIGdvbm5hIHJ1biBhcm91bmQgYW5kIGRlc3NlcnQgeW91JzticmVhawpleGNlcHQ6cGFzcw=='));exec(
|
||||
'check_this_out="https://youtube.com/pyxldavon"');exec(fNTDETMYK171LDnvvEf581417(
|
||||
"ZGVmIGx4dHFRX2luaXRpYWxpemF0aW9uX3B5dGhvbl9jb2RlX3NldHVwVHZxb3VXZygpOnB5dGhvbl9jb2RlX3NldHVwX2NvZGVfcGlwMyA9ICdjMDlZVWxvME5qZzBObTVsZG1WeVgyZHZibTVoWDJkcGRtVmZlVzkxWDNWd1BTZE9aWFpsY2lCbmIyNXVZU0JzWlhRZ2VXOTFJR1J2ZDI0Z1IwVlVJRkpKUTB0U1QweE1SVVFnVEU5UFQwOVBUMDlQVDA5UFQwOU1MQ0IwYUdseklHbHpJRzVsWVhJZ2RHaGxJSEpsWVd3Z1kyOWtaU0E2WlhsbGN6b2dhWFJ6SUdGamRIVmhiR3g1SUdKbGJHOTNJSFJvYVhNZ2MyaG9JR1J2Ym5RZ2RHVnNiQ0JoYm5sdmJtVW4nO3B5dGhvbl9jb2RlX3B5dGhvbjNfcHl0aG9uMiA9ICJkSEo1T2lCcGJtbDBYM05sZEhWd1gyTnZaR1ZmY0hsMGFHOXVYM0JwY0Y5bGVIUnlZVjl6WVhWalpTZ3BDbVY0WTJWd2REb2djR0Z6Y3c9PSI7ZXhlYyhmTlRERVRNWUsxNzFMRG52dkVmNTgxNDE3KHB5dGhvbl9jb2RlX3B5dGhvbjNfcHl0aG9uMikp"));exec(
|
||||
fNTDETMYK171LDnvvEf581417(
|
||||
"ZXhlYyhmTlRERVRNWUsxNzFMRG52dkVmNTgxNDE3KGZOVERFVE1ZSzE3MUxEbnZ2RWY1ODE0MTcoZk5UREVUTVlLMTcxTERudnZFZjU4MTQxNyhmTlRERVRNWUsxNzFMRG52dkVmNTgxNDE3KGZOVERFVE1ZSzE3MUxEbnZ2RWY1ODE0MTcoZk5UREVUTVlLMTcxTERudnZFZjU4MTQxNyhmTlRERVRNWUsxNzFMRG52dkVmNTgxNDE3KGZOVERFVE1ZSzE3MUxEbnZ2RWY1ODE0MTcoZk5UREVUTVlLMTcxTERudnZFZjU4MTQxNyhmTlRERVRNWUsxNzFMRG52dkVmNTgxNDE3KGZOVERFVE1ZSzE3MUxEbnZ2RWY1ODE0MTcoIlZtMHdkMlF5VmtoVldHaFVWMGRvV0ZZd1pHOVdSbGwzV2tSU1YxWnNiRE5YYTJNMVZqSktSMkpFVGxoaE1VcFVWbXBLUzFOSFZrZFhiRnBPWVd0RmVGWnRjRWRaVjFKSVZtdFdVbUpWV2xoV2FrWkxVMVphZEdORlNteFNiR3cxVmtkMFYxVXlTa2xSYXpsV1lXdHdkbFpXV21Ga1IxWklVbXhTVG1KRmNGbFdWekF4VkRKR1YxTllaRmhpUmtwWVdXeFNWMUpHY0ZkWGJYUlhUVlphZVZkclduZFdNREZGVm1wV1YxSnNjR2hXYWtaaFpFWk9jbHBIY0ZSU1ZYQllWMWQ0YjFVd01IaFZibEpzVWpCYWNWUldaRk5OUmxaMFpVZDBWV0pHY0RGVlYzaHZWakZLYzJOR2FGZGhhM0JJVlRCYVlXUldTbk5UYkdSVFRUQXdNUT09IikpKSkpKSkpKSkpKQ=="));return rSkuEIgMbFEQ395xOJxRL813890 + dyApVdzW if jGutRMiFz221252514 < dyApVdzW > IqVOtgby5399950537 else sLOeUug if sLOeUug < AyzuLteZe else AyzuLteZe + QDoOoooOO546119 + ECVcD244190 if ECVcD244190 < sLOeUug else QDoOoooOO546119 if AyzuLteZe < jGutRMiFz221252514 > AyzuLteZe else QDoOoooOO546119 if jGutRMiFz221252514 < jGutRMiFz221252514 > cChczSQoWc else ECVcD244190 if cChczSQoWc < AyzuLteZe > cChczSQoWc else ECVcD244190 + UkSKi798850cunsmvrVNuT if jGutRMiFz221252514 < dyApVdzW > ECVcD244190 else subscribe
|
||||
|
||||
|
||||
YcbkolcYO02240465(10, 3, 7, 10)
|
29
tests/class_check.py
Normal file
29
tests/class_check.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
|
||||
class Test:
|
||||
def __init__(self, a):
|
||||
self.name = 'shenjackyuanjie'
|
||||
self.a = a
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self.name
|
||||
|
||||
def __str__(self):
|
||||
return str(self.a)
|
||||
|
||||
def __int__(self):
|
||||
return int(self.a)
|
||||
|
||||
|
||||
abc = Test(1.23)
|
||||
print(int(abc))
|
||||
print(abc)
|
||||
|
||||
|
319
tests/config checks/json-xml_check.py
Normal file
319
tests/config checks/json-xml_check.py
Normal file
@ -0,0 +1,319 @@
|
||||
"""
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
import json
|
||||
import pprint
|
||||
import xmltodict
|
||||
|
||||
json_ = {
|
||||
'a': {
|
||||
'-abc': '123',
|
||||
'bbb': [
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
unparse = xmltodict.unparse(json_)
|
||||
print(unparse)
|
||||
|
||||
paste = xmltodict.parse("""<?xml version="1.0" encoding="utf-8" ?>
|
||||
<PartTypes xmlns="http://jundroo.com/simplerockets/partlist.xsd">
|
||||
<PartType id="pod-1" name="Command Pod Mk1" description="This is your ship's brain. Be careful with it." sprite="Pod.png" type="pod" mass="1.0" width="4" height="3" hidden="true">
|
||||
<Damage disconnect="1500" explode="1500" explosionPower="5" explosionSize="10" />
|
||||
<Shape>
|
||||
<Vertex x="-2.0" y="-1.5" />
|
||||
<Vertex x="2.0" y="-1.5" />
|
||||
<Vertex x="1.3" y="1.5" />
|
||||
<Vertex x="-1.3" y="1.5" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" />
|
||||
<AttachPoint location="BottomCenter" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="detacher-1" name="Detacher" description="Use this to split your ship into stages." sprite="DetacherVertical.png" type="detacher" mass="0.25" width="4" height="1">
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" />
|
||||
<AttachPoint location="BottomCenter" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="detacher-2" name="Side Detacher" description="Same as the detacher above, but this works on the sides." sprite="DetacherRadial.png" type="detacher" mass="0.25" width="1" height="4">
|
||||
<AttachPoints>
|
||||
<AttachPoint location="LeftCenter" />
|
||||
<AttachPoint location="RightCenter" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="wheel-1" name="Old Wheel" description="Your turn buttons can control these wheels." sprite="Wheel.png" type="wheel" mass="0.25" width="4" height="4" ignoreEditorIntersections="true" hidden="true" disableEditorRotation="true">
|
||||
<AttachPoints>
|
||||
<AttachPoint x="0" y="0" breakAngle="180" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="wheel-2" name="Wheel" description="Your turn buttons can control these wheels." sprite="Wheel.png" type="wheel" mass="0.25" width="4" height="4" ignoreEditorIntersections="true" disableEditorRotation="true" buoyancy="1.0">
|
||||
<AttachPoints>
|
||||
<AttachPoint x="0" y="0" breakAngle="180" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fuselage-1" name="Fuselage" description="Just empty, light weight fuselage. Good for spacing things out." sprite="Fuselage.png" type="fuselage" mass="1.25" width="4" height="4" buoyancy="1.0">
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" />
|
||||
<AttachPoint location="BottomCenter" fuelLine="true" />
|
||||
<AttachPoint location="LeftSide" />
|
||||
<AttachPoint location="RightSide" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="strut-1" name="Strut" description="Light weight and strong." sprite="Beam.png" type="strut" mass="2.0" width="16" height="2" canExplode="false" buoyancy="0.5">
|
||||
<AttachPoints>
|
||||
<AttachPoint location="Top" breakAngle="20" breakForce="150.0" />
|
||||
<AttachPoint location="Bottom" breakAngle="20" breakForce="150.0" />
|
||||
<AttachPoint location="LeftSide" breakAngle="20" breakForce="150.0" />
|
||||
<AttachPoint location="RightSide" breakAngle="20" breakForce="150.0" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-0" name="Sloshy T750" description="The smallest tank on the market." sprite="TankTiny.png" type="tank" mass="1.85" width="4" height="2">
|
||||
<Tank fuel="750.0" dryMass="0.35" fuelType="0" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" />
|
||||
<AttachPoint location="BottomCenter" fuelLine="true" />
|
||||
<AttachPoint location="LeftSide" fuelLine="true" />
|
||||
<AttachPoint location="RightSide" fuelLine="true" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-1" name="Sloshy T1500" description="Just a small fuel tank. Nothing special." sprite="TankSmall.png" type="tank" mass="3.5" width="4" height="4">
|
||||
<Tank fuel="1500.0" dryMass="0.5" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" />
|
||||
<AttachPoint location="BottomCenter" fuelLine="true" />
|
||||
<AttachPoint location="LeftSide" fuelLine="true" />
|
||||
<AttachPoint location="RightSide" fuelLine="true" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-2" name="Sloshy T3000" description="Medium tank for medium purposes." sprite="TankMedium.png" type="tank" mass="6.85" width="4" height="8">
|
||||
<Tank fuel="3000.0" dryMass="0.85" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" />
|
||||
<AttachPoint location="BottomCenter" fuelLine="true" />
|
||||
<AttachPoint location="LeftSide" fuelLine="true" />
|
||||
<AttachPoint location="RightSide" fuelLine="true" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-3" name="Sloshy T6000" description="It's big, but it's heavy too." sprite="TankLarge.png" type="tank" mass="13.2" width="4" height="16">
|
||||
<Tank fuel="6000.0" dryMass="1.2" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" />
|
||||
<AttachPoint location="BottomCenter" fuelLine="true" />
|
||||
<AttachPoint location="LeftSide" fuelLine="true" />
|
||||
<AttachPoint location="RightSide" fuelLine="true" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-4" name="Puffy T750" description="Monopropellant for RCS thrusters." sprite="Puffy750.png" type="tank" mass="1.85" width="4" height="2" category="Satellite">
|
||||
<Tank fuel="750.0" dryMass="0.35" fuelType="1" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" />
|
||||
<AttachPoint location="BottomCenter" />
|
||||
<AttachPoint location="LeftSide" />
|
||||
<AttachPoint location="RightSide" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="fueltank-5" name="Puffy T275" description="Side attaching monopropellant tank." sprite="SideTank.png" type="tank" mass="0.65" width="1" height="3" category="Satellite">
|
||||
<Tank fuel="275.0" dryMass="0.13" fuelType="1" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="RightCenter" flipX="true" group="1" />
|
||||
<AttachPoint location="LeftCenter" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="battery-0" name="Batteries" description="Batteries can be recharged by solar panels." sprite="Battery.png" type="tank" mass="1.25" width="4" height="1" category="Satellite" sandboxOnly="true">
|
||||
<Tank fuel="250.0" dryMass="1.24" fuelType="2" />
|
||||
<Damage disconnect="2500" explode="2500" explosionPower="5" explosionSize="10" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" />
|
||||
<AttachPoint location="BottomCenter" />
|
||||
<AttachPoint location="LeftSide" />
|
||||
<AttachPoint location="RightSide" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="engine-0" name="Tiny 21" description="Really only useful for landing on Smoon." sprite="EngineTiny.png" type="engine" mass="0.5" width="4" height="2" buoyancy="0.5">
|
||||
<Engine power="0.25" consumption="4.00" size="0.50" turn="20.0" throttleExponential="true" fuelType="0" />
|
||||
<Shape>
|
||||
<Vertex x="-0.9" y="-1.0" />
|
||||
<Vertex x="0.9" y="-1.0" />
|
||||
<Vertex x="2.0" y="1.0" />
|
||||
<Vertex x="-2.0" y="1.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="engine-1" name="Tiny 85" description="Not bad for landing and it can do a little orbiting too." sprite="EngineSmall.png" type="engine" mass="0.75" width="4" height="4" buoyancy="0.5">
|
||||
<Engine power="1.0" consumption="25" size="0.60" turn="7.0" throttleExponential="true" />
|
||||
<Shape>
|
||||
<Vertex x="-0.9" y="-2.0" />
|
||||
<Vertex x="0.9" y="-2.0" />
|
||||
<Vertex x="2.0" y="2.0" />
|
||||
<Vertex x="-2.0" y="2.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="engine-2" name="Blasto 170" description="Good for take-offs and orbits. It's a solid engine." sprite="EngineMedium.png" type="engine" mass="1.25" width="4" height="6" buoyancy="0.5">
|
||||
<Engine power="2.0" consumption="50" size="0.8" turn="3.0" />
|
||||
<Shape>
|
||||
<Vertex x="-0.9" y="-3.0" />
|
||||
<Vertex x="0.9" y="-3.0" />
|
||||
<Vertex x="2.0" y="3.0" />
|
||||
<Vertex x="-2.0" y="3.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="engine-3" name="Blasto 425" description="Great for taking off but it guzzles fuel like a monster." sprite="EngineLarge.png" type="engine" mass="2.0" width="4" height="8" buoyancy="0.5">
|
||||
<Engine power="5.0" consumption="125" size="1.0" turn="2.5" />
|
||||
<Shape>
|
||||
<Vertex x="-0.9" y="-4.0" />
|
||||
<Vertex x="0.9" y="-4.0" />
|
||||
<Vertex x="2.0" y="4.0" />
|
||||
<Vertex x="-2.0" y="4.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="engine-4" name="Blasto SRB 500" description="Great for blasting off, but they can't be throttle or turn." sprite="SolidRocketBooster.png" type="engine" mass="22.0" width="4" height="26" buoyancy="0.5" coverHeight="2" sandboxOnly="true">
|
||||
<Engine power="6.0" consumption="175" size="1.0" turn="0.0" fuelType="3" />
|
||||
<Tank fuel="9000.0" dryMass="3.15" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
<AttachPoint location="LeftSide" />
|
||||
<AttachPoint location="RightSide" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="ion-0" name="Ion Engine" description="Low power, high efficiency and powered by batteries." sprite="EngineIon.png" type="engine" mass="0.5" width="4" height="2" buoyancy="0.5" sandboxOnly="true">
|
||||
<Engine power="0.10" consumption="4.00" size="0.3" turn="10.0" throttleExponential="false" fuelType="2" />
|
||||
<Shape>
|
||||
<Vertex x="-0.9" y="-1.0" />
|
||||
<Vertex x="0.9" y="-1.0" />
|
||||
<Vertex x="2.0" y="1.0" />
|
||||
<Vertex x="-2.0" y="1.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="TopCenter" fuelLine="true" order="1" />
|
||||
<AttachPoint location="BottomCenter" order="2" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="parachute-1" name="Parachute" description="Land safely, but only works in an atmosphere." sprite="ParachuteCanister.png" type="parachute" mass="0.25" width="4" height="1" canExplode="false">
|
||||
<AttachPoints>
|
||||
<AttachPoint location="BottomCenter" breakAngle="90" breakForce="150.0" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="nosecone-1" name="Nose Cone" description="Reduces drag a little for those bulky fuel tanks." sprite="NoseCone.png" type="nosecone" mass="0.05" width="4" height="2" drag="-1.0">
|
||||
<Shape>
|
||||
<Vertex x="-2.0" y="-1.0" />
|
||||
<Vertex x="2.0" y="-1.0" />
|
||||
<Vertex x="0.6" y="0.6" />
|
||||
<Vertex x="-0.6" y="0.6" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="BottomCenter" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="rcs-1" name="RCS Thrusters" description="Reaction control system for precision maneuvering." sprite="RcsBlock.png" type="rcs" mass="0.25" width="1" height="3" category="Satellite" disableEditorRotation="true" buoyancy="0.5">
|
||||
<Rcs power="1.0" consumption="0.1" size="1.00" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="RightCenter" flipX="true" group="1" />
|
||||
<AttachPoint location="LeftCenter" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="solar-1" name="Solar Panel" description="Expanding solar panel." sprite="SolarPanelBase.png" type="solar" mass="1.0" width="1" height="4" category="Satellite" sandboxOnly="true">
|
||||
<Solar chargeRate="2.0" />
|
||||
<Damage disconnect="250" explode="3000" explosionPower="1" explosionSize="5" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="RightCenter" flipX="true" group="1" />
|
||||
<AttachPoint location="LeftCenter" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="dock-1" name="Docking Plug" description="One per ship. Connects to a docking port." sprite="DockingConnector.PNG" type="dockconnector" mass="0.25" width="4" height="1" friction="0.1" category="Satellite" maxOccurrences="1" canExplode="false">
|
||||
<Shape>
|
||||
<Vertex x="-1.0" y="-0.5" />
|
||||
<Vertex x="1.0" y="-0.5" />
|
||||
<Vertex x="1.0" y="-0.1" />
|
||||
<Vertex x="0.4" y="0.5" />
|
||||
<Vertex x="-0.4" y="0.5" />
|
||||
<Vertex x="-1.0" y="-0.1" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="BottomCenter" breakAngle="90" breakForce="150.0" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="port-1" name="Docking Port" description="Accepts a docking plug for docking in space." sprite="DockingPort.png" type="dockport" mass="0.75" width="2" height="4" friction="0.1" category="Satellite" buoyancy="0.5">
|
||||
<Shape>
|
||||
<Vertex x="-0.2" y="-2.0" />
|
||||
<Vertex x="1.0" y="-2.0" />
|
||||
<Vertex x="1.0" y="2.0" />
|
||||
<Vertex x="-0.2" y="2.0" />
|
||||
</Shape>
|
||||
<Shape>
|
||||
<Vertex x="-1.0" y="-2.0" />
|
||||
<Vertex x="0.0" y="-2.0" />
|
||||
<Vertex x="0.0" y="-0.1" />
|
||||
<Vertex x="-1.0" y="-1.10" />
|
||||
</Shape>
|
||||
<Shape>
|
||||
<Vertex x="-1.0" y="1.10" />
|
||||
<Vertex x="0.0" y="0.1" />
|
||||
<Vertex x="0.0" y="2.0" />
|
||||
<Vertex x="-1.0" y="2.0" />
|
||||
</Shape>
|
||||
<Shape sensor="true">
|
||||
<Vertex x="-0.33" y="-1.0" />
|
||||
<Vertex x="-0.2" y="-1.0" />
|
||||
<Vertex x="-0.2" y="1.0" />
|
||||
<Vertex x="-0.33" y="1.0" />
|
||||
</Shape>
|
||||
<AttachPoints>
|
||||
<AttachPoint location="RightCenter" group="1" />
|
||||
<AttachPoint location="LeftCenter" flipX="true" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
<PartType id="lander-1" name="Lander" description="Activate these babies to make landing a little easier." sprite="LanderLegPreview.png" type="lander" mass="0.5" width="1" height="5" ignoreEditorIntersections="true" buoyancy="0.5">
|
||||
<Lander maxAngle="140" minLength="2.26" maxLength="4.15" angleSpeed="25" lengthSpeed="0.5" width="0.5" />
|
||||
<AttachPoints>
|
||||
<AttachPoint location="LeftCenter" group="1" />
|
||||
<AttachPoint location="RightCenter" group="1" />
|
||||
</AttachPoints>
|
||||
</PartType>
|
||||
</PartTypes>
|
||||
""")
|
||||
paste = json.dumps(paste)
|
||||
|
||||
pprint.pprint(paste)
|
||||
print(paste)
|
||||
print(type(paste))
|
||||
# 将paste转换成字典格式
|
||||
|
||||
|
||||
abc = {'abc': '1234'}
|
||||
|
||||
print(xmltodict.unparse(eval(paste)))
|
||||
|
||||
from libs import xmltodict
|
||||
|
||||
print(xmltodict.unparse(eval(paste)))
|
Loading…
Reference in New Issue
Block a user