forked from bartvdbraak/blender
pep8 whitespace commit
bpy/rna api (no functionality change, just move getting the srna py base into a function)
This commit is contained in:
parent
5bb88685ca
commit
4e61f8a836
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
@ -19,7 +19,7 @@
|
||||
def ord_ind(i1,i2):
|
||||
if i1<i2: return i1,i2
|
||||
return i2,i1
|
||||
|
||||
|
||||
def edge_key(ed):
|
||||
v1, v2 = tuple(ed.verts)
|
||||
return ord_ind(v1, v2)
|
||||
@ -28,18 +28,18 @@ def face_edge_keys(face):
|
||||
verts = tuple(face.verts)
|
||||
if len(verts)==3:
|
||||
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[0])
|
||||
|
||||
|
||||
return ord_ind(verts[0], verts[1]), ord_ind(verts[1], verts[2]), ord_ind(verts[2], verts[3]), ord_ind(verts[3], verts[0])
|
||||
|
||||
def mesh_edge_keys(mesh):
|
||||
return [edge_key for face in mesh.faces for edge_key in face.edge_keys()]
|
||||
|
||||
def mesh_edge_face_count_dict(mesh, face_edge_keys=None):
|
||||
|
||||
|
||||
# Optional speedup
|
||||
if face_edge_keys==None:
|
||||
face_edge_keys = [face.edge_keys() for face in face_list]
|
||||
|
||||
|
||||
face_edge_count = {}
|
||||
for face_keys in face_edge_keys:
|
||||
for key in face_keys:
|
||||
@ -47,8 +47,8 @@ def mesh_edge_face_count_dict(mesh, face_edge_keys=None):
|
||||
face_edge_count[key] += 1
|
||||
except:
|
||||
face_edge_count[key] = 1
|
||||
|
||||
|
||||
|
||||
|
||||
return face_edge_count
|
||||
|
||||
def mesh_edge_face_count(mesh, face_edge_keys=None):
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
@ -127,11 +127,11 @@ class bpy_ops_submodule_op(object):
|
||||
'''
|
||||
|
||||
__keys__ = ('module', 'func')
|
||||
|
||||
|
||||
|
||||
|
||||
def _get_doc(self):
|
||||
return op_as_string(self.idname())
|
||||
|
||||
|
||||
__doc__ = property(_get_doc)
|
||||
|
||||
def __init__(self, module, func):
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -4,12 +4,12 @@
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
@ -190,11 +190,11 @@ class DATA_PT_shape_keys(DataButtonsPanel):
|
||||
else:
|
||||
subrow1.itemR(kb, "mute", icon='ICON_MUTE_IPO_OFF', text="")
|
||||
subrow.itemR(ob, "shape_key_edit_mode", text="")
|
||||
|
||||
|
||||
subrow = sub.row(align=True)
|
||||
subrow.itemO("object.shape_key_mirror", icon='ICON_ARROW_LEFTRIGHT', text="")
|
||||
subrow.itemO("object.shape_key_clear", icon='ICON_X', text="")
|
||||
|
||||
|
||||
|
||||
row = layout.row()
|
||||
row.itemR(kb, "name")
|
||||
|
@ -88,7 +88,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
col = split.column()
|
||||
col.itemR(con, "chain_length")
|
||||
col.itemR(con, "targetless")
|
||||
|
||||
|
||||
def CHILD_OF(self, context, layout, con):
|
||||
self.target_template(layout, con)
|
||||
|
||||
@ -129,7 +129,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
row.itemR(con, "target_z")
|
||||
|
||||
self.space_template(layout, con)
|
||||
|
||||
|
||||
def IK(self, context, layout, con):
|
||||
if context.object.pose.ik_solver == "ITASC":
|
||||
layout.itemR(con, "ik_type")
|
||||
@ -168,7 +168,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
sub = col.column()
|
||||
sub.active = con.rotation
|
||||
sub.itemR(con, "orient_weight", text="Rotation", slider=True)
|
||||
|
||||
|
||||
def IK_COPY_POSE(self, context, layout, con):
|
||||
self.target_template(layout, con)
|
||||
self.ik_template(layout, con)
|
||||
@ -212,7 +212,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.itemR(con, "weight", text="Weight", slider=True)
|
||||
row.itemR(con, "distance", text="Distance", slider=True)
|
||||
|
||||
|
||||
def FOLLOW_PATH(self, context, layout, con):
|
||||
self.target_template(layout, con)
|
||||
|
||||
@ -310,7 +310,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.itemL(text="Convert:")
|
||||
row.itemR(con, "owner_space", text="")
|
||||
|
||||
|
||||
def LIMIT_SCALE(self, context, layout, con):
|
||||
split = layout.split()
|
||||
|
||||
@ -351,7 +351,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
row = layout.row()
|
||||
row.itemL(text="Convert:")
|
||||
row.itemR(con, "owner_space", text="")
|
||||
|
||||
|
||||
def COPY_ROTATION(self, context, layout, con):
|
||||
self.target_template(layout, con)
|
||||
|
||||
@ -378,7 +378,7 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
||||
layout.itemR(con, "offset")
|
||||
|
||||
self.space_template(layout, con)
|
||||
|
||||
|
||||
def COPY_LOCATION(self, context, layout, con):
|
||||
self.target_template(layout, con)
|
||||
|
||||
|
@ -89,16 +89,16 @@ class CONSOLE_MT_language(bpy.types.Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.column()
|
||||
|
||||
|
||||
mod = bpy.ops.console
|
||||
languages = []
|
||||
for opname in dir(mod):
|
||||
# execute_python, execute_shell etc.
|
||||
if opname.startswith("execute_"):
|
||||
languages.append(opname.split('_', 1)[-1])
|
||||
|
||||
|
||||
languages.sort()
|
||||
|
||||
|
||||
for language in languages:
|
||||
layout.item_stringO("console.language", "language", language, text=language[0].upper() + language[1:])
|
||||
|
||||
@ -155,13 +155,13 @@ class ConsoleBanner(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
sc = context.space_data
|
||||
|
||||
|
||||
# default to python
|
||||
if not sc.language:
|
||||
sc.language = 'python'
|
||||
|
||||
banner = getattr(bpy.ops.console, "banner_" + sc.language, None)
|
||||
|
||||
|
||||
if banner:
|
||||
banner()
|
||||
else:
|
||||
@ -178,12 +178,12 @@ class ConsoleLanguage(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
sc = context.space_data
|
||||
|
||||
|
||||
# defailt to python
|
||||
sc.language = self.language
|
||||
|
||||
|
||||
bpy.ops.console.banner()
|
||||
|
||||
|
||||
# insert a new blank line
|
||||
bpy.ops.console.history_append(text="", current_character=0,
|
||||
remove_duplicates=True)
|
||||
|
@ -187,9 +187,9 @@ class INFO_MT_add(bpy.types.Menu):
|
||||
layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
|
||||
|
||||
layout.itemS()
|
||||
|
||||
|
||||
layout.operator_context = "INVOKE_SCREEN"
|
||||
|
||||
|
||||
layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
|
||||
layout.item_enumO("object.add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
|
||||
layout.item_enumO("object.add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
|
||||
@ -197,9 +197,9 @@ class INFO_MT_add(bpy.types.Menu):
|
||||
layout.itemS()
|
||||
|
||||
layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
|
||||
|
||||
|
||||
layout.operator_context = "EXEC_SCREEN"
|
||||
|
||||
|
||||
layout.item_menu_enumO("object.lamp_add", "type", 'LAMP', text="Lamp", icon='ICON_OUTLINER_OB_LAMP')
|
||||
|
||||
layout.itemS()
|
||||
|
@ -644,7 +644,7 @@ class VIEW3D_MT_make_links(bpy.types.Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
|
||||
layout.item_menu_enumO("object.make_links_scene", "type", text="Objects to Scene...")
|
||||
|
||||
layout.items_enumO("object.make_links_data", property="type") # inline
|
||||
@ -1373,26 +1373,26 @@ class VIEW3D_PT_3dview_item(bpy.types.Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Item"
|
||||
|
||||
|
||||
def poll(self, context):
|
||||
return (context.active_object or context.bone or context.edit_bone)
|
||||
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
|
||||
ob = context.object
|
||||
|
||||
|
||||
row = layout.row()
|
||||
row.itemL(text="", icon='ICON_OBJECT_DATA')
|
||||
row.itemR(ob, "name", text="")
|
||||
|
||||
|
||||
if ((context.active_bone or context.active_pchan) and ob.type == 'ARMATURE' and (ob.mode == 'EDIT' or ob.mode == 'POSE')):
|
||||
bone = context.active_bone
|
||||
if not bone:
|
||||
pchan = context.active_pchan
|
||||
if pchan:
|
||||
bone = pchan.bone
|
||||
|
||||
|
||||
row = layout.row()
|
||||
row.itemL(text="", icon='ICON_BONE_DATA')
|
||||
row.itemR(bone, "name", text="")
|
||||
|
@ -111,7 +111,7 @@ class VIEW3D_PT_tools_meshedit(View3DPanel):
|
||||
col = layout.column(align=True)
|
||||
col.itemL(text="UV Mapping:")
|
||||
col.item_stringO("wm.call_menu", "name", "VIEW3D_MT_uv_map", text="Unwrap")
|
||||
|
||||
|
||||
col.itemO("mesh.uvs_rotate")
|
||||
col.itemO("mesh.uvs_mirror")
|
||||
|
||||
|
@ -2539,7 +2539,32 @@ PyObject *BPy_GetStructRNA(PyObject *self)
|
||||
}
|
||||
*/
|
||||
|
||||
PyObject* pyrna_srna_Subtype(StructRNA *srna)
|
||||
static PyObject* pyrna_srna_Subtype(StructRNA *srna);
|
||||
|
||||
/* return a borrowed reference */
|
||||
static PyObject* pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dict)
|
||||
{
|
||||
/* Assume RNA_struct_py_type_get(srna) was already checked */
|
||||
StructRNA *base;
|
||||
|
||||
PyObject *py_base= NULL;
|
||||
|
||||
/* get the base type */
|
||||
base= RNA_struct_base(srna);
|
||||
if(base && base != srna) {
|
||||
/*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
|
||||
py_base= pyrna_srna_Subtype(base); //, bpy_types_dict);
|
||||
Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */
|
||||
}
|
||||
|
||||
if(py_base==NULL) {
|
||||
py_base= (PyObject *)&pyrna_struct_Type;
|
||||
}
|
||||
|
||||
return py_base;
|
||||
}
|
||||
|
||||
static PyObject* pyrna_srna_Subtype(StructRNA *srna)
|
||||
{
|
||||
PyObject *newclass = NULL;
|
||||
|
||||
@ -2555,27 +2580,13 @@ PyObject* pyrna_srna_Subtype(StructRNA *srna)
|
||||
*/
|
||||
|
||||
/* Assume RNA_struct_py_type_get(srna) was alredy checked */
|
||||
StructRNA *base;
|
||||
|
||||
PyObject *py_base= NULL;
|
||||
PyObject *py_base= pyrna_srna_PyBase(srna);
|
||||
|
||||
const char *idname= RNA_struct_identifier(srna);
|
||||
const char *descr= RNA_struct_ui_description(srna);
|
||||
|
||||
if(!descr) descr= "(no docs)";
|
||||
|
||||
/* get the base type */
|
||||
base= RNA_struct_base(srna);
|
||||
if(base && base != srna) {
|
||||
/*/printf("debug subtype %s %p\n", RNA_struct_identifier(srna), srna); */
|
||||
py_base= pyrna_srna_Subtype(base);
|
||||
Py_DECREF(py_base); /* srna owns, this is only to pass as an arg */
|
||||
}
|
||||
|
||||
if(py_base==NULL) {
|
||||
py_base= (PyObject *)&pyrna_struct_Type;
|
||||
}
|
||||
|
||||
/* always use O not N when calling, N causes refcount errors */
|
||||
newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr);
|
||||
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
|
||||
@ -2611,7 +2622,7 @@ static StructRNA *srna_from_ptr(PointerRNA *ptr)
|
||||
}
|
||||
|
||||
/* always returns a new ref, be sure to decref when done */
|
||||
PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
static PyObject* pyrna_struct_Subtype(PointerRNA *ptr)
|
||||
{
|
||||
return pyrna_srna_Subtype(srna_from_ptr(ptr));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user