diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-08-09 15:32:55 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-08-09 15:32:55 +0400 |
commit | dd75ec490761640571a0d8e53a0d439091f2736f (patch) | |
tree | 25b3966862febbf3ee8c81ed45f7045c99f84016 /source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py | |
parent | 02b0967bd11dd6fd2454b37182d9f94ea451b603 (diff) | |
parent | c026b8066ddc1c42144d2e5132384ea7c1211050 (diff) |
Merged changes in the trunk up to revision 31190.
Diffstat (limited to 'source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py')
-rw-r--r-- | source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py | 56 |
1 files changed, 56 insertions, 0 deletions
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 100644 index 00000000000..9fcaa8be3f8 --- /dev/null +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner_merge.py @@ -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()
\ No newline at end of file |