Code cleanup: unused python vars & imports
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Apr 2014 19:31:20 +0000 (05:31 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Apr 2014 19:36:16 +0000 (05:36 +1000)
Use frosted rather then pyflakes

31 files changed:
doc/python_api/sphinx_doc_gen.py
intern/cycles/blender/addon/ui.py
release/scripts/modules/addon_utils.py
release/scripts/modules/bpy_extras/view3d_utils.py
release/scripts/modules/nodeitems_utils.py
release/scripts/modules/rna_keymap_ui.py
release/scripts/startup/bl_operators/add_mesh_torus.py
release/scripts/startup/bl_operators/mesh.py
release/scripts/startup/bl_operators/node.py
release/scripts/startup/bl_operators/object.py
release/scripts/startup/bl_operators/vertexpaint_dirt.py
release/scripts/startup/bl_operators/view3d.py
release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/__init__.py
release/scripts/startup/bl_ui/properties_data_armature.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/properties_mask_common.py
release/scripts/startup/bl_ui/properties_material.py
release/scripts/startup/bl_ui/properties_object.py
release/scripts/startup/bl_ui/properties_render_layer.py
release/scripts/startup/bl_ui/properties_scene.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_node.py
release/scripts/startup/bl_ui/space_sequencer.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/datatoc/datatoc_icon_split.py
source/tests/bl_rna_wiki_reference.py
source/tests/pep8.py
source/tests/rst_to_doctree_mini.py

index 4cea81d5cf01085372b1f6259971d9efe6b27c2e..3169fda5e3a82da51b35e8574467e30fefe953b3 100644 (file)
@@ -62,7 +62,7 @@ Sphinx: PDF generation
 
 try:
     import bpy  # blender module
-except:
+except ImportError:
     print("\nERROR: this script must run from inside Blender")
     print(SCRIPT_HELP_MSG)
     import sys
index a064b4ff4c9074281a14af9bdd11b1495615fc8a..4cdc7210b0122856b74ccaf2dd041904b1e56821 100644 (file)
@@ -571,7 +571,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
 
         rd = context.scene.render
         scene = context.scene
-        cscene = scene.cycles
+        cscene = scene.cycles
 
         layout.active = rd.use_motion_blur
 
@@ -585,7 +585,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
 
         rd = context.scene.render
         scene = context.scene
-        cscene = scene.cycles
+        cscene = scene.cycles
 
         ob = context.object
         cob = ob.cycles
@@ -1194,7 +1194,7 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        cscene = scene.cycles
+        cscene = scene.cycles
         psys = context.particle_system
         return CyclesButtonsPanel.poll(context) and psys and psys.settings.type == 'HAIR'
 
@@ -1233,7 +1233,7 @@ class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
     @classmethod
     def poll(cls, context):
         scene = context.scene
-        cscene = scene.cycles
+        cscene = scene.cycles
         ccscene = scene.cycles_curves
         psys = context.particle_system
         use_curves = ccscene.use_curves and psys
index e76bcc027513501367fbeeb86cbdba5b5fd1b56f..88356b676d292399dff3b524e69c549c2eccdc56 100644 (file)
@@ -229,9 +229,9 @@ def check(module_name):
 
 def _addon_ensure(module_name):
     addons = _user_preferences.addons
-    addon = _user_preferences.addons.get(module_name)
+    addon = addons.get(module_name)
     if not addon:
-        addon = _user_preferences.addons.new()
+        addon = addons.new()
         addon.module = module_name
 
 
index 7a075e93e1a15108da29f3fe6a7e57e9363baee5..ad555a417d71c02b21ca3bd0daa4693aeabfae62 100644 (file)
@@ -73,16 +73,11 @@ def region_2d_to_origin_3d(region, rv3d, coord):
     :return: The origin of the viewpoint in 3d space.
     :rtype: :class:`mathutils.Vector`
     """
-    from mathutils import Vector
-
     viewinv = rv3d.view_matrix.inverted()
 
     if rv3d.is_perspective:
-        from mathutils.geometry import intersect_line_plane
-
         origin_start = viewinv.translation.copy()
     else:
-        from mathutils.geometry import intersect_point_line
         persmat = rv3d.perspective_matrix.copy()
         dx = (2.0 * coord[0] / region.width) - 1.0
         dy = (2.0 * coord[1] / region.height) - 1.0
index 7418452b039336684e05642997b9d2fd3ab11e26..f017c76ae6fa81c79eb4da4aaf2ab2462d53a6fc 100644 (file)
@@ -18,7 +18,6 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Menu, Panel
 
 
 class NodeCategory():
@@ -92,7 +91,6 @@ def register_node_categories(identifier, cat_list):
     def draw_node_item(self, context):
         layout = self.layout
         col = layout.column()
-        default_context = bpy.app.translations.contexts.default
         for item in self.category.items(context):
             item.draw(item, col, context)
 
index dde26d6e284e01d143af047f14592209b44e7190..12d99a00d44702ae3005a38d5ea1951d51eadb96 100644 (file)
@@ -292,7 +292,6 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
                                 kmi_type_set.add(v)
             return kmi_type_set
 
-        kmi_type_set_combine = None
         for i, kmi_type in enumerate(filter_text_split):
             kmi_type_set = kmi_type_set_from_string(kmi_type)
 
index 39b0df1dd6563cdfb4e2fd8a22b07f9777e5a312..449a4cef1efdc0e4aab5fa8690f577b28b7954e7 100644 (file)
@@ -22,7 +22,6 @@ from bpy.types import Operator
 
 from bpy.props import (FloatProperty,
                        IntProperty,
-                       BoolProperty,
                        )
 from bpy.app.translations import pgettext_data as data_
 
index cead7d66097fcb4f32dca230e65d6297e91c6d23..f86c31cd9cc3d923f00cf2705685265089ee3de2 100644 (file)
@@ -87,7 +87,6 @@ class MeshMirrorUV(Operator):
 
         polys = mesh.polygons
         loops = mesh.loops
-        verts = mesh.vertices
         uv_loops = mesh.uv_layers.active.data
         nbr_polys = len(polys)
 
index 13189b2e9d3d8b1d477aceca4048125d842a5a37..9bdd928970032c1f233c31f66ab49743122ce532 100644 (file)
@@ -61,7 +61,6 @@ class NodeAddOperator():
     @staticmethod
     def store_mouse_cursor(context, event):
         space = context.space_data
-        v2d = context.region.view2d
         tree = space.edit_tree
 
         # convert mouse position to the View2D for later node placement
index ae13ba8b559284e8c45794b6282b45fa1a0a34a3..04f4cba6d3b9dc6475ad32d243995fb87a609b0d 100644 (file)
@@ -687,7 +687,6 @@ class TransformsToDeltasAnim(Operator):
         DELTA_PATHS = STANDARD_TO_DELTA_PATHS.values()
 
         # try to apply on each selected object
-        success = False
         for obj in context.selected_editable_objects:
             adt = obj.animation_data
             if (adt is None) or (adt.action is None):
@@ -792,7 +791,6 @@ class LodByName(Operator):
         return (context.active_object is not None)
 
     def execute(self, context):
-        scene = context.scene
         ob = context.active_object
 
         prefix = ""
@@ -843,7 +841,6 @@ class LodClearAll(Operator):
         return (context.active_object is not None)
 
     def execute(self, context):
-        scene = context.scene
         ob = context.active_object
 
         if ob.lod_levels:
index cd3ffb9c232f5d382f4cef93e15cd3b9af34257e..68c9bc143bec38b3bed907250ed5b3c05a0034c9 100644 (file)
@@ -183,7 +183,6 @@ class VertexPaintDirt(Operator):
 
     def execute(self, context):
         import time
-        from math import radians
 
         obj = context.object
         mesh = obj.data
index da6628617e72f902e9bf30dafaf74458087967db..85cc9210c2de7267a87e11909b729bae45a975a8 100644 (file)
@@ -19,7 +19,6 @@
 # <pep8-80 compliant>
 
 import bpy
-import mathutils
 from bpy.types import Operator
 from bpy.props import BoolProperty
 
index 3fdde1a1339ecfa29fb82db5b1be81d56e1bcc20..86ae8fdc4e6ba584697058cf6a09d5abc8f5c703 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from bpy.types import Menu, Operator
+from bpy.types import Operator
 from bpy.props import (StringProperty,
                        BoolProperty,
                        IntProperty,
index 793cbf8ce804086dabd723e65930b074bf8ff83e..6b72ef12dccc49e95b704ee8562022b8266c13f3 100644 (file)
@@ -195,7 +195,6 @@ class UI_UL_list(bpy.types.UIList):
         return a list mapping org_idx -> new_idx,
                or an empty list if no sorting has been done.
         """
-        neworder = [None] * len(items)
         _sort = [(idx, getattr(it, propname, "")) for idx, it in enumerate(items)]
         return cls.sort_items_helper(_sort, lambda e: e[1].lower())
 
index f4ec2ce1f31f0f25c57a1b7d7e80dd62e9d4627d..c6823f17153c8ade9763df654d6ce2230d81d9ba 100644 (file)
@@ -292,7 +292,7 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
         return (context.object) and (context.armature)
 
     def draw(self, context):
-        layout = self.layout
+        layout = self.layout
 
         ob = context.object
         avs = ob.pose.animation_visualization
index edf3354db4fab02ed6eeb9060fb4def257914c75..622c9ba24453a3fe63e0421f5b949fb7bd12add3 100644 (file)
@@ -76,7 +76,7 @@ class MESH_UL_shape_keys(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
         # assert(isinstance(item, bpy.types.ShapeKey)
         obj = active_data
-        key = data
+        key = data
         key_block = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
             split = layout.split(0.66, False)
@@ -323,7 +323,6 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
         layout = self.layout
 
         me = context.mesh
-        lay = me.uv_textures.active
 
         row = layout.row()
         col = row.column()
@@ -343,7 +342,6 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
         layout = self.layout
 
         me = context.mesh
-        lay = me.vertex_colors.active
 
         row = layout.row()
         col = row.column()
index eef7b00f0be426d1655b647092d3451efcdfc157..9a2857cc7b86e801049bde8999f9c59927e7065d 100644 (file)
@@ -377,7 +377,6 @@ class MASK_MT_select(Menu):
 
     def draw(self, context):
         layout = self.layout
-        sc = context.space_data
 
         layout.operator("mask.select_border")
         layout.operator("mask.select_circle")
index 03a28b609be1a381d66c264c8107e02aa8873c63..e3fcb0ef53ece2ba72144a6aaa9e5452523addad 100644 (file)
@@ -73,7 +73,7 @@ class MATERIAL_MT_specials(Menu):
 class MATERIAL_UL_matslots(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
         # assert(isinstance(item, bpy.types.MaterialSlot)
-        ob = data
+        ob = data
         slot = item
         ma = slot.material
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
index b0872f47ea64df11a5fcdfa50be484aae3d5b233..3ff9ab9e12ffd79210449cdd44bec808bce9cd14 100644 (file)
@@ -324,7 +324,7 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel):
         return (context.object)
 
     def draw(self, context):
-        layout = self.layout
+        layout = self.layout
 
         ob = context.object
         avs = ob.animation_visualization
index 488f041688057f280ebf51c10dd86caa0cb8d174..2494e49d8126f62e15b7a78a25f2d462a9ab1bdc 100644 (file)
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Menu, Panel, UIList
+from bpy.types import Panel, UIList
 
 
 class RenderLayerButtonsPanel():
index 10574c88abbddc224e21125a927e1e3733c33cf8..049161fdce88f2fad1ed183317e1a298914e1e12 100644 (file)
@@ -182,7 +182,6 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
         layout = self.layout
 
         scene = context.scene
-        rd = scene.render
 
         col = layout.column()
         col.label(text="Display:")
index d638fad8d6a2e7d78a28dcb5892945e934aa916e..d1981c0b0e5560ef612009f3844536afc77fedbb 100644 (file)
@@ -262,7 +262,6 @@ class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
 
         sc = context.space_data
         clip = sc.clip
-        settings = clip.tracking.settings
 
         col = layout.column(align=True)
         row = col.row(align=True)
@@ -641,7 +640,6 @@ class CLIP_PT_plane_track(CLIP_PT_tracking_panel, Panel):
     def draw(self, context):
         layout = self.layout
 
-        sc = context.space_data
         clip = context.space_data.clip
         active_track = clip.tracking.plane_tracks.active
 
@@ -1086,7 +1084,6 @@ class CLIP_PT_footage_info(CLIP_PT_clip_view_panel, Panel):
         layout = self.layout
 
         sc = context.space_data
-        clip = sc.clip
 
         col = layout.column()
         col.template_movieclip_information(sc, "clip", sc.clip_user)
index 9bf6aaa17034a4d394f0f7936c271bde294b7f79..f19e77eff8ec46583e9cc3cf52d9d5aa6e715379 100644 (file)
@@ -458,7 +458,6 @@ class MASK_MT_editor_menus(Menu):
         sima = context.space_data
         ima = sima.image
 
-        show_render = sima.show_render
         show_uvedit = sima.show_uvedit
         show_maskedit = sima.show_maskedit
 
@@ -759,7 +758,6 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
 
         toolsettings = context.tool_settings.image_paint
         brush = toolsettings.brush
-        tex_slot = brush.texture_slot
 
         col = layout.column()
         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
@@ -775,7 +773,6 @@ class IMAGE_PT_tools_mask_texture(BrushButtonsPanel, Panel):
         layout = self.layout
 
         brush = context.tool_settings.image_paint.brush
-        tex_slot_alpha = brush.mask_texture_slot
 
         col = layout.column()
 
index c183c331fadba887c4233253e3c9073650513112..959043f7931bd0b4a65b5ec8fe2384d29330d93b 100644 (file)
@@ -274,7 +274,6 @@ class NODE_PT_active_node_generic(Panel):
 
     @classmethod
     def poll(cls, context):
-        space = context.space_data
         return context.active_node is not None
 
     def draw(self, context):
@@ -293,7 +292,6 @@ class NODE_PT_active_node_color(Panel):
 
     @classmethod
     def poll(cls, context):
-        space = context.space_data
         return context.active_node is not None
 
     def draw_header(self, context):
@@ -323,7 +321,6 @@ class NODE_PT_active_node_properties(Panel):
 
     @classmethod
     def poll(cls, context):
-        space = context.space_data
         return context.active_node is not None
 
     def draw(self, context):
index 823aa2acf8976d9354da3b8bd9b5d3fdd9ccd7cf..0ce095d48e2185e281cc56a0bee32b61a82e15f5 100644 (file)
@@ -486,7 +486,6 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
-        sequencer = context.scene.sequence_editor
         strip = act_strip(context)
 
         if strip.input_count > 0:
index 52f987be79641e6ce4249abfff16dc5f3c88e715..a433832c96eaafb1f8be9a388dd8fbad42ab2de7 100644 (file)
@@ -30,8 +30,7 @@ class VIEW3D_HT_header(Header):
         layout = self.layout
 
         view = context.space_data
-        mode_string = context.mode
-        edit_object = context.edit_object
+        # mode_string = context.mode
         obj = context.active_object
         toolsettings = context.tool_settings
 
@@ -2793,8 +2792,6 @@ class VIEW3D_PT_view3d_display(Panel):
 
         view = context.space_data
         scene = context.scene
-        gs = scene.game_settings
-        obj = context.object
 
         col = layout.column()
         col.prop(view, "show_only_render")
index f938f30cd35cc6452abd5cc6fad016b68ff7486b..eec99a786574683a7dc7dff4856e84353155b038 100644 (file)
@@ -1100,7 +1100,6 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
 
         settings = self.paint_settings(context)
         brush = settings.brush
-        tex_slot = brush.texture_slot
 
         col = layout.column()
 
@@ -1124,7 +1123,6 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
         layout = self.layout
 
         brush = context.tool_settings.image_paint.brush
-        tex_slot_alpha = brush.mask_texture_slot
 
         col = layout.column()
 
index 44d8e5fd0fb539d07ffbb938b45c322b4d7b425c..55f0a5c5f6a87da93e7a31aaaf6876a0b18e0e8f 100755 (executable)
@@ -164,7 +164,6 @@ def dice(filepath, output, output_prefix, name_style,
          minx_icon, miny_icon, maxx_icon, maxy_icon,
          spacex_icon, spacey_icon,
          ):
-    import struct
 
     is_simple = (max(minx, miny, maxx, maxy,
                      minx_icon, miny_icon, maxx_icon, maxy_icon,
@@ -209,7 +208,7 @@ def dice(filepath, output, output_prefix, name_style,
 
             # simple, no margins
             if is_simple:
-                sub_x = x * icon_x
+                sub_x = x * icon_w
                 sub_y = y * icon_h
             else:
                 sub_x = minx + ((x * (icon_w + spacex_icon)) + minx_icon)
index c394107d8d177ac7cc204443c4c520704ac5f512..d7ca80a14bd59ae555e94a8f5d1a4e0240f0e391 100644 (file)
@@ -96,7 +96,7 @@ def test_urls():
     import rna_wiki_reference
 
     import urllib.error
-    from urllib.request import urlopen
+   from urllib.request import urlopen
 
     prefix = rna_wiki_reference.url_manual_prefix
     urls = {suffix for (rna_id, suffix) in rna_wiki_reference.url_manual_mapping}
@@ -118,7 +118,7 @@ def test_urls():
         print("  %s ... " % url_full, end="")
         sys.stdout.flush()
         try:
-            urllib.request.urlopen(url_full)
+            urlopen(url_full)
             print(color_green + "OK" + color_normal)
         except urllib.error.HTTPError:
             print(color_red + "FAIL!" + color_normal)
index 235bca48104fab19527210b5c47384465a8b93f0..cca49d54ac0a2a86a048d4abfb4e6df23861b62d 100644 (file)
 
 import os
 
-# depends on pep8, pyflakes, pylint
+# depends on pep8, frosted, pylint
 # for Ubuntu
 #
-#   sudo apt-get install pylint pyflakes
+#   sudo apt-get install pylint
 #
 #   sudo apt-get install python-setuptools python-pip
 #   sudo pip install pep8
+#   sudo pip install frosted
 #
-# in Debian install pylint pyflakes pep8 with apt-get/aptitude/etc
+# in Debian install pylint pep8 with apt-get/aptitude/etc
 #
 # on *nix run
 #   python source/tests/pep8.py > test_pep8.log 2>&1
@@ -118,10 +119,10 @@ def main():
 
         os.system("pep8 --repeat --ignore=%s '%s'" % (",".join(ignore_tmp), f))
 
-    # pyflakes
-    print("\n\n\n# running pyflakes...")
+    # frosted
+    print("\n\n\n# running frosted...")
     for f, pep8_type in files:
-        os.system("pyflakes '%s'" % f)
+        os.system("frosted '%s'" % f)
 
     print("\n\n\n# running pylint...")
     for f, pep8_type in files:
index cb7b029129694dab38c1d5003aac86c904187254..6a885a108f80b1fc3c10b415911d4fe937c8f0c6 100644 (file)
@@ -50,7 +50,6 @@ def parse_rst_py(filepath):
     indent_map = {}
     indent_prev = 0
     f = open(filepath, encoding="utf-8")
-    indent_lists = []
     for i, line in enumerate(f):
         line_strip = line.lstrip()
         # ^\.\.\s[a-zA-Z09\-]+::.*$