Fix T53843: Error opening online manual

This commit is contained in:
Campbell Barton
2018-01-22 09:45:51 +11:00
parent a841e65b85
commit d9c962a367

View File

@@ -906,6 +906,15 @@ class WM_OT_path_open(Operator):
def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
def operator_exists_pair(a, b):
# Not fast, this is only for docs.
return b in dir(getattr(bpy.ops, a))
def operator_exists_single(a):
a, b = a.partition("_OT_")[::2]
return operator_exists_pair(a.lower(), b)
id_split = doc_id.split(".")
url = rna = None
@@ -919,7 +928,7 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
class_name, class_prop = id_split
# an operator (common case - just button referencing an op)
if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop):
if operator_exists_pair(class_name, class_prop):
if do_url:
url = (
"%s/bpy.ops.%s.html#bpy.ops.%s.%s" %
@@ -927,14 +936,7 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
)
else:
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
rna_class = getattr(bpy.types, class_name)
# an operator setting (selected from a running operator), rare case
# note: Py defined operators are subclass of Operator,
# C defined operators are subclass of OperatorProperties.
# we may need to check on this at some point.
if issubclass(rna_class, (bpy.types.Operator, bpy.types.OperatorProperties)):
elif operator_exists_single(class_name):
# note: ignore the prop name since we don't have a way to link into it
class_name, class_prop = class_name.split("_OT_", 1)
class_name = class_name.lower()
@@ -947,6 +949,7 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""):
rna = "bpy.ops.%s.%s" % (class_name, class_prop)
else:
# an RNA setting, common case
rna_class = getattr(bpy.types, class_name)
# detect if this is a inherited member and use that name instead
rna_parent = rna_class.bl_rna