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:
Diffstat (limited to 'release/scripts/modules/bpy_types.py')
-rw-r--r--release/scripts/modules/bpy_types.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index aaa2ae59a0d..b2f4d71ed92 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -56,6 +56,21 @@ class Context(StructRNA):
if value is None:
return value
+ # If the attribute is a list property, apply subscripting.
+ if isinstance(value, list) and path_rest.startswith("["):
+ index_str, div, index_tail = path_rest[1:].partition("]")
+ if not div:
+ raise ValueError("Path index is not terminated: %s%s" % (attr, path_rest))
+ try:
+ index = int(index_str)
+ except ValueError:
+ raise ValueError("Path index is invalid: %s[%s]" % (attr, index_str))
+ if 0 <= index < len(value):
+ path_rest = index_tail
+ value = value[index]
+ else:
+ raise IndexError("Path index out of range: %s[%s]" % (attr, index_str))
+
# Resolve the rest of the path if necessary.
if path_rest:
path_resolve_fn = getattr(value, "path_resolve", None)
@@ -778,7 +793,7 @@ class Gizmo(StructRNA):
vbo = GPUVertBuf(len=len(verts), format=fmt)
vbo.attr_fill(id=pos_id, data=verts)
batch = GPUBatch(type=type, buf=vbo)
- shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR' if dims == 3 else '2D_UNIFORM_COLOR')
+ shader = gpu.shader.from_builtin('UNIFORM_COLOR')
batch.program_set(shader)
return (batch, shader)
@@ -1059,6 +1074,7 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
- preset_operator_defaults (dict of keyword args)
"""
import bpy
+ from bpy.app.translations import pgettext_iface as iface_
ext_valid = getattr(self, "preset_extensions", {".py", ".xml"})
props_default = getattr(self, "preset_operator_defaults", None)
add_operator = getattr(self, "preset_add_operator", None)
@@ -1068,7 +1084,8 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
props_default=props_default,
filter_ext=lambda ext: ext.lower() in ext_valid,
add_operator=add_operator,
- display_name=lambda name: bpy.path.display_name(name, title_case=False)
+ display_name=lambda name: iface_(
+ bpy.path.display_name(name, title_case=False))
)
@classmethod