From 245ab753f527722c15bc28498f778bf55f33bf99 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 May 2010 16:00:42 +0000 Subject: [PATCH] misc uninteresting stuff (killing time at airport commit) - pep8 updates - RNA_TwoDFilterActuator --> RNA_Filter2DActuator - minor changes to conolse namespace init. --- release/scripts/op/console_python.py | 17 +++++++++-------- release/scripts/op/image.py | 2 +- release/scripts/op/vertexpaint_dirt.py | 4 ++-- release/scripts/ui/properties_data_mesh.py | 2 +- release/scripts/ui/properties_particle.py | 2 +- .../scripts/ui/properties_physics_common.py | 18 ++++++++---------- release/scripts/ui/properties_render.py | 1 - release/scripts/ui/properties_texture.py | 12 +++++++----- release/scripts/ui/space_image.py | 2 +- release/scripts/ui/space_outliner.py | 4 +++- release/scripts/ui/space_sequencer.py | 6 ++++-- release/scripts/ui/space_userpref_keymap.py | 11 +++++++---- source/blender/makesrna/intern/rna_actuator.c | 4 ++-- 13 files changed, 46 insertions(+), 39 deletions(-) diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py index 99654505c17..87abe0b6f47 100644 --- a/release/scripts/op/console_python.py +++ b/release/scripts/op/console_python.py @@ -40,9 +40,9 @@ def get_console(console_id): ''' from code import InteractiveConsole - try: - consoles = get_console.consoles - except: + consoles = getattr(get_console, "consoles", None) + + if consoles is None: consoles = get_console.consoles = {} # clear all dead consoles, use text names as IDs @@ -53,16 +53,17 @@ def get_console(console_id): del consoles[id] ''' - try: - console, stdout, stderr = consoles[console_id] - + console_data = consoles.get(console_id) + + if console_data: + console, stdout, stderr = console_data + # XXX, bug in python 3.1.2 ? # 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() - - except: + else: namespace = {'__builtins__': __builtins__, 'bpy': bpy} console = InteractiveConsole(namespace) diff --git a/release/scripts/op/image.py b/release/scripts/op/image.py index 45ccda1396b..9907362502e 100644 --- a/release/scripts/op/image.py +++ b/release/scripts/op/image.py @@ -28,7 +28,7 @@ class EditExternally(bpy.types.Operator): bl_label = "Image Edit Externally" bl_options = {'REGISTER'} - path = StringProperty(name="File Path", description="Path to an image file", maxlen= 1024, default= "") + path = StringProperty(name="File Path", description="Path to an image file", maxlen=1024, default="") def _editor_guess(self, context): import platform diff --git a/release/scripts/op/vertexpaint_dirt.py b/release/scripts/op/vertexpaint_dirt.py index c7b7ee71964..c1521866a56 100644 --- a/release/scripts/op/vertexpaint_dirt.py +++ b/release/scripts/op/vertexpaint_dirt.py @@ -69,10 +69,10 @@ def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, clamp_clean, # normalize the vector by dividing by the number of connected verts tot_con = len(con[i]) - + if tot_con == 0: continue - + vec /= tot_con # angle is the acos of the dot product between vert and connected verts normals diff --git a/release/scripts/ui/properties_data_mesh.py b/release/scripts/ui/properties_data_mesh.py index a33b4f22368..780a743f15a 100644 --- a/release/scripts/ui/properties_data_mesh.py +++ b/release/scripts/ui/properties_data_mesh.py @@ -303,7 +303,7 @@ class DATA_PT_texface(DataButtonsPanel): ob = context.active_object rd = context.scene.render - return (context.mode =='EDIT_MESH') and (rd.engine == 'BLENDER_GAME') and ob and ob.type == 'MESH' + return (context.mode == 'EDIT_MESH') and (rd.engine == 'BLENDER_GAME') and ob and ob.type == 'MESH' def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index 84b756e6257..6ec396bf7a1 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -389,7 +389,7 @@ class PARTICLE_PT_physics(ParticleButtonsPanel): row.prop(part, "physics_type", expand=True) else: row.prop(part, "physics_type", text="") - + if part.physics_type != 'NO': row = layout.row() col = row.column(align=True) diff --git a/release/scripts/ui/properties_physics_common.py b/release/scripts/ui/properties_physics_common.py index 080d576ab9a..20073c68989 100644 --- a/release/scripts/ui/properties_physics_common.py +++ b/release/scripts/ui/properties_physics_common.py @@ -49,12 +49,11 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): layout.label(text=cache.info) else: layout.prop(cache, "name", text="File Name") - + split = layout.split() col = split.column(align=True) - + if not particles: - col.enabled = enabled col.prop(cache, "frame_start") col.prop(cache, "frame_end") @@ -74,19 +73,18 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): sub.prop(cache, "disk_cache") col.label(text=cache.info) - layout.separator() - + split = layout.split() - + col = split.column() - + if cache.baked == True: col.operator("ptcache.free_bake", text="Free Bake") else: col.operator("ptcache.bake", text="Bake").bake = True - + sub = col.row() sub.enabled = (cache.frames_skipped or cache.outdated) and enabled sub.operator("ptcache.bake", text="Calculate To Frame").bake = False @@ -94,8 +92,8 @@ def point_cache_ui(self, context, cache, enabled, particles, smoke): sub = col.column() sub.enabled = enabled sub.operator("ptcache.bake_from_cache", text="Current Cache to Bake") - - + + if wide_ui: col = split.column() col.operator("ptcache.bake_all", text="Bake All Dynamics").bake = True diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py index b6137e271b9..f95228567f1 100644 --- a/release/scripts/ui/properties_render.py +++ b/release/scripts/ui/properties_render.py @@ -106,7 +106,6 @@ class RENDER_PT_layers(RenderButtonsPanel): col.label(text="Mask Layers:") col.prop(rl, "zmask_layers", text="") - layout.separator() layout.label(text="Include:") diff --git a/release/scripts/ui/properties_texture.py b/release/scripts/ui/properties_texture.py index d537b5c29c2..07a097cfd3a 100644 --- a/release/scripts/ui/properties_texture.py +++ b/release/scripts/ui/properties_texture.py @@ -47,6 +47,7 @@ class TEXTURE_MT_envmap_specials(bpy.types.Menu): from properties_material import active_node_mat + def context_tex_datablock(context): idblock = context.material if idblock: @@ -71,7 +72,8 @@ class TextureButtonsPanel(bpy.types.Panel): def poll(self, context): tex = context.texture - if not tex or tex == None: return False + if not tex: + return False engine = context.scene.render.engine return (tex.type != 'NONE' or tex.use_nodes) and (engine in self.COMPAT_ENGINES) @@ -102,7 +104,7 @@ class TEXTURE_PT_context_texture(TextureButtonsPanel): engine = context.scene.render.engine if not hasattr(context, "texture_slot"): return False - return ((context.material or context.world or context.lamp or context.brush or context.texture) + return ((context.material or context.world or context.lamp or context.brush or context.texture) and (engine in self.COMPAT_ENGINES)) def draw(self, context): @@ -212,7 +214,7 @@ class TextureSlotPanel(TextureButtonsPanel): def poll(self, context): if not hasattr(context, "texture_slot"): return False - + engine = context.scene.render.engine return TextureButtonsPanel.poll(self, context) and (engine in self.COMPAT_ENGINES) @@ -228,7 +230,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel): if not getattr(context, "texture_slot", None): return False - + engine = context.scene.render.engine return (engine in self.COMPAT_ENGINES) @@ -277,7 +279,7 @@ class TEXTURE_PT_mapping(TextureSlotPanel): row = layout.row() row.active = tex.map_mode in ('FIXED', 'TILED') row.prop(tex, "angle") - + row = layout.row() row.active = tex.map_mode in ('TILED', '3D') row.column().prop(tex, "size") diff --git a/release/scripts/ui/space_image.py b/release/scripts/ui/space_image.py index 7f595207f53..dd07f7b66f8 100644 --- a/release/scripts/ui/space_image.py +++ b/release/scripts/ui/space_image.py @@ -471,7 +471,7 @@ class IMAGE_PT_scope_sample(bpy.types.Panel): def poll(self, context): sima = context.space_data - return sima + return sima def draw(self, context): layout = self.layout diff --git a/release/scripts/ui/space_outliner.py b/release/scripts/ui/space_outliner.py index a0f8f41f58a..ec3c430feaa 100644 --- a/release/scripts/ui/space_outliner.py +++ b/release/scripts/ui/space_outliner.py @@ -85,6 +85,7 @@ class OUTLINER_MT_view(bpy.types.Menu): layout.operator("screen.area_dupli") layout.operator("screen.screen_full_area") + class OUTLINER_MT_search(bpy.types.Menu): bl_label = "Search" @@ -98,6 +99,7 @@ class OUTLINER_MT_search(bpy.types.Menu): col.prop(space, "match_case_sensitive") col.prop(space, "match_complete") + class OUTLINER_MT_edit_datablocks(bpy.types.Menu): bl_label = "Edit" @@ -118,7 +120,7 @@ class OUTLINER_MT_edit_datablocks(bpy.types.Menu): classes = [ OUTLINER_HT_header, OUTLINER_MT_view, - OUTLINER_MT_search, + OUTLINER_MT_search, OUTLINER_MT_edit_datablocks] diff --git a/release/scripts/ui/space_sequencer.py b/release/scripts/ui/space_sequencer.py index d928f40250e..fad8307c401 100644 --- a/release/scripts/ui/space_sequencer.py +++ b/release/scripts/ui/space_sequencer.py @@ -446,7 +446,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel): elif strip.type == 'TRANSFORM': self.draw_panel_transform(strip) - + elif strip.type == "MULTICAM": layout.prop(strip, "multicam_source") @@ -518,7 +518,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel): 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', - 'MULTICAM','SPEED') + 'MULTICAM', 'SPEED') def draw_filename(self, context): pass @@ -611,6 +611,7 @@ class SEQUENCER_PT_input_image(SEQUENCER_PT_input): col = split.column() col.prop(elem, "filename", text="") # strip.elements[0] could be a fallback + class SEQUENCER_PT_input_secondary(SEQUENCER_PT_input): bl_label = "Strip Input" @@ -627,6 +628,7 @@ class SEQUENCER_PT_input_secondary(SEQUENCER_PT_input): def draw_filename(self, context): pass + class SEQUENCER_PT_sound(SequencerButtonsPanel): bl_label = "Sound" diff --git a/release/scripts/ui/space_userpref_keymap.py b/release/scripts/ui/space_userpref_keymap.py index 4f440729e9d..961b138ab7e 100644 --- a/release/scripts/ui/space_userpref_keymap.py +++ b/release/scripts/ui/space_userpref_keymap.py @@ -92,7 +92,7 @@ KM_HIERARCHY = [ ]), ('Property Editor', 'PROPERTIES', 'WINDOW', []), # align context menu - + ('Script', 'SCRIPTS_WINDOW', 'WINDOW', []), ('Text', 'TEXT_EDITOR', 'WINDOW', []), ('Console', 'CONSOLE', 'WINDOW', []), @@ -107,19 +107,22 @@ KM_HIERARCHY = [ ('View3D Zoom Modal', 'EMPTY', 'WINDOW', []), ] + def _km_exists_in(km, export_keymaps): for km2, kc in export_keymaps: if km2.name == km.name: return True return False -# kc1 takes priority over kc2 + def _merge_keymaps(kc1, kc2): + """ note: kc1 takes priority over kc2 + """ merged_keymaps = [(km, kc1) for km in kc1.keymaps] if kc1 != kc2: merged_keymaps.extend([(km, kc2) for km in kc2.keymaps if not _km_exists_in(km, merged_keymaps)]) - - return merged_keymaps + + return merged_keymaps class InputKeyMapPanel(bpy.types.Panel): diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 23698e8140f..88bd88ec746 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -65,7 +65,7 @@ static StructRNA* rna_Actuator_refine(struct PointerRNA *ptr) case ACT_VISIBILITY: return &RNA_VisibilityActuator; case ACT_2DFILTER: - return &RNA_TwoDFilterActuator; + return &RNA_Filter2DActuator; case ACT_PARENT: return &RNA_ParentActuator; case ACT_SHAPEACTION: @@ -969,7 +969,7 @@ static void rna_def_twodfilter_actuator(BlenderRNA *brna) // {ACT_2DFILTER_NUMBER_OF_FILTERS, "", 0, "Do not use it. Sentinel", ""}, {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "TwoDFilterActuator", "Actuator"); + srna= RNA_def_struct(brna, "Filter2DActuator", "Actuator"); RNA_def_struct_ui_text(srna, "2D Filter Actuator", "Actuator to .."); RNA_def_struct_sdna_from(srna, "bTwoDFilterActuator", "data");