From cc2c57b79333abc8d396b21baf6006acb494e755 Mon Sep 17 00:00:00 2001 From: Joseph Eagar Date: Sat, 4 Sep 2010 19:00:38 +0000 Subject: [PATCH] more missing files --- .../makesrna/rna_cleanup/rna_cleaner_merge.py | 61 +++++++++++++++++++ .../makesrna/rna_cleanup/rna_update.sh | 13 ++++ 2 files changed, 74 insertions(+) create mode 100755 source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py create mode 100755 source/blender/makesrna/rna_cleanup/rna_update.sh diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py new file mode 100755 index 00000000000..8d2fe07b774 --- /dev/null +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py @@ -0,0 +1,61 @@ +#! /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].split("|")[-1], 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_new = mod_from_dict.pop(key) + except: + # print("not found", key) + val_new = val_orig + + # always take the class from the base + val = list(val_orig) + val[0] = val_new[0] # comment + val[4] = val_new[4] # -> to + val = tuple(val) + 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() diff --git a/source/blender/makesrna/rna_cleanup/rna_update.sh b/source/blender/makesrna/rna_cleanup/rna_update.sh new file mode 100755 index 00000000000..04d4bbcb0e4 --- /dev/null +++ b/source/blender/makesrna/rna_cleanup/rna_update.sh @@ -0,0 +1,13 @@ +cd ../../../../ +./blender.bin --background --python ./release/scripts/modules/rna_info.py 2> source/blender/makesrna/rna_cleanup/out.txt +cd ./source/blender/makesrna/rna_cleanup/ +./rna_cleaner.py out.txt +./rna_cleaner.py rna_properties.txt +./rna_cleaner_merge.py out_work.py rna_properties_work.py +./rna_cleaner.py out_work_merged.py +./rna_cleaner.py out_work_lost.py +mv out_work_merged_work.txt rna_properties.txt # overwrite +mv out_work_lost_work.txt rna_properties_lost.txt +cat rna_properties.txt | grep -v "^#" > rna_properties_edits.txt +./rna_cleaner.py rna_properties.txt +echo "Updated: rna_properties.txt rna_properties_edits.txt rna_properties_lost.txt " \ No newline at end of file