Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-11-15 18:42:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-15 18:42:19 +0300
commiteb23c7660bbf94bb80f251389ddb2b21c288c74f (patch)
treeaca378008a1716d1fa2eedbe35d684c895a8729a
parent4cf24c10e200b8e8daf7bd12f8b7b93471b35477 (diff)
parentdc726fed82c8e4f73bb0db9be026000bd37c4eac (diff)
Merge branch 'blender-v2.81-release'
-rw-r--r--release/scripts/modules/rna_info.py100
1 files changed, 71 insertions, 29 deletions
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index 8a46246cf91..71d7ee5a7bc 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -121,6 +121,8 @@ class InfoStructRNA:
"children",
"references",
"properties",
+ "py_class",
+ "module_name",
)
global_lookup = {}
@@ -142,6 +144,15 @@ class InfoStructRNA:
self.references = []
self.properties = []
+ self.py_class = get_py_class_from_rna(self.bl_rna)
+ self.module_name = (
+ self.py_class.__module__
+ if (self.py_class and not hasattr(bpy.types, self.identifier)) else
+ "bpy.types"
+ )
+ if self.module_name == "bpy_types":
+ self.module_name = "bpy.types"
+
def build(self):
rna_type = self.bl_rna
parent_id = self.identifier
@@ -172,7 +183,7 @@ class InfoStructRNA:
def _get_py_visible_attrs(self):
attrs = []
- py_class = get_py_class_from_rna(self.bl_rna)
+ py_class = self.py_class
for attr_str in dir(py_class):
if attr_str.startswith("_"):
@@ -571,34 +582,65 @@ def BuildRNAInfo():
structs.append( (base_id(rna_struct), rna_struct.identifier, rna_struct) )
'''
structs = []
- for rna_type_name in dir(bpy.types):
- rna_type = getattr(bpy.types, rna_type_name)
-
- rna_struct = getattr(rna_type, "bl_rna", None)
-
- if rna_struct:
- # if not rna_type_name.startswith('__'):
-
- identifier = rna_struct.identifier
-
- if not rna_id_ignore(identifier):
- structs.append((base_id(rna_struct), identifier, rna_struct))
- # Simple lookup
- rna_struct_dict[identifier] = rna_struct
-
- # Store full rna path 'GameObjectSettings' -> 'Object.GameObjectSettings'
- rna_full_path_dict[identifier] = full_rna_struct_path(rna_struct)
-
- # Store a list of functions, remove inherited later
- # NOT USED YET
- ## rna_functions_dict[identifier] = get_direct_functions(rna_struct)
-
- # fill in these later
- rna_children_dict[identifier] = []
- rna_references_dict[identifier] = []
- else:
- print("Ignoring", rna_type_name)
+ def _bpy_types_iterator():
+ names_unique = set()
+ rna_type_list = []
+ for rna_type_name in dir(bpy.types):
+ names_unique.add(rna_type_name)
+ rna_type = getattr(bpy.types, rna_type_name)
+ rna_struct = getattr(rna_type, "bl_rna", None)
+ if rna_struct is not None:
+ rna_type_list.append(rna_type)
+ yield (rna_type_name, rna_struct)
+ else:
+ print("Ignoring", rna_type_name)
+
+ # Now, there are some sub-classes in add-ons we also want to include.
+ # Cycles for e.g. these are referenced from the Scene, but not part of
+ # bpy.types module.
+ # Include all sub-classes we didn't already get from 'bpy.types'.
+ i = 0
+ while i < len(rna_type_list):
+ rna_type = rna_type_list[i]
+ for rna_sub_type in rna_type.__subclasses__():
+ rna_sub_struct = getattr(rna_sub_type, "bl_rna", None)
+ if rna_sub_struct is not None:
+ rna_sub_type_name = rna_sub_struct.identifier
+ if rna_sub_type_name not in names_unique:
+ names_unique.add(rna_sub_type_name)
+ rna_type_list.append(rna_sub_type)
+ # The bl_idname may not match the class name in the file.
+ # Always use the 'bl_idname' because using the Python
+ # class name causes confusion - having two names for the same thing.
+ # Since having two names for the same thing is trickier to support
+ # without a significant benefit.
+ yield (rna_sub_type_name, rna_sub_struct)
+ i += 1
+
+ for (rna_type_name, rna_struct) in _bpy_types_iterator():
+ # if not rna_type_name.startswith('__'):
+
+ identifier = rna_struct.identifier
+
+ if not rna_id_ignore(identifier):
+ structs.append((base_id(rna_struct), identifier, rna_struct))
+
+ # Simple lookup
+ rna_struct_dict[identifier] = rna_struct
+
+ # Store full rna path 'GameObjectSettings' -> 'Object.GameObjectSettings'
+ rna_full_path_dict[identifier] = full_rna_struct_path(rna_struct)
+
+ # Store a list of functions, remove inherited later
+ # NOT USED YET
+ ## rna_functions_dict[identifier] = get_direct_functions(rna_struct)
+
+ # fill in these later
+ rna_children_dict[identifier] = []
+ rna_references_dict[identifier] = []
+
+ del _bpy_types_iterator
structs.sort() # not needed but speeds up sort below, setting items without an inheritance first
@@ -784,7 +826,7 @@ def main():
sys.stderr.write("\n\nEOF\n")
else:
text = bpy.data.texts.new(name="api.py")
- text.from_string(data)
+ text.from_string("\n".join(data))
if __name__ == "__main__":