6
6
Typical line in the input file (elements in [] are optional).
8
8
[comment *] ToolSettings.snap_align_rotation -> use_snap_align_rotation: boolean [Align rotation with the snapping target]
10
Geterate output format from blender run this:
11
./blender.bin --background -noaudio --python ./release/scripts/modules/rna_info.py 2> source/blender/makesrna/rna_cleanup/out.txt
73
76
return (inputfile, sort_priority)
76
def check_prefix(prop):
79
def check_prefix(prop, btype):
77
80
# reminder: props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
79
prefix = prop.split('_')[0]
80
if prefix not in kw_prefixes:
81
return 'BAD-PREFIX: ' + prefix
81
if btype == "boolean":
83
prefix = prop.split('_')[0]
84
if prefix not in kw_prefixes:
85
return 'BAD-PREFIX: ' + prefix
89
return 'SPECIAL-KEYWORD: ' + prop
85
return 'SPECIAL-KEYWORD: ' + prop
91
return 'BAD-KEYWORD: ' + prop
87
return 'BAD-KEYWORD: ' + prop
90
96
def check_if_changed(a,b):
105
111
props_length_max=[0,0,0,0,0,0,0,0]
106
for line in file_lines:
117
for iii, line in enumerate(file_lines):
121
line_strip = line.strip()
111
122
# empty line or comment
112
if not line.strip() or line.startswith('#'):
126
if line_strip == "EOF":
129
if line.startswith("#"):
116
133
[bclass, tail] = [x.strip() for x in line.split('.', 1)]
135
152
# type, description
137
154
[btype, description] = tail.split(None, 1)
138
if '"' in description:
139
description.replace('"', "'")
155
# make life easy and strip quotes
156
description = description.replace("'", "").replace('"', "").replace("\\", "").strip()
140
157
except ValueError:
141
158
[btype, description] = [tail,'NO DESCRIPTION']
144
kwcheck = check_prefix(bto)
161
kwcheck = check_prefix(bto, btype)
147
164
changed = check_if_changed(bfrom, bto)
149
166
# lists formatting
150
props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, repr(description)]
167
props=[comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
151
168
props_list.append(props)
152
169
props_length_max=list(map(max,zip(props_length_max,list(map(len,props)))))
171
if done_text in comment:
175
print("Total done %.2f" % (done / tot * 100.0) )
154
177
return (props_list,props_length_max)
165
188
props_length_max = [0 for i in rna_api[0]] # this way if the vector will take more elements we are safe
166
189
for index,props in enumerate(rna_api):
167
190
comment, changed, bclass, bfrom, bto, kwcheck, btype, description = props
168
kwcheck = check_prefix(bto) # keyword-check
191
kwcheck = check_prefix(bto, btype) # keyword-check
169
192
changed = check_if_changed(bfrom, bto) # changed?
170
193
description = repr(description)
194
description = description.replace("'", "").replace('"', "").replace("\\", "").strip()
171
195
rna_api[index] = [comment, changed, bclass, bfrom, bto, kwcheck, btype, description]
172
196
props_length = list(map(len,props)) # lengths
173
197
props_length_max = list(map(max,zip(props_length_max,props_length))) # max lengths
191
215
# order based on the i-th element in lists
192
i = sort_choices.index(sort_priority)
194
props_list = sorted(props_list, key=lambda p: p[i], reverse=True)
216
if sort_priority == "class.to":
217
props_list = sorted(props_list, key=lambda p: (p[2], p[4]))
196
props_list = sorted(props_list, key=lambda p: p[i])
219
i = sort_choices.index(sort_priority)
221
props_list = sorted(props_list, key=lambda p: p[i], reverse=True)
223
props_list = sorted(props_list, key=lambda p: p[i])
198
225
print ('\nSorted by %s.' % font_bold(sort_priority))
199
226
return props_list
233
260
props_list = [['NOTE', 'CHANGED', 'CLASS', 'FROM', 'TO', 'KEYWORD-CHECK', 'TYPE', 'DESCRIPTION']] + props_list
234
261
for props in props_list:
264
# quick way we can tell if it changed
265
if props[3] == props[4]: txt += "#"
236
268
if props[0] != '': txt += '%s * ' % props[0] # comment
237
txt += '%s.%s -> %s: %s %s\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
269
txt += '%s.%s -> %s: %s "%s"\n' % tuple(props[2:5] + props[6:]) # skipping keyword-check
239
271
if props[0] == 'NOTE': indent = '# '
240
272
else: indent = ' '
241
rna += indent + '("%s", "%s", "%s", "%s", %s),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
273
rna += indent + '("%s", "%s", "%s", "%s", "%s"),\n' % tuple(props[2:5] + props[6:]) # description is already string formatted
243
275
blanks = [' '* (x[0]-x[1]) for x in zip(props_length_max,list(map(len,props)))]
244
276
props = [('"%s"%s' if props[-1] != x[0] else "%s%s") % (x[0],x[1]) for x in zip(props,blanks)]
245
py += indent + '(%s, %s, %s, %s, %s, %s, %s, %s),\n' % tuple(props)
277
py += indent + '(%s, %s, %s, %s, %s, %s, %s, "%s"),\n' % tuple(props)
248
280
f_py.write("rna_api = [\n%s]\n" % py)
266
298
global sort_choices, default_sort_choice
267
299
global kw_prefixes, kw
269
sort_choices = ['note','changed','class','from','to','kw']
270
default_sort_choice = sort_choices[0]
301
sort_choices = ['note','changed','class','from','to','kw', 'class.to']
302
default_sort_choice = sort_choices[-1]
271
303
kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \
272
'pressed','show','show_only','use','use_only','layers','states']
304
'pressed','show','show_only','use','use_only','layers','states', 'select']
273
305
kw = ['active','hide','invert','select','layers','mute','states','use','lock']
275
307
input_filename, sort_priority = check_commandline()