pep8 cleanup
This commit is contained in:
@@ -35,6 +35,7 @@ FLAG_MESSAGES = {
|
||||
FORBIDDEN: "Explicitly forbidden!",
|
||||
}
|
||||
|
||||
|
||||
def gen_menu_file(stats, settings):
|
||||
# Generate languages file used by Blender's i18n system.
|
||||
# First, match all entries in LANGUAGES to a lang in stats, if possible!
|
||||
|
@@ -507,7 +507,8 @@ def keyconfig_set(filepath, report=None):
|
||||
report({'ERROR'}, error_msg)
|
||||
print(error_msg)
|
||||
|
||||
kc_new = next(chain(iter(kc for kc in keyconfigs if kc not in keyconfigs_old), (None,)))
|
||||
kc_new = next(chain(iter(kc for kc in keyconfigs
|
||||
if kc not in keyconfigs_old), (None,)))
|
||||
if kc_new is None:
|
||||
if report is not None:
|
||||
report({'ERROR'}, "Failed to load keymap %r" % filepath)
|
||||
|
@@ -110,7 +110,7 @@ def complete_indices(word, namespace, obj=None, base=None):
|
||||
# dictionary type
|
||||
matches = ['%s[%r]' % (base, key) for key in sorted(obj.keys())]
|
||||
else:
|
||||
# list type,
|
||||
# list type
|
||||
matches = ['%s[%d]' % (base, idx) for idx in range(obj_len)]
|
||||
if word != base:
|
||||
matches = [match for match in matches if match.startswith(word)]
|
||||
|
@@ -42,6 +42,7 @@ class NodeCategory():
|
||||
yield item
|
||||
self.items = items_gen
|
||||
|
||||
|
||||
class NodeItem():
|
||||
def __init__(self, nodetype, label=None, settings={}, poll=None):
|
||||
self.nodetype = nodetype
|
||||
@@ -81,6 +82,7 @@ class NodeItemCustom():
|
||||
|
||||
_node_categories = {}
|
||||
|
||||
|
||||
def register_node_categories(identifier, cat_list):
|
||||
if identifier in _node_categories:
|
||||
raise KeyError("Node categories list '%s' already registered" % identifier)
|
||||
@@ -97,21 +99,21 @@ def register_node_categories(identifier, cat_list):
|
||||
menu_types = []
|
||||
panel_types = []
|
||||
for cat in cat_list:
|
||||
menu_type = type("NODE_MT_category_"+cat.identifier, (bpy.types.Menu,), {
|
||||
"bl_space_type" : 'NODE_EDITOR',
|
||||
"bl_label" : cat.name,
|
||||
"category" : cat,
|
||||
"poll" : cat.poll,
|
||||
"draw" : draw_node_item,
|
||||
menu_type = type("NODE_MT_category_" + cat.identifier, (bpy.types.Menu,), {
|
||||
"bl_space_type": 'NODE_EDITOR',
|
||||
"bl_label": cat.name,
|
||||
"category": cat,
|
||||
"poll": cat.poll,
|
||||
"draw": draw_node_item,
|
||||
})
|
||||
panel_type = type("NODE_PT_category_"+cat.identifier, (bpy.types.Panel,), {
|
||||
"bl_space_type" : 'NODE_EDITOR',
|
||||
"bl_region_type" : 'TOOLS',
|
||||
"bl_label" : cat.name,
|
||||
"bl_options" : {'DEFAULT_CLOSED'},
|
||||
"category" : cat,
|
||||
"poll" : cat.poll,
|
||||
"draw" : draw_node_item,
|
||||
panel_type = type("NODE_PT_category_" + cat.identifier, (bpy.types.Panel,), {
|
||||
"bl_space_type": 'NODE_EDITOR',
|
||||
"bl_region_type": 'TOOLS',
|
||||
"bl_label": cat.name,
|
||||
"bl_options": {'DEFAULT_CLOSED'},
|
||||
"category": cat,
|
||||
"poll": cat.poll,
|
||||
"draw": draw_node_item,
|
||||
})
|
||||
|
||||
menu_types.append(menu_type)
|
||||
@@ -166,4 +168,3 @@ def unregister_node_categories(identifier=None):
|
||||
for cat_types in _node_categories.values():
|
||||
unregister_node_cat_types(cat_types)
|
||||
_node_categories.clear()
|
||||
|
||||
|
@@ -18,9 +18,17 @@
|
||||
|
||||
# <pep8-80 compliant>
|
||||
|
||||
import bpy, nodeitems_utils
|
||||
from bpy.types import Operator, PropertyGroup
|
||||
from bpy.props import BoolProperty, CollectionProperty, EnumProperty, IntProperty, StringProperty
|
||||
import bpy
|
||||
import nodeitems_utils
|
||||
from bpy.types import (Operator,
|
||||
PropertyGroup,
|
||||
)
|
||||
from bpy.props import (BoolProperty,
|
||||
CollectionProperty,
|
||||
EnumProperty,
|
||||
IntProperty,
|
||||
StringProperty,
|
||||
)
|
||||
|
||||
|
||||
class NodeSetting(PropertyGroup):
|
||||
@@ -30,6 +38,7 @@ class NodeSetting(PropertyGroup):
|
||||
default="",
|
||||
)
|
||||
|
||||
|
||||
# Base class for node 'Add' operators
|
||||
class NodeAddOperator():
|
||||
|
||||
@@ -84,8 +93,8 @@ class NodeAddOperator():
|
||||
try:
|
||||
setattr(node, setting.name, value)
|
||||
except AttributeError as e:
|
||||
self.report({'ERROR_INVALID_INPUT'}, "Node has no attribute "+setting.name)
|
||||
print (str(e))
|
||||
self.report({'ERROR_INVALID_INPUT'}, "Node has no attribute " + setting.name)
|
||||
print(str(e))
|
||||
# Continue despite invalid attribute
|
||||
|
||||
if space.use_hidden_preview:
|
||||
|
@@ -30,7 +30,9 @@ class AddPresetBase():
|
||||
- preset_subdir """
|
||||
# bl_idname = "script.preset_base_add"
|
||||
# bl_label = "Add a Python Preset"
|
||||
bl_options = {'REGISTER', 'INTERNAL'} # only because invoke_props_popup requires. Also do not add to search menu.
|
||||
|
||||
# only because invoke_props_popup requires. Also do not add to search menu.
|
||||
bl_options = {'REGISTER', 'INTERNAL'}
|
||||
|
||||
name = StringProperty(
|
||||
name="Name",
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
# Contributor(s): Keith "Wahooney" Boshoff, Campbell Barton
|
||||
|
||||
|
||||
def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, dirt_only):
|
||||
from mathutils import Vector
|
||||
from math import acos
|
||||
|
@@ -138,7 +138,7 @@ class VIEW3D_OT_select_or_deselect_all(Operator):
|
||||
x = event.mouse_region_x
|
||||
y = event.mouse_region_y
|
||||
|
||||
if self.extend == False and self.toggle == False and self.deselect == False:
|
||||
if self.extend is False and self.toggle is False and self.deselect is False:
|
||||
active_object = context.active_object
|
||||
|
||||
if active_object:
|
||||
|
@@ -1180,6 +1180,7 @@ class WM_OT_keyconfig_activate(Operator):
|
||||
else:
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
class WM_OT_appconfig_default(Operator):
|
||||
bl_idname = "wm.appconfig_default"
|
||||
bl_label = "Default Application Configuration"
|
||||
@@ -1576,6 +1577,7 @@ class WM_OT_addon_enable(Operator):
|
||||
import addon_utils
|
||||
|
||||
err_str = ""
|
||||
|
||||
def err_cb():
|
||||
import traceback
|
||||
nonlocal err_str
|
||||
@@ -1618,6 +1620,7 @@ class WM_OT_addon_disable(Operator):
|
||||
import addon_utils
|
||||
|
||||
err_str = ""
|
||||
|
||||
def err_cb():
|
||||
import traceback
|
||||
nonlocal err_str
|
||||
|
@@ -78,6 +78,7 @@ class RENDER_PT_dimensions(RenderButtonsPanel, Panel):
|
||||
|
||||
_frame_rate_args_prev = None
|
||||
_preset_class = None
|
||||
|
||||
@staticmethod
|
||||
def _draw_framerate_label(*args):
|
||||
# avoids re-creating text string each draw
|
||||
|
@@ -336,7 +336,8 @@ class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
|
||||
col.prop(settings, "use_keyframe_selection")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.active = not settings.use_tripod_solver and not settings.use_keyframe_selection
|
||||
col.active = (not settings.use_tripod_solver and
|
||||
not settings.use_keyframe_selection)
|
||||
col.prop(tracking_object, "keyframe_a")
|
||||
col.prop(tracking_object, "keyframe_b")
|
||||
|
||||
@@ -408,7 +409,7 @@ class CLIP_PT_tools_orientation(CLIP_PT_reconstruction_panel, Panel):
|
||||
layout.separator()
|
||||
|
||||
col = layout.column()
|
||||
row = col.row(align=True);
|
||||
row = col.row(align=True)
|
||||
row.operator("clip.set_scale")
|
||||
row.operator("clip.apply_solution_scale", text="Apply Scale")
|
||||
col.prop(settings, "distance")
|
||||
|
@@ -756,7 +756,6 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
|
||||
sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
|
||||
|
||||
|
||||
|
||||
class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
|
||||
bl_label = "Texture Mask"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
@@ -901,7 +900,7 @@ class IMAGE_PT_tools_brush_appearance(BrushButtonsPanel, Panel):
|
||||
return
|
||||
|
||||
col = layout.column()
|
||||
col.prop(toolsettings, "show_brush");
|
||||
col.prop(toolsettings, "show_brush")
|
||||
|
||||
col = col.column()
|
||||
col.prop(brush, "cursor_color_add", text="")
|
||||
|
@@ -239,7 +239,9 @@ class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
|
||||
|
||||
obj = context.object
|
||||
if (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
|
||||
obj.data.draw_type in {'BBONE', 'ENVELOPE'}):
|
||||
obj.data.draw_type in {'BBONE', 'ENVELOPE'}
|
||||
):
|
||||
|
||||
layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
|
||||
|
||||
if context.edit_object and context.edit_object.type == 'ARMATURE':
|
||||
|
@@ -724,7 +724,6 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
|
||||
sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
|
||||
sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
|
||||
|
||||
|
||||
# Weight Paint Mode #
|
||||
elif context.weight_paint_object and brush:
|
||||
layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
|
||||
@@ -1083,7 +1082,7 @@ class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
|
||||
return
|
||||
|
||||
col = layout.column()
|
||||
col.prop(settings, "show_brush");
|
||||
col.prop(settings, "show_brush")
|
||||
|
||||
col = col.column()
|
||||
col.active = settings.show_brush
|
||||
|
@@ -27,19 +27,22 @@ from nodeitems_utils import NodeCategory, NodeItem, NodeItemCustom
|
||||
class CompositorNodeCategory(NodeCategory):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.space_data.tree_type == 'CompositorNodeTree'
|
||||
return (context.space_data.tree_type == 'CompositorNodeTree')
|
||||
|
||||
|
||||
class ShaderNewNodeCategory(NodeCategory):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.space_data.tree_type == 'ShaderNodeTree' and \
|
||||
context.scene.render.use_shading_nodes
|
||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||
context.scene.render.use_shading_nodes)
|
||||
|
||||
|
||||
class ShaderOldNodeCategory(NodeCategory):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.space_data.tree_type == 'ShaderNodeTree' and \
|
||||
not context.scene.render.use_shading_nodes
|
||||
return (context.space_data.tree_type == 'ShaderNodeTree' and
|
||||
not context.scene.render.use_shading_nodes)
|
||||
|
||||
|
||||
class TextureNodeCategory(NodeCategory):
|
||||
@classmethod
|
||||
@@ -54,10 +57,12 @@ def group_make_draw(self, layout, context):
|
||||
|
||||
# maps node tree type to group node type
|
||||
node_tree_group_type = {
|
||||
'CompositorNodeTree' : 'CompositorNodeGroup',
|
||||
'ShaderNodeTree' : 'ShaderNodeGroup',
|
||||
'TextureNodeTree' : 'TextureNodeGroup',
|
||||
'CompositorNodeTree': 'CompositorNodeGroup',
|
||||
'ShaderNodeTree': 'ShaderNodeGroup',
|
||||
'TextureNodeTree': 'TextureNodeGroup',
|
||||
}
|
||||
|
||||
|
||||
# generic node group items generator for shader, compositor and texture node groups
|
||||
def node_group_items(context):
|
||||
space = context.space_data
|
||||
@@ -86,7 +91,10 @@ def node_group_items(context):
|
||||
if contains_group(group, ntree):
|
||||
continue
|
||||
|
||||
yield NodeItem(node_tree_group_type[group.bl_idname], group.name, { "node_tree" : "bpy.data.node_groups[%r]" % group.name })
|
||||
yield NodeItem(node_tree_group_type[group.bl_idname],
|
||||
group.name,
|
||||
{"node_tree": "bpy.data.node_groups[%r]" % group.name})
|
||||
|
||||
|
||||
# only show input/output nodes inside node groups
|
||||
def group_input_output_item_poll(context):
|
||||
@@ -232,7 +240,7 @@ shader_node_categories = [
|
||||
|
||||
compositor_node_categories = [
|
||||
# Compositor Nodes
|
||||
CompositorNodeCategory("CMP_INPUT", "Input", items = [
|
||||
CompositorNodeCategory("CMP_INPUT", "Input", items=[
|
||||
NodeItem("CompositorNodeRLayers"),
|
||||
NodeItem("CompositorNodeImage"),
|
||||
NodeItem("CompositorNodeMovieClip"),
|
||||
@@ -245,7 +253,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeTrackPos"),
|
||||
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_OUTPUT", "Output", items = [
|
||||
CompositorNodeCategory("CMP_OUTPUT", "Output", items=[
|
||||
NodeItem("CompositorNodeComposite"),
|
||||
NodeItem("CompositorNodeViewer"),
|
||||
NodeItem("CompositorNodeSplitViewer"),
|
||||
@@ -253,7 +261,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeLevels"),
|
||||
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_OP_COLOR", "Color", items = [
|
||||
CompositorNodeCategory("CMP_OP_COLOR", "Color", items=[
|
||||
NodeItem("CompositorNodeMixRGB"),
|
||||
NodeItem("CompositorNodeAlphaOver"),
|
||||
NodeItem("CompositorNodeInvert"),
|
||||
@@ -267,7 +275,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeTonemap"),
|
||||
NodeItem("CompositorNodeZcombine"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_CONVERTOR", "Converter", items = [
|
||||
CompositorNodeCategory("CMP_CONVERTOR", "Converter", items=[
|
||||
NodeItem("CompositorNodeMath"),
|
||||
NodeItem("CompositorNodeValToRGB"),
|
||||
NodeItem("CompositorNodeSetAlpha"),
|
||||
@@ -283,7 +291,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeSepYCCA"),
|
||||
NodeItem("CompositorNodeCombYCCA"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_OP_FILTER", "Filter", items = [
|
||||
CompositorNodeCategory("CMP_OP_FILTER", "Filter", items=[
|
||||
NodeItem("CompositorNodeBlur"),
|
||||
NodeItem("CompositorNodeBilateralblur"),
|
||||
NodeItem("CompositorNodeDilateErode"),
|
||||
@@ -297,14 +305,14 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeDBlur"),
|
||||
NodeItem("CompositorNodePixelate"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items = [
|
||||
CompositorNodeCategory("CMP_OP_VECTOR", "Vector", items=[
|
||||
NodeItem("CompositorNodeNormal"),
|
||||
NodeItem("CompositorNodeMapValue"),
|
||||
NodeItem("CompositorNodeMapRange"),
|
||||
NodeItem("CompositorNodeNormalize"),
|
||||
NodeItem("CompositorNodeCurveVec"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_MATTE", "Matte", items = [
|
||||
CompositorNodeCategory("CMP_MATTE", "Matte", items=[
|
||||
NodeItem("CompositorNodeKeying"),
|
||||
NodeItem("CompositorNodeKeyingScreen"),
|
||||
NodeItem("CompositorNodeChannelMatte"),
|
||||
@@ -318,7 +326,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeColorMatte"),
|
||||
NodeItem("CompositorNodeDoubleEdgeMask"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_DISTORT", "Distort", items = [
|
||||
CompositorNodeCategory("CMP_DISTORT", "Distort", items=[
|
||||
NodeItem("CompositorNodeScale"),
|
||||
NodeItem("CompositorNodeLensdist"),
|
||||
NodeItem("CompositorNodeMovieDistortion"),
|
||||
@@ -332,7 +340,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeStabilize"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_GROUP", "Group", items=node_group_items),
|
||||
CompositorNodeCategory("CMP_LAYOUT", "Layout", items = [
|
||||
CompositorNodeCategory("CMP_LAYOUT", "Layout", items=[
|
||||
NodeItem("NodeFrame"),
|
||||
NodeItem("NodeReroute"),
|
||||
NodeItem("CompositorNodeSwitch"),
|
||||
@@ -341,19 +349,19 @@ compositor_node_categories = [
|
||||
|
||||
texture_node_categories = [
|
||||
# Texture Nodes
|
||||
TextureNodeCategory("TEX_INPUT", "Input", items = [
|
||||
TextureNodeCategory("TEX_INPUT", "Input", items=[
|
||||
NodeItem("TextureNodeCurveTime"),
|
||||
NodeItem("TextureNodeCoordinates"),
|
||||
NodeItem("TextureNodeTexture"),
|
||||
NodeItem("TextureNodeImage"),
|
||||
NodeItem("NodeGroupInput", poll=group_input_output_item_poll),
|
||||
]),
|
||||
TextureNodeCategory("TEX_OUTPUT", "Output", items = [
|
||||
TextureNodeCategory("TEX_OUTPUT", "Output", items=[
|
||||
NodeItem("TextureNodeOutput"),
|
||||
NodeItem("TextureNodeViewer"),
|
||||
NodeItem("NodeGroupOutput", poll=group_input_output_item_poll),
|
||||
]),
|
||||
TextureNodeCategory("TEX_OP_COLOR", "Color", items = [
|
||||
TextureNodeCategory("TEX_OP_COLOR", "Color", items=[
|
||||
NodeItem("TextureNodeMixRGB"),
|
||||
NodeItem("TextureNodeCurveRGB"),
|
||||
NodeItem("TextureNodeInvert"),
|
||||
@@ -361,11 +369,11 @@ texture_node_categories = [
|
||||
NodeItem("TextureNodeCompose"),
|
||||
NodeItem("TextureNodeDecompose"),
|
||||
]),
|
||||
TextureNodeCategory("TEX_PATTERN", "Pattern", items = [
|
||||
TextureNodeCategory("TEX_PATTERN", "Pattern", items=[
|
||||
NodeItem("TextureNodeChecker"),
|
||||
NodeItem("TextureNodeBricks"),
|
||||
]),
|
||||
TextureNodeCategory("TEX_TEXTURE", "Textures", items = [
|
||||
TextureNodeCategory("TEX_TEXTURE", "Textures", items=[
|
||||
NodeItem("TextureNodeTexNoise"),
|
||||
NodeItem("TextureNodeTexDistNoise"),
|
||||
NodeItem("TextureNodeTexClouds"),
|
||||
@@ -377,20 +385,20 @@ texture_node_categories = [
|
||||
NodeItem("TextureNodeTexMusgrave"),
|
||||
NodeItem("TextureNodeTexStucci"),
|
||||
]),
|
||||
TextureNodeCategory("TEX_CONVERTOR", "Converter", items = [
|
||||
TextureNodeCategory("TEX_CONVERTOR", "Converter", items=[
|
||||
NodeItem("TextureNodeMath"),
|
||||
NodeItem("TextureNodeValToRGB"),
|
||||
NodeItem("TextureNodeRGBToBW"),
|
||||
NodeItem("TextureNodeValToNor"),
|
||||
NodeItem("TextureNodeDistance"),
|
||||
]),
|
||||
TextureNodeCategory("TEX_DISTORT", "Distort", items = [
|
||||
TextureNodeCategory("TEX_DISTORT", "Distort", items=[
|
||||
NodeItem("TextureNodeScale"),
|
||||
NodeItem("TextureNodeTranslate"),
|
||||
NodeItem("TextureNodeRotate"),
|
||||
]),
|
||||
TextureNodeCategory("TEX_GROUP", "Group", items=node_group_items),
|
||||
TextureNodeCategory("TEX_LAYOUT", "Layout", items = [
|
||||
TextureNodeCategory("TEX_LAYOUT", "Layout", items=[
|
||||
NodeItem("NodeFrame"),
|
||||
NodeItem("NodeReroute"),
|
||||
]),
|
||||
@@ -398,15 +406,15 @@ texture_node_categories = [
|
||||
|
||||
|
||||
def register():
|
||||
nodeitems_utils.register_node_categories("SHADER", shader_node_categories)
|
||||
nodeitems_utils.register_node_categories("COMPOSITING", compositor_node_categories)
|
||||
nodeitems_utils.register_node_categories("TEXTURE", texture_node_categories)
|
||||
nodeitems_utils.register_node_categories('SHADER', shader_node_categories)
|
||||
nodeitems_utils.register_node_categories('COMPOSITING', compositor_node_categories)
|
||||
nodeitems_utils.register_node_categories('TEXTURE', texture_node_categories)
|
||||
|
||||
|
||||
def unregister():
|
||||
nodeitems_utils.unregister_node_categories("SHADER")
|
||||
nodeitems_utils.unregister_node_categories("COMPOSITING")
|
||||
nodeitems_utils.unregister_node_categories("TEXTURE")
|
||||
nodeitems_utils.unregister_node_categories('SHADER')
|
||||
nodeitems_utils.unregister_node_categories('COMPOSITING')
|
||||
nodeitems_utils.unregister_node_categories('TEXTURE')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user