From d541a200c2fcac497ec2a52e6d3c8f31f7032f29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 23 Oct 2011 00:53:50 +0000 Subject: rename user interface operator properties from 'op' to 'props' --- .../scripts/startup/bl_ui/properties_data_mesh.py | 6 ++---- release/scripts/startup/bl_ui/properties_scene.py | 3 +-- release/scripts/startup/bl_ui/space_image.py | 24 +++++++++++----------- .../scripts/startup/bl_ui/space_userpref_keymap.py | 6 ++---- release/scripts/startup/bl_ui/space_view3d.py | 5 ++--- release/scripts/templates/driver_functions.py | 1 + 6 files changed, 20 insertions(+), 25 deletions(-) (limited to 'release') diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index ff19ece8f94..425b7a601c8 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -51,8 +51,7 @@ class MESH_MT_shape_key_specials(Menu): layout.operator("object.shape_key_transfer", icon='COPY_ID') # icon is not ideal layout.operator("object.join_shapes", icon='COPY_ID') # icon is not ideal layout.operator("object.shape_key_mirror", icon='ARROW_LEFTRIGHT') - op = layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Shape From Mix") - op.from_mix = True + layout.operator("object.shape_key_add", icon='ZOOMIN', text="New Shape From Mix").from_mix = True class MeshButtonsPanel(): @@ -207,8 +206,7 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel): col = row.column() sub = col.column(align=True) - op = sub.operator("object.shape_key_add", icon='ZOOMIN', text="") - op.from_mix = False + sub.operator("object.shape_key_add", icon='ZOOMIN', text="").from_mix = False sub.operator("object.shape_key_remove", icon='ZOOMOUT', text="") sub.menu("MESH_MT_shape_key_specials", icon='DOWNARROW_HLT', text="") diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 167cead9a3b..d3859a78bea 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -115,8 +115,7 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, Panel): subcol = col.column() subcol.operator_context = 'INVOKE_DEFAULT' - op = subcol.operator("anim.keying_set_export", text="Export to File") - op.filepath = "keyingset.py" + subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py" col = row.column() col.label(text="Keyframing Settings:") diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 051854a28f1..50db989a2e2 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -157,24 +157,24 @@ class IMAGE_MT_image_invert(Menu): def draw(self, context): layout = self.layout - op = layout.operator("image.invert", text="Invert Image Colors") - op.invert_r = True - op.invert_g = True - op.invert_b = True + props = layout.operator("image.invert", text="Invert Image Colors") + props.invert_r = True + props.invert_g = True + props.invert_b = True layout.separator() - op = layout.operator("image.invert", text="Invert Red Channel") - op.invert_r = True + props = layout.operator("image.invert", text="Invert Red Channel") + props.invert_r = True - op = layout.operator("image.invert", text="Invert Green Channel") - op.invert_g = True + props = layout.operator("image.invert", text="Invert Green Channel") + props.invert_g = True - op = layout.operator("image.invert", text="Invert Blue Channel") - op.invert_b = True + props = layout.operator("image.invert", text="Invert Blue Channel") + props.invert_b = True - op = layout.operator("image.invert", text="Invert Alpha Channel") - op.invert_a = True + props = layout.operator("image.invert", text="Invert Alpha Channel") + props.invert_a = True class IMAGE_MT_uvs_showhide(Menu): diff --git a/release/scripts/startup/bl_ui/space_userpref_keymap.py b/release/scripts/startup/bl_ui/space_userpref_keymap.py index 2c537efa61b..5e5ce462da9 100644 --- a/release/scripts/startup/bl_ui/space_userpref_keymap.py +++ b/release/scripts/startup/bl_ui/space_userpref_keymap.py @@ -164,11 +164,9 @@ class InputKeyMapPanel: row.label() if (not kmi.is_user_defined) and kmi.is_user_modified: - op = row.operator("wm.keyitem_restore", text="", icon='BACK') - op.item_id = kmi.id + row.operator("wm.keyitem_restore", text="", icon='BACK').item_id = kmi.id else: - op = row.operator("wm.keyitem_remove", text="", icon='X') - op.item_id = kmi.id + row.operator("wm.keyitem_remove", text="", icon='X').item_id = kmi.id # Expanded, additional event settings if kmi.show_expanded: diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c6a26cd9bbf..1170bce2c14 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -54,11 +54,10 @@ class VIEW3D_HT_header(Header): else: sub.menu("VIEW3D_MT_object") - # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode... - row = layout.row() #XXX Narrowed down vert/edge/face selector in edit mode/solid drawmode. -DingTo + row = layout.row() # XXX Narrowed down vert/edge/face selector in edit mode/solid drawmode. -DingTo row.template_header_3D() - + if obj: # Particle edit if obj.mode == 'PARTICLE_EDIT': diff --git a/release/scripts/templates/driver_functions.py b/release/scripts/templates/driver_functions.py index db9d4fb4678..1c6af0e574f 100644 --- a/release/scripts/templates/driver_functions.py +++ b/release/scripts/templates/driver_functions.py @@ -16,6 +16,7 @@ def invert(f): uuid_store = {} + def slow_value(value, fac, uuid): """ Delay the value by a factor, use a unique string to allow use in multiple drivers without conflict: -- cgit v1.2.3 From 0f5f502f9e433e6f353ccd126e575d9ff9f85689 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 23 Oct 2011 12:17:24 +0000 Subject: minor formatting edits (80 char width) --- release/scripts/modules/bpy_types.py | 133 +++++++++++++++++++++--------- release/scripts/modules/console_python.py | 28 ++++--- 2 files changed, 113 insertions(+), 48 deletions(-) (limited to 'release') diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index cee0712e814..088e239e9a5 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -16,7 +16,7 @@ # # ##### END GPL LICENSE BLOCK ##### -# +# from _bpy import types as bpy_types import _bpy @@ -34,7 +34,8 @@ class Context(StructRNA): def copy(self): from types import BuiltinMethodType new_context = {} - generic_attrs = list(StructRNA.__dict__.keys()) + ["bl_rna", "rna_type", "copy"] + generic_attrs = (list(StructRNA.__dict__.keys()) + + ["bl_rna", "rna_type", "copy"]) for attr in dir(self): if not (attr.startswith("_") or attr in generic_attrs): value = getattr(self, attr) @@ -52,14 +53,19 @@ class Library(bpy_types.ID): """ID data blocks which use this library""" import bpy - # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE, we could make this an attribute in rna. - attr_links = "actions", "armatures", "brushes", "cameras", \ - "curves", "grease_pencil", "groups", "images", \ - "lamps", "lattices", "materials", "metaballs", \ - "meshes", "node_groups", "objects", "scenes", \ - "sounds", "speakers", "textures", "texts", "fonts", "worlds" + # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE, + # we could make this an attribute in rna. + attr_links = ("actions", "armatures", "brushes", "cameras", + "curves", "grease_pencil", "groups", "images", + "lamps", "lattices", "materials", "metaballs", + "meshes", "node_groups", "objects", "scenes", + "sounds", "speakers", "textures", "texts", + "fonts", "worlds") - return tuple(id_block for attr in attr_links for id_block in getattr(bpy.data, attr) if id_block.library == self) + return tuple(id_block + for attr in attr_links + for id_block in getattr(bpy.data, attr) + if id_block.library == self) class Texture(bpy_types.ID): @@ -69,13 +75,21 @@ class Texture(bpy_types.ID): def users_material(self): """Materials that use this texture""" import bpy - return tuple(mat for mat in bpy.data.materials if self in [slot.texture for slot in mat.texture_slots if slot]) + return tuple(mat for mat in bpy.data.materials + if self in [slot.texture + for slot in mat.texture_slots + if slot] + ) @property def users_object_modifier(self): """Object modifiers that use this texture""" import bpy - return tuple(obj for obj in bpy.data.objects if self in [mod.texture for mod in obj.modifiers if mod.type == 'DISPLACE']) + return tuple(obj for obj in bpy.data.objects if + self in [mod.texture + for mod in obj.modifiers + if mod.type == 'DISPLACE'] + ) class Group(bpy_types.ID): @@ -85,7 +99,8 @@ class Group(bpy_types.ID): def users_dupli_group(self): """The dupli group this group is used in""" import bpy - return tuple(obj for obj in bpy.data.objects if self == obj.dupli_group) + return tuple(obj for obj in bpy.data.objects + if self == obj.dupli_group) class Object(bpy_types.ID): @@ -95,19 +110,22 @@ class Object(bpy_types.ID): def children(self): """All the children of this object""" import bpy - return tuple(child for child in bpy.data.objects if child.parent == self) + return tuple(child for child in bpy.data.objects + if child.parent == self) @property def users_group(self): """The groups this object is in""" import bpy - return tuple(group for group in bpy.data.groups if self in group.objects[:]) + return tuple(group for group in bpy.data.groups + if self in group.objects[:]) @property def users_scene(self): """The scenes this object is in""" import bpy - return tuple(scene for scene in bpy.data.scenes if self in scene.objects[:]) + return tuple(scene for scene in bpy.data.scenes + if self in scene.objects[:]) class _GenericBone: @@ -118,13 +136,14 @@ class _GenericBone: __slots__ = () def translate(self, vec): - """Utility function to add *vec* to the head and tail of this bone.""" + """Utility function to add *vec* to the head and tail of this bone""" self.head += vec self.tail += vec def parent_index(self, parent_test): """ - The same as 'bone in other_bone.parent_recursive' but saved generating a list. + The same as 'bone in other_bone.parent_recursive' + but saved generating a list. """ # use the name so different types can be tested. name = parent_test.name @@ -187,7 +206,9 @@ class _GenericBone: @property def length(self): - """The distance from head to tail, when set the head is moved to fit the length.""" + """ The distance from head to tail, + when set the head is moved to fit the length. + """ return self.vector.length @length.setter @@ -196,7 +217,9 @@ class _GenericBone: @property def vector(self): - """The direction this bone is pointing. Utility function for (tail - head)""" + """ The direction this bone is pointing. + Utility function for (tail - head) + """ return (self.tail - self.head) @property @@ -222,7 +245,8 @@ class _GenericBone: """ Returns a chain of children with the same base name as this bone. Only direct chains are supported, forks caused by multiple children - with matching base names will terminate the function and not be returned. + with matching base names will terminate the function + and not be returned. """ basename = self.basename chain = [] @@ -241,7 +265,9 @@ class _GenericBone: chain.append(child) else: if len(children_basename): - print("multiple basenames found, this is probably not what you want!", self.name, children_basename) + print("multiple basenames found, " + "this is probably not what you want!", + self.name, children_basename) break @@ -284,13 +310,18 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): def transform(self, matrix, scale=True, roll=True): """ - Transform the the bones head, tail, roll and envelope (when the matrix has a scale component). + Transform the the bones head, tail, roll and envelope + (when the matrix has a scale component). :arg matrix: 3x3 or 4x4 transformation matrix. :type matrix: :class:`mathutils.Matrix` :arg scale: Scale the bone envelope by the matrix. :type scale: bool - :arg roll: Correct the roll to point in the same relative direction to the head and tail. + :arg roll: + + Correct the roll to point in the same relative + direction to the head and tail. + :type roll: bool """ from mathutils import Vector @@ -321,11 +352,23 @@ class Mesh(bpy_types.ID): Make a mesh from a list of vertices/edges/faces Until we have a nicer way to make geometry, use this. - :arg vertices: float triplets each representing (X, Y, Z) eg: [(0.0, 1.0, 0.5), ...]. + :arg vertices: + + float triplets each representing (X, Y, Z) + eg: [(0.0, 1.0, 0.5), ...]. + :type vertices: iterable object - :arg edges: int pairs, each pair contains two indices to the *vertices* argument. eg: [(1, 2), ...] + :arg edges: + + int pairs, each pair contains two indices to the + *vertices* argument. eg: [(1, 2), ...] + :type edges: iterable object - :arg faces: iterator of faces, each faces contains three or four indices to the *vertices* argument. eg: [(5, 6, 8, 9), (1, 2, 3), ...] + :arg faces: + + iterator of faces, each faces contains three or four indices to + the *vertices* argument. eg: [(5, 6, 8, 9), (1, 2, 3), ...] + :type faces: iterable object """ self.vertices.add(len(vertices)) @@ -419,7 +462,10 @@ class Text(bpy_types.ID): def users_logic(self): """Logic bricks that use this text""" import bpy - return tuple(obj for obj in bpy.data.objects if self in [cont.text for cont in obj.game.controllers if cont.type == 'PYTHON']) + return tuple(obj for obj in bpy.data.objects + if self in [cont.text for cont in obj.game.controllers + if cont.type == 'PYTHON'] + ) # values are module: [(cls, path, line), ...] TypeMap = {} @@ -510,10 +556,11 @@ class Operator(StructRNA, metaclass=OrderedMeta): return super().__delattr__(attr) def as_keywords(self, ignore=()): - """ Return a copy of the properties as a dictionary. - """ + """Return a copy of the properties as a dictionary""" ignore = ignore + ("rna_type",) - return {attr: getattr(self, attr) for attr in self.properties.rna_type.properties.keys() if attr not in ignore} + return {attr: getattr(self, attr) + for attr in self.properties.rna_type.properties.keys() + if attr not in ignore} class Macro(StructRNA, metaclass=OrderedMeta): @@ -553,7 +600,8 @@ class _GenericUI: operator_context_default = self.layout.operator_context for func in draw_ls._draw_funcs: - # so bad menu functions don't stop the entire menu from drawing + # so bad menu functions don't stop + # the entire menu from drawing try: func(self, context) except: @@ -569,13 +617,19 @@ class _GenericUI: @classmethod def append(cls, draw_func): - """Append a draw function to this menu, takes the same arguments as the menus draw function.""" + """ + Append a draw function to this menu, + takes the same arguments as the menus draw function + """ draw_funcs = cls._dyn_ui_initialize() draw_funcs.append(draw_func) @classmethod def prepend(cls, draw_func): - """Prepend a draw function to this menu, takes the same arguments as the menus draw function.""" + """ + Prepend a draw function to this menu, takes the same arguments as + the menus draw function + """ draw_funcs = cls._dyn_ui_initialize() draw_funcs.insert(0, draw_func) @@ -615,7 +669,8 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): # collect paths files = [] for directory in searchpaths: - files.extend([(f, os.path.join(directory, f)) for f in os.listdir(directory)]) + files.extend([(f, os.path.join(directory, f)) + for f in os.listdir(directory)]) files.sort() @@ -635,9 +690,11 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): props.menu_idname = self.bl_idname def draw_preset(self, context): - """Define these on the subclass - - preset_operator - - preset_subdir + """ + Define these on the subclass + - preset_operator + - preset_subdir """ import bpy - self.path_menu(bpy.utils.preset_paths(self.preset_subdir), self.preset_operator) + self.path_menu(bpy.utils.preset_paths(self.preset_subdir), + self.preset_operator) diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py index f11ccf84f0b..6c49283b3e1 100644 --- a/release/scripts/modules/console_python.py +++ b/release/scripts/modules/console_python.py @@ -16,11 +16,11 @@ # # ##### END GPL LICENSE BLOCK ##### -# +# import sys import bpy -language_id = 'python' +language_id = "python" # store our own __main__ module, not 100% needed # but python expects this in some places @@ -28,8 +28,8 @@ _BPY_MAIN_OWN = True def add_scrollback(text, text_type): - for l in text.split('\n'): - bpy.ops.console.scrollback_append(text=l.replace('\t', ' '), + for l in text.split("\n"): + bpy.ops.console.scrollback_append(text=l.replace("\t", " "), type=text_type) @@ -81,7 +81,8 @@ def get_console(console_id): console, stdout, stderr = console_data # XXX, bug in python 3.1.2, 3.2 ? (worked in 3.1.1) - # seems there is no way to clear StringIO objects for writing, have to make new ones each time. + # seems there is no way to clear StringIO objects for writing, have to + # make new ones each time. import io stdout = io.StringIO() stderr = io.StringIO() @@ -99,7 +100,8 @@ def get_console(console_id): replace_help(namespace) - console = InteractiveConsole(locals=namespace, filename="") + console = InteractiveConsole(locals=namespace, + filename="") console.push("from mathutils import *") console.push("from math import *") @@ -265,7 +267,8 @@ def autocomplete(context): # Separate autocomplete output by command prompts if scrollback != '': - bpy.ops.console.scrollback_append(text=sc.prompt + current_line.body, type='INPUT') + bpy.ops.console.scrollback_append(text=sc.prompt + current_line.body, + type='INPUT') # Now we need to copy back the line from blender back into the # text editor. This will change when we don't use the text editor @@ -296,10 +299,15 @@ def banner(context): add_scrollback("Execute: Enter", 'OUTPUT') add_scrollback("Autocomplete: Ctrl+Space", 'OUTPUT') add_scrollback("Ctrl +/- Wheel: Zoom", 'OUTPUT') - add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils", 'OUTPUT') - add_scrollback("Convenience Imports: from mathutils import *; from math import *", 'OUTPUT') + add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, " + "bpy.props, bpy.types, bpy.context, bpy.utils, " + "bgl, blf, mathutils", + 'OUTPUT') + add_scrollback("Convenience Imports: from mathutils import *; " + "from math import *", 'OUTPUT') add_scrollback("", 'OUTPUT') - # add_scrollback(" WARNING!!! Blender 2.5 API is subject to change, see API reference for more info", 'ERROR') + # add_scrollback(" WARNING!!! Blender 2.5 API is subject to change, " + # "see API reference for more info", 'ERROR') # add_scrollback("", 'OUTPUT') sc.prompt = PROMPT -- cgit v1.2.3