pep8 cleanup

This commit is contained in:
Campbell Barton 2012-09-26 21:19:51 +00:00
parent dbeddcdbce
commit 8a51d235e6
17 changed files with 62 additions and 37 deletions

View File

@ -437,6 +437,7 @@ class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
layout.prop(cdata, "use_subdivision")
layout.prop(cdata, "dicing_rate")
class Cycles_PT_mesh_normals(CyclesButtonsPanel, Panel):
bl_label = "Normals"
bl_context = "data"
@ -953,7 +954,7 @@ def draw_device(self, context):
layout.prop(cscene, "device")
elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
layout.prop(cscene, "device")
if cscene.feature_set == 'EXPERIMENTAL' and cscene.device == 'CPU' and engine.with_osl():
layout.prop(cscene, "shading_system")

View File

@ -275,7 +275,8 @@ def enable(module_name, default_set=True, persistent=False):
try:
mod.register()
except:
print("Exception in module register(): %r" % getattr(mod, "__file__", module_name))
print("Exception in module register(): %r" %
getattr(mod, "__file__", module_name))
handle_error()
del sys.modules[module_name]
return None
@ -317,7 +318,8 @@ def disable(module_name, default_set=True):
try:
mod.unregister()
except:
print("Exception in module unregister(): %r" % getattr(mod, "__file__", module_name))
print("Exception in module unregister(): %r" %
getattr(mod, "__file__", module_name))
import traceback
traceback.print_exc()
else:

View File

