This commit is contained in:
Campbell Barton
2011-08-11 05:04:01 +00:00
63 changed files with 6767 additions and 6743 deletions

View File

@@ -379,7 +379,7 @@ def path_reference(filepath,
is_relative = filepath.startswith("//")
filepath_abs = os.path.normpath(bpy.path.abspath(filepath, base_src))
if mode in ('ABSOLUTE', 'RELATIVE', 'STRIP'):
if mode in {'ABSOLUTE', 'RELATIVE', 'STRIP'}:
pass
elif mode == 'MATCH':
mode = 'RELATIVE' if is_relative else 'ABSOLUTE'

View File

@@ -294,7 +294,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
'''
Normal single concave loop filling
'''
if type(from_data) in (tuple, list):
if type(from_data) in {tuple, list}:
verts = [Vector(from_data[i]) for ii, i in enumerate(indices)]
else:
verts = [from_data.vertices[i].co for ii, i in enumerate(indices)]
@@ -312,7 +312,7 @@ def ngon_tesselate(from_data, indices, fix_loops=True):
used twice. This is used by lightwave LWO files a lot
'''
if type(from_data) in (tuple, list):
if type(from_data) in {tuple, list}:
verts = [vert_treplet(Vector(from_data[i]), ii)
for ii, i in enumerate(indices)]
else:

View File

@@ -120,7 +120,7 @@ def fromxml(data):
py_item = (xml_node.tagName, _fromxml_kwargs(xml_node), [])
#_fromxml_iter(py_item, xml_node.childNodes)
for xml_node_child in xml_node.childNodes:
if xml_node_child.nodeType not in (xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE):
if xml_node_child.nodeType not in {xml_node_child.TEXT_NODE, xml_node_child.COMMENT_NODE}:
py_item[CHILDREN].append(_fromxml(xml_node_child))
return py_item

View File

@@ -40,13 +40,13 @@ def _parse_rna(prop, value):
elif prop.type == 'INT':
value = int(value)
elif prop.type == 'BOOLEAN':
if value in (True, False):
if value in {True, False}:
pass
else:
if value not in ("True", "False"):
if value not in {"True", "False"}:
raise Exception("invalid bool value: %s" % value)
value = bool(value == "True")
elif prop.type in ('STRING', 'ENUM'):
elif prop.type in {'STRING', 'ENUM'}:
pass
elif prop.type == 'POINTER':
value = eval("_bpy." + value)

View File

@@ -148,7 +148,7 @@ class InfoStructRNA:
import types
functions = []
for identifier, attr in self._get_py_visible_attrs():
if type(attr) in (types.FunctionType, types.MethodType):
if type(attr) in {types.FunctionType, types.MethodType}:
functions.append((identifier, attr))
return functions
@@ -156,7 +156,7 @@ class InfoStructRNA:
import types
functions = []
for identifier, attr in self._get_py_visible_attrs():
if type(attr) in (types.BuiltinMethodType, types.BuiltinFunctionType):
if type(attr) in {types.BuiltinMethodType, types.BuiltinFunctionType}:
functions.append((identifier, attr))
return functions
@@ -260,7 +260,7 @@ class InfoPropertyRNA:
if self.array_length:
type_str += " array of %d items" % (self.array_length)
if self.type in ("float", "int"):
if self.type in {"float", "int"}:
type_str += " in [%s, %s]" % (range_str(self.min), range_str(self.max))
elif self.type == "enum":
if self.is_enum_flag:
@@ -595,7 +595,7 @@ def BuildRNAInfo():
for prop in rna_info.properties:
# ERROR CHECK
default = prop.default
if type(default) in (float, int):
if type(default) in {float, int}:
if default < prop.min or default > prop.max:
print("\t %s.%s, %s not in [%s - %s]" % (rna_info.identifier, prop.identifier, default, prop.min, prop.max))

View File

@@ -61,13 +61,19 @@ class EditExternally(bpy.types.Operator):
def execute(self, context):
import os
import subprocess
filepath = os.path.normpath(bpy.path.abspath(self.filepath))
filepath = self.filepath
if not filepath:
self.report({'ERROR'}, "Image path not set")
return {'CANCELLED'}
filepath = os.path.normpath(bpy.path.abspath(filepath))
if not os.path.exists(filepath):
self.report({'ERROR'},
"Image path %r not found, image may be packed or "
"unsaved." % filepath)
return {'CANCELLED'}
cmd = self._editor_guess(context) + [filepath]

View File

@@ -23,7 +23,15 @@ import mathutils
class prettyface(object):
__slots__ = "uv", "width", "height", "children", "xoff", "yoff", "has_parent", "rot"
__slots__ = ("uv",
"width",
"height",
"children",
"xoff",
"yoff",
"has_parent",
"rot",
)
def __init__(self, data):
self.has_parent = False
@@ -263,10 +271,9 @@ def lightmap_uvpack(meshes,
del trylens
def trilensdiff(t1, t2):
return\
abs(t1[1][t1[2][0]] - t2[1][t2[2][0]]) + \
abs(t1[1][t1[2][1]] - t2[1][t2[2][1]]) + \
abs(t1[1][t1[2][2]] - t2[1][t2[2][2]])
return (abs(t1[1][t1[2][0]] - t2[1][t2[2][0]]) +
abs(t1[1][t1[2][1]] - t2[1][t2[2][1]]) +
abs(t1[1][t1[2][2]] - t2[1][t2[2][2]]))
while tri_lengths:
tri1 = tri_lengths.pop()
@@ -520,7 +527,7 @@ def unwrap(operator, context, **kwargs):
if obj and obj.type == 'MESH':
meshes = [obj.data]
else:
meshes = {me.name: me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if not me.library if len(me.faces)}.values()
meshes = list({me for obj in context.selected_objects if obj.type == 'MESH' for me in (obj.data,) if me.faces and me.library is None})
if not meshes:
operator.report({'ERROR'}, "No mesh object.")
@@ -543,22 +550,51 @@ class LightMapPack(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'}
PREF_CONTEXT = bpy.props.EnumProperty(
name="Selection",
description="",
items=(("SEL_FACES", "Selected Faces", "Space all UVs evently"),
("ALL_FACES", "All Faces", "Average space UVs edge length of each loop"),
("ALL_OBJECTS", "Selected Mesh Object", "Average space UVs edge length of each loop")
),
name="Selection",
description="")
)
# Image & UVs...
PREF_PACK_IN_ONE = BoolProperty(name="Share Tex Space", default=True, description="Objects Share texture space, map all objects into 1 uvmap")
PREF_NEW_UVLAYER = BoolProperty(name="New UV Layer", default=False, description="Create a new UV layer for every mesh packed")
PREF_APPLY_IMAGE = BoolProperty(name="New Image", default=False, description="Assign new images for every mesh (only one if shared tex space enabled)")
PREF_IMG_PX_SIZE = IntProperty(name="Image Size", min=64, max=5000, default=512, description="Width and Height for the new image")
PREF_PACK_IN_ONE = BoolProperty(
name="Share Tex Space",
description=("Objects Share texture space, map all objects "
"into 1 uvmap"),
default=True,
)
PREF_NEW_UVLAYER = BoolProperty(
name="New UV Layer",
description="Create a new UV layer for every mesh packed",
default=False,
)
PREF_APPLY_IMAGE = BoolProperty(
name="New Image",
description=("Assign new images for every mesh (only one if "
"shared tex space enabled)"),
default=False,
)
PREF_IMG_PX_SIZE = IntProperty(
name="Image Size",
description="Width and Height for the new image",
min=64, max=5000,
default=512,
)
# UV Packing...
PREF_BOX_DIV = IntProperty(name="Pack Quality", min=1, max=48, default=12, description="Pre Packing before the complex boxpack")
PREF_MARGIN_DIV = FloatProperty(name="Margin", min=0.001, max=1.0, default=0.1, description="Size of the margin as a division of the UV")
PREF_BOX_DIV = IntProperty(
name="Pack Quality",
description="Pre Packing before the complex boxpack",
min=1, max=48,
default=12,
)
PREF_MARGIN_DIV = FloatProperty(
name="Margin",
description="Size of the margin as a division of the UV",
min=0.001, max=1.0,
default=0.1,
)
def execute(self, context):
kwargs = self.as_keywords()

View File

@@ -586,7 +586,7 @@ class WM_OT_context_modal_mouse(bpy.types.Operator):
self._values_clear()
return {'FINISHED'}
elif event_type in ('RIGHTMOUSE', 'ESC'):
elif event_type in {'RIGHTMOUSE', 'ESC'}:
self._values_restore()
return {'FINISHED'}
@@ -839,7 +839,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
prop_ui = rna_idprop_ui_prop_get(item, prop)
if prop_type in (float, int):
if prop_type in {float, int}:
prop_ui['soft_min'] = prop_ui['min'] = prop_type(self.min)
prop_ui['soft_max'] = prop_ui['max'] = prop_type(self.max)

View File

@@ -361,7 +361,7 @@ class DATA_PT_paragraph(CurveButtonsPanel, bpy.types.Panel):
col.prop(text, "offset_y", text="Y")
class DATA_PT_textboxes(CurveButtonsPanel, bpy.types.Panel):
class DATA_PT_text_boxes(CurveButtonsPanel, bpy.types.Panel):
bl_label = "Text Boxes"
@classmethod

View File

@@ -462,7 +462,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel, bpy.types.Panel):
col.prop(part, "mass")
col.prop(part, "use_multiply_size_mass", text="Multiply mass with size")
if part.physics_type in ('NEWTON', 'FLUID'):
if part.physics_type in {'NEWTON', 'FLUID'}:
split = layout.split()
col = split.column()
@@ -921,7 +921,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, bpy.types.Panel):
col = row.column()
col.label(text="")
if part.render_type in ('OBJECT', 'GROUP') and not part.use_advanced_hair:
if part.render_type in {'OBJECT', 'GROUP'} and not part.use_advanced_hair:
row = layout.row(align=True)
row.prop(part, "particle_size")
row.prop(part, "size_random", slider=True)

View File

@@ -355,7 +355,7 @@ class INFO_MT_help(bpy.types.Menu):
layout = self.layout
layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-258/'
layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-259/'
layout.separator()

View File

@@ -1077,17 +1077,25 @@ class WM_OT_addon_enable(bpy.types.Operator):
bl_idname = "wm.addon_enable"
bl_label = "Enable Add-On"
module = StringProperty(name="Module", description="Module name of the addon to enable")
module = StringProperty(
name="Module",
description="Module name of the addon to enable",
)
def execute(self, context):
mod = addon_utils.enable(self.module)
if mod:
# check if add-on is written for current blender version, or raise a warning
info = addon_utils.module_bl_info(mod)
if info.get("blender", (0, 0, 0)) > bpy.app.version:
self.report("WARNING','This script was written for a newer version of Blender and might not function (correctly).\nThe script is enabled though.")
info_ver = info.get("blender", (0, 0, 0))
if info_ver > bpy.app.version:
self.report({'WARNING'}, ("This script was written Blender "
"version %d.%d.%d and might not "
"function (correctly).\n"
"The script is enabled though.") %
info_ver)
return {'FINISHED'}
else:
return {'CANCELLED'}

View File

@@ -542,22 +542,24 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
def execute(self, context):
from os.path import basename
import shutil
if not self.filepath:
raise Exception("Filepath not set")
f = open(self.filepath, "r")
if not f:
raise Exception("Could not open file")
if not self.filepath:
self.report({'ERROR'}, "Filepath not set")
return {'CANCELLED'}
config_name = basename(self.filepath)
path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", "keyconfig"), create=True)
path = os.path.join(path, config_name)
if self.keep_original:
shutil.copy(self.filepath, path)
else:
shutil.move(self.filepath, path)
try:
if self.keep_original:
shutil.copy(self.filepath, path)
else:
shutil.move(self.filepath, path)
except Exception as e:
self.report({'ERROR'}, "Installing keymap failed: %s" % e)
return {'CANCELLED'}
# sneaky way to check we're actually running the code.
bpy.utils.keyconfig_set(path)

View File

@@ -18,7 +18,7 @@ class ModalOperator(bpy.types.Operator):
elif event.type == 'LEFTMOUSE':
return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'):
elif event.type in {'RIGHTMOUSE', 'ESC'}:
context.object.location.x = self.first_value
return {'CANCELLED'}
@@ -47,4 +47,4 @@ if __name__ == "__main__":
register()
# test call
bpy.ops.object.modal_operator()
bpy.ops.object.modal_operator('INVOKE_DEFAULT')

View File

@@ -45,7 +45,7 @@ class ModalDrawOperator(bpy.types.Operator):
context.region.callback_remove(self._handle)
return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'):
elif event.type in {'RIGHTMOUSE', 'ESC'}:
context.region.callback_remove(self._handle)
return {'CANCELLED'}

View File

@@ -10,7 +10,7 @@ class ModalTimerOperator(bpy.types.Operator):
def modal(self, context, event):
if event.type == 'ESC':
return self.cancel()
return self.cancel(context)
if event.type == 'TIMER':
# change theme color, silly!

View File

@@ -29,7 +29,7 @@ class ViewOperator(bpy.types.Operator):
context.area.header_text_set()
return {'FINISHED'}
elif event.type in ('RIGHTMOUSE', 'ESC'):
elif event.type in {'RIGHTMOUSE', 'ESC'}:
rv3d.view_location = self._initial_location
context.area.header_text_set()
return {'CANCELLED'}