rna refactor...
- added a script to merge 2 lists of rna renaming from/to - merged rna_booleans.txt into rna_properties.txt - made rna_cleaner.py sort by class.from by default.
This commit is contained in:
parent
9581cf1bdd
commit
8d517cff33
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,9 @@ This script is used to help cleaning RNA api.
|
||||
Typical line in the input file (elements in [] are optional).
|
||||
|
||||
[comment *] ToolSettings.snap_align_rotation -> use_snap_align_rotation: boolean [Align rotation with the snapping target]
|
||||
|
||||
Geterate output format from blender run this:
|
||||
./blender.bin --background --python ./release/scripts/modules/rna_info.py > source/blender/makesrna/rna_cleanup/out.txt
|
||||
"""
|
||||
|
||||
|
||||
@ -189,6 +192,9 @@ def sort(props_list, sort_priority):
|
||||
"""
|
||||
|
||||
# order based on the i-th element in lists
|
||||
if sort_priority == "class.from":
|
||||
props_list = sorted(props_list, key=lambda p: (p[2], p[3]))
|
||||
else:
|
||||
i = sort_choices.index(sort_priority)
|
||||
if i == 0:
|
||||
props_list = sorted(props_list, key=lambda p: p[i], reverse=True)
|
||||
@ -266,8 +272,8 @@ def main():
|
||||
global sort_choices, default_sort_choice
|
||||
global kw_prefixes, kw
|
||||
|
||||
sort_choices = ['note','changed','class','from','to','kw']
|
||||
default_sort_choice = sort_choices[0]
|
||||
sort_choices = ['note','changed','class','from','to','kw', 'class.from']
|
||||
default_sort_choice = sort_choices[-1]
|
||||
kw_prefixes = [ 'active','apply','bl','exclude','has','invert','is','lock', \
|
||||
'pressed','show','show_only','use','use_only','layers','states']
|
||||
kw = ['active','hide','invert','select','layers','mute','states','use','lock']
|
||||
|
56
source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
Normal file
56
source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py
Normal file
@ -0,0 +1,56 @@
|
||||
#! /usr/bin/env python3.1
|
||||
|
||||
import sys
|
||||
|
||||
'''
|
||||
Example usage:
|
||||
python3 rna_cleaner_merge.py out_work.py rna_booleans_work.py
|
||||
'''
|
||||
def main():
|
||||
|
||||
def work_line_id(line):
|
||||
return line[2], line[3] # class/from
|
||||
|
||||
|
||||
if not (sys.argv[-1].endswith(".py") and sys.argv[-2].endswith(".py")):
|
||||
print("Only accepts 2 py files as arguments.")
|
||||
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
mod_from = __import__(sys.argv[-1][:-3])
|
||||
mod_to = __import__(sys.argv[-2][:-3])
|
||||
|
||||
mod_to_dict = dict([(work_line_id(line), line) for line in mod_to.rna_api])
|
||||
mod_from_dict = dict([(work_line_id(line), line) for line in mod_from.rna_api])
|
||||
|
||||
rna_api_new = []
|
||||
|
||||
for key, val_orig in mod_to_dict.items():
|
||||
try:
|
||||
val = mod_from_dict.pop(key)
|
||||
except:
|
||||
# print("not found", key)
|
||||
val = val_orig
|
||||
|
||||
rna_api_new.append(val)
|
||||
|
||||
def write_work_file(file_path, rna_api):
|
||||
rna_api = list(rna_api)
|
||||
rna_api.sort(key=work_line_id)
|
||||
file_out = open(file_path, "w")
|
||||
file_out.write("rna_api = [\n")
|
||||
for line in rna_api:
|
||||
file_out.write(" %s,\n" % (repr(line)))
|
||||
file_out.write("]\n")
|
||||
file_out.close()
|
||||
|
||||
file_path = sys.argv[-2][:-3] + "_merged.py"
|
||||
write_work_file(file_path, rna_api_new)
|
||||
|
||||
if mod_from_dict:
|
||||
file_path = sys.argv[-2][:-3] + "_lost.py"
|
||||
write_work_file(file_path, list(mod_from_dict.values()))
|
||||
print("Warning '%s' contains lost %d items from module %s.py" % (file_path, len(mod_from_dict), mod_from.__name__))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user