1# ##### BEGIN GPL LICENSE BLOCK ##### 2# 3# This program is free software; you can redistribute it and/or 4# modify it under the terms of the GNU General Public License 5# as published by the Free Software Foundation; either version 2 6# of the License, or (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program; if not, write to the Free Software Foundation, 15# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16# 17# ##### END GPL LICENSE BLOCK ##### 18 19# <pep8 compliant> 20 21if 1: 22 # Print once every 1000 23 GEN_PATH = True 24 PRINT_DATA = False 25 PRINT_DATA_INT = 1000 26 VERBOSE = False 27 VERBOSE_TYPE = False 28 MAX_RECURSIVE = 8 29else: 30 # Print everything 31 GEN_PATH = True 32 PRINT_DATA = True 33 PRINT_DATA_INT = 0 34 VERBOSE = False 35 VERBOSE_TYPE = False 36 MAX_RECURSIVE = 8 37 38seek_count = [0] 39 40 41def seek(r, txt, recurs): 42 43 seek_count[0] += 1 44 45 if PRINT_DATA_INT: 46 if not (seek_count[0] % PRINT_DATA_INT): 47 print(seek_count[0], txt) 48 49 if PRINT_DATA: 50 print(txt) 51 52 newtxt = '' 53 54 if recurs > MAX_RECURSIVE: 55 #print ("Recursion is over max") 56 #print (txt) 57 return 58 59 type_r = type(r) 60 61 # print(type_r) 62 # print(dir(r)) 63 64 # basic types 65 if type_r in (float, int, bool, type(None)): 66 if PRINT_DATA: 67 print(txt + ' -> ' + str(r)) 68 return 69 70 if type_r == str: 71 if PRINT_DATA: 72 print(txt + ' -> "' + str(r) + '"') 73 return 74 75 try: 76 keys = r.keys() 77 except: 78 keys = None 79 80 if keys is not None: 81 if PRINT_DATA: 82 print(txt + '.keys() - ' + str(r.keys())) 83 84 try: 85 __members__ = dir(r) 86 except: 87 __members__ = [] 88 89 for item in __members__: 90 if item.startswith("__"): 91 continue 92 93 if GEN_PATH: 94 newtxt = txt + '.' + item 95 96 if item == 'rna_type' and VERBOSE_TYPE is False: # just avoid because it spits out loads of data 97 continue 98 99 value = getattr(r, item, None) 100 101 seek(value, newtxt, recurs + 1) 102 103 if keys: 104 for k in keys: 105 if GEN_PATH: 106 newtxt = txt + '["' + k + '"]' 107 seek(r.__getitem__(k), newtxt, recurs + 1) 108 109 else: 110 try: 111 length = len(r) 112 except: 113 length = 0 114 115 if VERBOSE is False and length >= 4: 116 for i in (0, length - 1): 117 if i > 0: 118 if PRINT_DATA: 119 print((" " * len(txt)) + " ... skipping " + str(length - 2) + " items ...") 120 121 if GEN_PATH: 122 newtxt = txt + '[' + str(i) + ']' 123 seek(r[i], newtxt, recurs + 1) 124 else: 125 for i in range(length): 126 if GEN_PATH: 127 newtxt = txt + '[' + str(i) + ']' 128 seek(r[i], newtxt, recurs + 1) 129 130 131seek(bpy.data, 'bpy.data', 0) 132# seek(bpy.types, 'bpy.types', 0) 133''' 134for d in dir(bpy.types): 135 t = getattr(bpy.types, d) 136 try: 137 r = t.bl_rna 138 except: 139 r = None 140 if r: 141 seek(r, 'bpy.types.' + d + '.bl_rna', 0) 142''' 143 144# print dir(bpy) 145#import sys 146# sys.exit() 147 148print("iter over ", seek_count, "rna items") 149