@ -16,7 +16,7 @@
#
# ***** END GPL LICENSE BLOCK *****
# <pep8-80 compliant>
# <pep8 compliant>
# Write out messages.txt from Blender.
# XXX: This script is meant to be used from inside Blender!
@ -43,6 +43,7 @@ UNDOC_OPS_STR = settings.UNDOC_OPS_STR
NC_ALLOWED = settings.WARN_MSGID_NOT_CAPITALIZED_ALLOWED
def check(check_ctxt, messages, key, msgsrc):
if check_ctxt is None:
return
@ -78,7 +79,8 @@ def dump_messages_rna(messages, check_ctxt):
import bpy
def classBlackList():
blacklist_rna_class = [# core classes
blacklist_rna_class = [
# core classes
"Context", "Event", "Function", "UILayout",
"BlendData",
# registerable classes

View File

@ -162,9 +162,9 @@ def main():
" {} specific context{} present:\n {}\n"
"".format(glob_stats["nbr"], glob_stats["lvl"] / glob_stats["nbr"],
glob_stats["lvl_ttips"] / glob_stats["nbr"],
glob_stats["lvl_trans_ttips"]/glob_stats["nbr"],
glob_stats["lvl_ttips_in_trans"]/glob_stats["nbr"],
glob_stats["lvl_comm"]/glob_stats["nbr"], glob_stats["nbr_signs"],
glob_stats["lvl_trans_ttips"] / glob_stats["nbr"],
glob_stats["lvl_ttips_in_trans"] / glob_stats["nbr"],
glob_stats["lvl_comm"] / glob_stats["nbr"], glob_stats["nbr_signs"],
glob_stats["nbr_trans_signs"], nbr_contexts, _ctx_txt,
"\n ".join(glob_stats["contexts"]-{""})))

View File

@ -95,7 +95,6 @@ def parse_messages(fname):
msgctxt_lines = []
comment_lines = []
def finalize_message():
nonlocal reading_msgid, reading_msgstr, reading_msgctxt, \
reading_comment, is_fuzzy, is_translated, is_commented, \
@ -225,7 +224,6 @@ def parse_messages(fname):
if reading_msgstr:
finalize_message()
return (messages,
{"trans_msg": translated_messages,
"fuzzy_msg": fuzzy_messages,

View File

@ -59,6 +59,7 @@ import addon_utils as _addon_utils
_script_module_dirs = "startup", "modules"
def _test_import(module_name, loaded_modules):
use_time = _bpy.app.debug_python
@ -615,12 +616,15 @@ def _blender_default_map():
# hooks for doc lookups
_manual_map = [_blender_default_map]
def register_manual_map(manual_hook):
_manual_map.append(manual_hook)
def unregister_manual_map(manual_hook):
_manual_map.remove(manual_hook)
def manual_map():
# reverse so default is called last
for cb in reversed(_manual_map):
@ -633,4 +637,3 @@ def manual_map():
continue
yield prefix, url_manual_mapping

View File

@ -304,7 +304,7 @@ def copy_as_script(context):
for line in sc.scrollback:
text = line.body
type = line.type
if type == 'INFO': # ignore autocomp.
continue
if type == 'INPUT':

View File

@ -259,7 +259,7 @@ def xml2rna(root_xml,
except ValueError:
try:
value_xml_coerce = [float(v) for v in value_xml_split]
except ValueError: # bool vector property
except ValueError: # bool vector property
value_xml_coerce = [{'TRUE': True, 'FALSE': False}[v] for v in value_xml_split]
del value_xml_split
tp_name = 'ARRAY'

View File

@ -14,4 +14,4 @@ settings.default_margin = 0
settings.use_default_red_channel = True
settings.use_default_green_channel = True
settings.use_default_blue_channel = True
settings.default_correlation_min = 0.6
settings.default_correlation_min = 0.6

View File

@ -14,4 +14,4 @@ settings.default_margin = 0
settings.use_default_red_channel = True
settings.use_default_green_channel = True
settings.use_default_blue_channel = True
settings.default_correlation_min = 0.75
settings.default_correlation_min = 0.75

View File

@ -14,4 +14,4 @@ settings.default_margin = 0
settings.use_default_red_channel = True
settings.use_default_green_channel = True
settings.use_default_blue_channel = True
settings.default_correlation_min = 0.6
settings.default_correlation_min = 0.6

View File

@ -14,4 +14,4 @@ settings.default_margin = 0
settings.use_default_red_channel = True
settings.use_default_green_channel = True
settings.use_default_blue_channel = True
settings.default_correlation_min = 0.75
settings.default_correlation_min = 0.75

View File

@ -22,12 +22,16 @@ import bpy
from bpy.types import Operator
from bpy.props import EnumProperty
# XXX These node item lists should actually be generated by a callback at operator execution time (see node_type_items below),
# using the active node tree from the context. Due to a difficult bug in bpy this is not possible (item list memory gets freed too early),
# XXX These node item lists should actually be generated by a callback at
# operator execution time (see node_type_items below),
# using the active node tree from the context.
# Due to a difficult bug in bpy this is not possible
# (item list memory gets freed too early),
# so for now just copy the static item lists to these global variables.
#
# In the custom_nodes branch, the static per-tree-type node items are replaced by a single independent type list anyway (with a poll function
# to limit node types to the respective trees). So this workaround is only temporary.
# In the custom_nodes branch, the static per-tree-type node items are replaced
# by a single independent type list anyway (with a poll function to limit node
# types to the respective trees). So this workaround is only temporary.
# lazy init
node_type_items_dict = {}
@ -39,18 +43,21 @@ node_group_prefix = 'GROUP_'
# Generate a list of enum items for a given node class
# Copy existing type enum, adding a prefix to distinguish from node groups
# Skip the base node group type, node groups will be added below for all existing group trees
# Skip the base node group type,
# node groups will be added below for all existing group trees
def node_type_items(node_class):
return [(node_type_prefix + item.identifier, item.name, item.description)
for item in node_class.bl_rna.properties['type'].enum_items if item.identifier != 'GROUP']
for item in node_class.bl_rna.properties['type'].enum_items
if item.identifier != 'GROUP']
# Generate items for node group types
# Filter by the given tree_type
# Node group trees don't have a description property yet (could add this as a custom property though)
# Node group trees don't have a description property yet
# (could add this as a custom property though)
def node_group_items(tree_type):
return [(node_group_prefix + group.name, group.name, '')
for group in bpy.data.node_groups if group.type == tree_type]
for group in bpy.data.node_groups if group.type == tree_type]
# Returns the enum item list for the edited tree in the context
@ -71,7 +78,11 @@ def node_type_items_cb(self, context):
})
# XXX Does not work correctly, see comment above
#return [(item.identifier, item.name, item.description, item.value) for item in tree.nodes.bl_rna.functions['new'].parameters['type'].enum_items]
'''
return [(item.identifier, item.name, item.description, item.value)
for item in
tree.nodes.bl_rna.functions['new'].parameters['type'].enum_items]
'''
if tree.type in node_type_items_dict:
return node_type_items_dict[tree.type] + node_group_items(tree.type)
@ -85,7 +96,8 @@ class NODE_OT_add_search(Operator):
bl_label = "Search and Add Node"
bl_options = {'REGISTER', 'UNDO'}
# XXX this should be called 'node_type' but the operator search property is hardcoded to 'type' by a hack in bpy_operator_wrap.c ...
# XXX this should be called 'node_type' but the operator search
# property is hardcoded to 'type' by a hack in bpy_operator_wrap.c ...
type = EnumProperty(
name="Node Type",
description="Node type",
@ -98,14 +110,17 @@ class NODE_OT_add_search(Operator):
space = context.space_data
tree = space.edit_tree
# Enum item identifier has an additional prefix to distinguish base node types from node groups
# Enum item identifier has an additional prefix to
# distinguish base node types from node groups
item = self.type
if item.startswith(node_type_prefix):
# item means base node type
node = tree.nodes.new(type=item[len(node_type_prefix):])
elif item.startswith(node_group_prefix):
# item means node group type
node = tree.nodes.new(type='GROUP', group=bpy.data.node_groups[item[len(node_group_prefix):]])
node = tree.nodes.new(
type='GROUP',
group=bpy.data.node_groups[item[len(node_group_prefix):]])
else:
return None
@ -133,7 +148,8 @@ class NODE_OT_add_search(Operator):
v2d = context.region.view2d
# convert mouse position to the View2D for later node placement
space.cursor_location = v2d.region_to_view(event.mouse_region_x, event.mouse_region_y)
space.cursor_location = v2d.region_to_view(event.mouse_region_x,
event.mouse_region_y)
context.window_manager.invoke_search_popup(self)
return {'CANCELLED'}

View File

@ -216,7 +216,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
def DISPLACE(self, layout, ob, md):
has_texture = (md.texture is not None)
split = layout.split()
col = split.column()

View File

@ -82,6 +82,7 @@ def register():
bpy.utils.register_manual_map(add_object_manual_map)
bpy.types.INFO_MT_mesh_add.append(add_object_button)
def unregister():
bpy.utils.unregister_class(OBJECT_OT_add_object)
bpy.utils.unregister_manual_map(add_object_manual_map)

View File

@ -29,9 +29,10 @@
import bpy
def test_data():
import rna_wiki_reference
assert(isinstance(rna_wiki_reference.url_manual_mapping, tuple))
for i, value in enumerate(rna_wiki_reference.url_manual_mapping):
try:
@ -44,12 +45,11 @@ def test_data():
traceback.print_exc()
raise
# a stripped down version of api_dump() in rna_info_dump.py
# a stripped down version of api_dump() in rna_info_dump.py
def test_lookup_coverage():
def rna_ids():
import rna_info
struct = rna_info.BuildRNAInfo()[0]
for struct_id, v in sorted(struct.items()):
@ -81,11 +81,12 @@ def test_lookup_coverage():
print("")
print("---------------------")
print("Undocumented Sections")
for rna_group in sorted(set_group_all):
if rna_group not in set_group_doc:
print("%s.*" % rna_group)
def test_urls():
pass # TODO

View File

@ -89,6 +89,7 @@ def run_ops(operators, setup_func=None, reset=True):
bpy.ops.wm.read_factory_settings()
setup_func()
# contexts
def ctx_clear_scene(): # copied from batch_import.py
unique_obs = set()
@ -231,7 +232,7 @@ def main():
#import random
#random.shuffle(operators)
# 2 passes, first just run setup_func to make sure they are ok
for operators_test in ((), operators):
# Run the operator tests in different contexts
@ -259,7 +260,7 @@ def main():
run_ops(operators_test, setup_func=ctx_editmode_mball)
run_ops(operators_test, setup_func=ctx_editmode_text)
run_ops(operators_test, setup_func=ctx_editmode_lattice)
if not operators_test:
print("All setup functions run fine!")