diff options
author | Antonis Ryakiotakis <kalast@gmail.com> | 2022-02-07 21:37:15 +0300 |
---|---|---|
committer | Antonis Ryakiotakis <kalast@gmail.com> | 2022-02-07 21:37:15 +0300 |
commit | d8c05502272990173381bfd2590884bbc95aa5f5 (patch) | |
tree | 8bd65efacbe6484b838d4550597d0f4a54ddddd9 /release/scripts/modules/rna_xml.py | |
parent | b64d551f3b2fa409b4eeefb641fc581eb6cd0bd6 (diff) | |
parent | fe1816f67fbc6aaf383ec77847d668367335d093 (diff) |
Merge branch 'master' into KTX_supportKTX_support
Diffstat (limited to 'release/scripts/modules/rna_xml.py')
-rw-r--r-- | release/scripts/modules/rna_xml.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 7f7b273c42b..aa8841c5efe 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -298,7 +298,7 @@ def xml2rna( del value_xml_split tp_name = 'ARRAY' -# print(" %s.%s (%s) --- %s" % (type(value).__name__, attr, tp_name, subvalue_type)) + # print(" %s.%s (%s) --- %s" % (type(value).__name__, attr, tp_name, subvalue_type)) try: setattr(value, attr, value_xml_coerce) except ValueError: @@ -340,7 +340,6 @@ def xml2rna( else: # print(elems) - if len(elems) == 1: # sub node named by its type child_xml_real, = elems @@ -376,7 +375,6 @@ def _get_context_val(context, path): def xml_file_run(context, filepath, rna_map): - import xml.dom.minidom xml_nodes = xml.dom.minidom.parse(filepath) @@ -391,27 +389,25 @@ def xml_file_run(context, filepath, rna_map): value = _get_context_val(context, rna_path) if value is not Ellipsis and value is not None: - print(" loading XML: %r -> %r" % (filepath, rna_path)) + # print(" loading XML: %r -> %r" % (filepath, rna_path)) xml2rna(xml_node, root_rna=value) def xml_file_write(context, filepath, rna_map, *, skip_typemap=None): - - file = open(filepath, "w", encoding="utf-8") - fw = file.write - - fw("<bpy>\n") - - for rna_path, _xml_tag in rna_map: - # xml_tag is ignored, we get this from the rna - value = _get_context_val(context, rna_path) - rna2xml(fw, + with open(filepath, "w", encoding="utf-8") as file: + fw = file.write + fw("<bpy>\n") + + for rna_path, _xml_tag in rna_map: + # xml_tag is ignored, we get this from the rna + value = _get_context_val(context, rna_path) + rna2xml( + fw=fw, root_rna=value, method='ATTR', root_ident=" ", ident_val=" ", skip_typemap=skip_typemap, - ) + ) - fw("</bpy>\n") - file.close() + fw("</bpy>\n") |