Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/modules/bpyml.py')
-rw-r--r--[-rwxr-xr-x]release/scripts/modules/bpyml.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py
index a2ba9ec8006..f1f72d50fd2 100755..100644
--- a/release/scripts/modules/bpyml.py
+++ b/release/scripts/modules/bpyml.py
@@ -37,6 +37,8 @@ or simple python blender/ui function calls.
"""
TAG, ARGS, CHILDREN = range(3)
+
+
class ReturnStore(tuple):
def __getitem__(self, key):
@@ -94,7 +96,6 @@ def toxml(py_data, indent=" "):
def _to_xml_iter(xml_parent, data_ls):
for py_item in data_ls:
xml_node = newdoc.createElement(py_item[TAG])
-
# ok if its empty
_to_xml_iter(xml_node, py_item[CHILDREN])
@@ -114,8 +115,7 @@ def fromxml(data):
for key, value in xml_node.attributes.items():
kwargs[key] = value
return kwargs
-
-
+
def _fromxml(xml_node):
py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), [])
#_fromxml_iter(py_item, xml_node.childNodes)
@@ -130,15 +130,15 @@ def fromxml(data):
def topretty_py(py_data, indent=" "):
-
+
if len(py_data) != 1:
raise Exception("Expected a list with one member")
lines = []
-
+
def _to_kwargs(kwargs):
return ", ".join([("%s=%s" % (key, repr(value))) for key, value in sorted(kwargs.items())])
-
+
def _topretty(py_item, indent_ctx, last):
if py_item[CHILDREN]:
lines.append("%s%s(%s) [" % (indent_ctx, py_item[TAG], _to_kwargs(py_item[ARGS])))
@@ -148,14 +148,14 @@ def topretty_py(py_data, indent=" "):
lines.append("%s]%s" % (indent_ctx, ("" if last else ",")))
else:
lines.append("%s%s(%s)%s" % (indent_ctx, py_item[TAG], _to_kwargs(py_item[ARGS]), ("" if last else ",")))
-
+
_topretty(py_data[0], "", True)
return "\n".join(lines)
if __name__ == "__main__":
# testing code.
-
+
tag_module("bpyml_test", ("ui", "prop", "row", "column", "active", "separator", "split"))
from bpyml_test import *
@@ -192,13 +192,13 @@ if __name__ == "__main__":
]
xml_data = toxml(draw)
- print(xml_data) # xml version
+ print(xml_data) # xml version
py_data = fromxml(xml_data)
- print(py_data) # converted back to py
+ print(py_data) # converted back to py
xml_data = toxml(py_data)
- print(xml_data) # again back to xml
+ print(xml_data) # again back to xml
- py_data = fromxml(xml_data) # pretty python version
+ py_data = fromxml(xml_data) # pretty python version
print(topretty_py(py_data))