Release tools: Add script to generate a list of bugs fixed from last release
[blender.git] / source / blender / python / rna_dump.py
blob8f0da121c54cd4828854af2619bfe81105615ac3
1 # SPDX-FileCopyrightText: 2009-2023 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 if 1:
6 # Print once every 1000
7 GEN_PATH = True
8 PRINT_DATA = False
9 PRINT_DATA_INT = 1000
10 VERBOSE = False
11 VERBOSE_TYPE = False
12 MAX_RECURSIVE = 8
13 else:
14 # Print everything
15 GEN_PATH = True
16 PRINT_DATA = True
17 PRINT_DATA_INT = 0
18 VERBOSE = False
19 VERBOSE_TYPE = False
20 MAX_RECURSIVE = 8
22 seek_count = [0]
25 def seek(r, txt, recurs):
27 seek_count[0] += 1
29 if PRINT_DATA_INT:
30 if not (seek_count[0] % PRINT_DATA_INT):
31 print(seek_count[0], txt)
33 if PRINT_DATA:
34 print(txt)
36 newtxt = ''
38 if recurs > MAX_RECURSIVE:
39 # print ("Recursion is over max")
40 # print (txt)
41 return
43 type_r = type(r)
45 # print(type_r)
46 # print(dir(r))
48 # basic types
49 if type_r in {float, int, bool, type(None)}:
50 if PRINT_DATA:
51 print(txt + ' -> ' + str(r))
52 return
54 if type_r is str:
55 if PRINT_DATA:
56 print(txt + ' -> "' + str(r) + '"')
57 return
59 try:
60 keys = r.keys()
61 except Exception:
62 keys = None
64 if keys is not None:
65 if PRINT_DATA:
66 print(txt + '.keys() - ' + str(r.keys()))
68 try:
69 __members__ = dir(r)
70 except Exception:
71 __members__ = []
73 for item in __members__:
74 if item.startswith("__"):
75 continue
77 if GEN_PATH:
78 newtxt = txt + '.' + item
80 if item == 'rna_type' and VERBOSE_TYPE is False: # just avoid because it spits out loads of data
81 continue
83 value = getattr(r, item, None)
85 seek(value, newtxt, recurs + 1)
87 if keys:
88 for k in keys:
89 if GEN_PATH:
90 newtxt = txt + '["' + k + '"]'
91 seek(r.__getitem__(k), newtxt, recurs + 1)
93 else:
94 try:
95 length = len(r)
96 except Exception:
97 length = 0
99 if VERBOSE is False and length >= 4:
100 for i in (0, length - 1):
101 if i > 0:
102 if PRINT_DATA:
103 print((" " * len(txt)) + " ... skipping " + str(length - 2) + " items ...")
105 if GEN_PATH:
106 newtxt = txt + '[' + str(i) + ']'
107 seek(r[i], newtxt, recurs + 1)
108 else:
109 for i in range(length):
110 if GEN_PATH:
111 newtxt = txt + '[' + str(i) + ']'
112 seek(r[i], newtxt, recurs + 1)
115 seek(bpy.data, 'bpy.data', 0)
116 # seek(bpy.types, 'bpy.types', 0)
118 for d in dir(bpy.types):
119 t = getattr(bpy.types, d)
120 try:
121 r = t.bl_rna
122 except AttributeError:
123 r = None
124 if r:
125 seek(r, 'bpy.types.' + d + '.bl_rna', 0)
128 print("iter over ", seek_count, "rna items")