Blender V2.61 - r43446

dump_rna2xml.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # ***** BEGIN GPL LICENSE BLOCK *****
00004 #
00005 # This program is free software; you can redistribute it and/or
00006 # modify it under the terms of the GNU General Public License
00007 # as published by the Free Software Foundation; either version 2
00008 # of the License, or (at your option) any later version.
00009 #
00010 # This program is distributed in the hope that it will be useful,
00011 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 # GNU General Public License for more details.
00014 #
00015 # You should have received a copy of the GNU General Public License
00016 # along with this program; if not, write to the Free Software Foundation,
00017 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018 #
00019 # Contributor(s): Campbell Barton
00020 #
00021 # ***** END GPL LICENSE BLOCK *****
00022 
00023 # <pep8 compliant>
00024 
00025 # This script dumps rna into xml.
00026 # useful for finding bugs in RNA api.
00027 
00028 # Example usage
00029 # blender some.blend --background -noaudio --python intern/tools/dump_rna2xml.py
00030 
00031 import os
00032 import bpy
00033 import rna_xml
00034 
00035 
00036 def main():
00037     filename = os.path.splitext(bpy.data.filepath)[0] + ".xml"
00038 
00039     file = open(filename, 'w')
00040 
00041     if 0:
00042         # blend file
00043         rna_xml.rna2xml(file.write,
00044                         root_rna=bpy.data,
00045                         root_rna_skip={"window_managers"})
00046     else:
00047         # theme. just another test
00048         rna_xml.rna2xml(file.write,
00049                         root_rna=bpy.context.user_preferences.themes[0],
00050                         method='ATTR')
00051 
00052         file.close()
00053 
00054     # read back to ensure this is valid!
00055     from xml.dom.minidom import parse
00056     xml_nodes = parse(filename)
00057     print("Written:", filename)
00058 
00059     # test reading back theme
00060     if 1:
00061         theme = xml_nodes.getElementsByTagName("Theme")[0]
00062         rna_xml.xml2rna(theme,
00063                         root_rna=bpy.context.user_preferences.themes[0],)
00064 
00065 if __name__ == "__main__":
00066     main()