Code cleanup: unused python vars & imports

Use frosted rather then pyflakes
This commit is contained in:
2014-04-25 05:31:20 +10:00
parent 16443b1ae0
commit a15be34389
31 changed files with 24 additions and 61 deletions

View File

@@ -62,7 +62,7 @@ Sphinx: PDF generation
try: try:
import bpy # blender module import bpy # blender module
except: except ImportError:
print("\nERROR: this script must run from inside Blender") print("\nERROR: this script must run from inside Blender")
print(SCRIPT_HELP_MSG) print(SCRIPT_HELP_MSG)
import sys import sys

View File

@@ -571,7 +571,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
rd = context.scene.render rd = context.scene.render
scene = context.scene scene = context.scene
cscene = scene.cycles # cscene = scene.cycles
layout.active = rd.use_motion_blur layout.active = rd.use_motion_blur
@@ -585,7 +585,7 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
rd = context.scene.render rd = context.scene.render
scene = context.scene scene = context.scene
cscene = scene.cycles # cscene = scene.cycles
ob = context.object ob = context.object
cob = ob.cycles cob = ob.cycles
@@ -1194,7 +1194,7 @@ class CyclesRender_PT_CurveRendering(CyclesButtonsPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
scene = context.scene scene = context.scene
cscene = scene.cycles # cscene = scene.cycles
psys = context.particle_system psys = context.particle_system
return CyclesButtonsPanel.poll(context) and psys and psys.settings.type == 'HAIR' return CyclesButtonsPanel.poll(context) and psys and psys.settings.type == 'HAIR'
@@ -1233,7 +1233,7 @@ class CyclesParticle_PT_CurveSettings(CyclesButtonsPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
scene = context.scene scene = context.scene
cscene = scene.cycles # cscene = scene.cycles
ccscene = scene.cycles_curves ccscene = scene.cycles_curves
psys = context.particle_system psys = context.particle_system
use_curves = ccscene.use_curves and psys use_curves = ccscene.use_curves and psys

View File

@@ -229,9 +229,9 @@ def check(module_name):
def _addon_ensure(module_name): def _addon_ensure(module_name):
addons = _user_preferences.addons addons = _user_preferences.addons
addon = _user_preferences.addons.get(module_name) addon = addons.get(module_name)
if not addon: if not addon:
addon = _user_preferences.addons.new() addon = addons.new()
addon.module = module_name addon.module = module_name

View File

@@ -73,16 +73,11 @@ def region_2d_to_origin_3d(region, rv3d, coord):
:return: The origin of the viewpoint in 3d space. :return: The origin of the viewpoint in 3d space.
:rtype: :class:`mathutils.Vector` :rtype: :class:`mathutils.Vector`
""" """
from mathutils import Vector
viewinv = rv3d.view_matrix.inverted() viewinv = rv3d.view_matrix.inverted()
if rv3d.is_perspective: if rv3d.is_perspective:
from mathutils.geometry import intersect_line_plane
origin_start = viewinv.translation.copy() origin_start = viewinv.translation.copy()
else: else:
from mathutils.geometry import intersect_point_line
persmat = rv3d.perspective_matrix.copy() persmat = rv3d.perspective_matrix.copy()
dx = (2.0 * coord[0] / region.width) - 1.0 dx = (2.0 * coord[0] / region.width) - 1.0
dy = (2.0 * coord[1] / region.height) - 1.0 dy = (2.0 * coord[1] / region.height) - 1.0

View File

@@ -18,7 +18,6 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
from bpy.types import Menu, Panel
class NodeCategory(): class NodeCategory():
@@ -92,7 +91,6 @@ def register_node_categories(identifier, cat_list):
def draw_node_item(self, context): def draw_node_item(self, context):
layout = self.layout layout = self.layout
col = layout.column() col = layout.column()
default_context = bpy.app.translations.contexts.default
for item in self.category.items(context): for item in self.category.items(context):
item.draw(item, col, context) item.draw(item, col, context)

View File

@@ -292,7 +292,6 @@ def draw_filtered(display_keymaps, filter_type, filter_text, layout):
kmi_type_set.add(v) kmi_type_set.add(v)
return kmi_type_set return kmi_type_set
kmi_type_set_combine = None
for i, kmi_type in enumerate(filter_text_split): for i, kmi_type in enumerate(filter_text_split):
kmi_type_set = kmi_type_set_from_string(kmi_type) kmi_type_set = kmi_type_set_from_string(kmi_type)

View File

@@ -22,7 +22,6 @@ from bpy.types import Operator
from bpy.props import (FloatProperty, from bpy.props import (FloatProperty,
IntProperty, IntProperty,
BoolProperty,
) )
from bpy.app.translations import pgettext_data as data_ from bpy.app.translations import pgettext_data as data_

View File

@@ -87,7 +87,6 @@ class MeshMirrorUV(Operator):
polys = mesh.polygons polys = mesh.polygons
loops = mesh.loops loops = mesh.loops
verts = mesh.vertices
uv_loops = mesh.uv_layers.active.data uv_loops = mesh.uv_layers.active.data
nbr_polys = len(polys) nbr_polys = len(polys)

View File

@@ -61,7 +61,6 @@ class NodeAddOperator():
@staticmethod @staticmethod
def store_mouse_cursor(context, event): def store_mouse_cursor(context, event):
space = context.space_data space = context.space_data
v2d = context.region.view2d
tree = space.edit_tree tree = space.edit_tree
# convert mouse position to the View2D for later node placement # convert mouse position to the View2D for later node placement

View File

@@ -687,7 +687,6 @@ class TransformsToDeltasAnim(Operator):
DELTA_PATHS = STANDARD_TO_DELTA_PATHS.values() DELTA_PATHS = STANDARD_TO_DELTA_PATHS.values()
# try to apply on each selected object # try to apply on each selected object
success = False
for obj in context.selected_editable_objects: for obj in context.selected_editable_objects:
adt = obj.animation_data adt = obj.animation_data
if (adt is None) or (adt.action is None): if (adt is None) or (adt.action is None):
@@ -792,7 +791,6 @@ class LodByName(Operator):
return (context.active_object is not None) return (context.active_object is not None)
def execute(self, context): def execute(self, context):
scene = context.scene
ob = context.active_object ob = context.active_object
prefix = "" prefix = ""
@@ -843,7 +841,6 @@ class LodClearAll(Operator):
return (context.active_object is not None) return (context.active_object is not None)
def execute(self, context): def execute(self, context):
scene = context.scene
ob = context.active_object ob = context.active_object
if ob.lod_levels: if ob.lod_levels:

View File

@@ -183,7 +183,6 @@ class VertexPaintDirt(Operator):
def execute(self, context): def execute(self, context):
import time import time
from math import radians
obj = context.object obj = context.object
mesh = obj.data mesh = obj.data

View File

@@ -19,7 +19,6 @@
# <pep8-80 compliant> # <pep8-80 compliant>
import bpy import bpy
import mathutils
from bpy.types import Operator from bpy.types import Operator
from bpy.props import BoolProperty from bpy.props import BoolProperty

View File

@@ -19,7 +19,7 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
from bpy.types import Menu, Operator from bpy.types import Operator
from bpy.props import (StringProperty, from bpy.props import (StringProperty,
BoolProperty, BoolProperty,
IntProperty, IntProperty,

View File

@@ -195,7 +195,6 @@ class UI_UL_list(bpy.types.UIList):
return a list mapping org_idx -> new_idx, return a list mapping org_idx -> new_idx,
or an empty list if no sorting has been done. 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)] _sort = [(idx, getattr(it, propname, "")) for idx, it in enumerate(items)]
return cls.sort_items_helper(_sort, lambda e: e[1].lower()) return cls.sort_items_helper(_sort, lambda e: e[1].lower())

View File

@@ -292,7 +292,7 @@ class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
return (context.object) and (context.armature) return (context.object) and (context.armature)
def draw(self, context): def draw(self, context):
layout = self.layout # layout = self.layout
ob = context.object ob = context.object
avs = ob.pose.animation_visualization avs = ob.pose.animation_visualization

View 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): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.ShapeKey) # assert(isinstance(item, bpy.types.ShapeKey)
obj = active_data obj = active_data
key = data # key = data
key_block = item key_block = item
if self.layout_type in {'DEFAULT', 'COMPACT'}: if self.layout_type in {'DEFAULT', 'COMPACT'}:
split = layout.split(0.66, False) split = layout.split(0.66, False)
@@ -323,7 +323,6 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
layout = self.layout layout = self.layout
me = context.mesh me = context.mesh
lay = me.uv_textures.active
row = layout.row() row = layout.row()
col = row.column() col = row.column()
@@ -343,7 +342,6 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
layout = self.layout layout = self.layout
me = context.mesh me = context.mesh
lay = me.vertex_colors.active
row = layout.row() row = layout.row()
col = row.column() col = row.column()

View File

@@ -377,7 +377,6 @@ class MASK_MT_select(Menu):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
sc = context.space_data
layout.operator("mask.select_border") layout.operator("mask.select_border")
layout.operator("mask.select_circle") layout.operator("mask.select_circle")

View File

@@ -73,7 +73,7 @@ class MATERIAL_MT_specials(Menu):
class MATERIAL_UL_matslots(UIList): class MATERIAL_UL_matslots(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
# assert(isinstance(item, bpy.types.MaterialSlot) # assert(isinstance(item, bpy.types.MaterialSlot)
ob = data # ob = data
slot = item slot = item
ma = slot.material ma = slot.material
if self.layout_type in {'DEFAULT', 'COMPACT'}: if self.layout_type in {'DEFAULT', 'COMPACT'}:

View File

@@ -324,7 +324,7 @@ class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel):
return (context.object) return (context.object)
def draw(self, context): def draw(self, context):
layout = self.layout # layout = self.layout
ob = context.object ob = context.object
avs = ob.animation_visualization avs = ob.animation_visualization

View File

@@ -18,7 +18,7 @@
# <pep8 compliant> # <pep8 compliant>
import bpy import bpy
from bpy.types import Menu, Panel, UIList from bpy.types import Panel, UIList
class RenderLayerButtonsPanel(): class RenderLayerButtonsPanel():

View File

@@ -182,7 +182,6 @@ class SCENE_PT_color_management(SceneButtonsPanel, Panel):
layout = self.layout layout = self.layout
scene = context.scene scene = context.scene
rd = scene.render
col = layout.column() col = layout.column()
col.label(text="Display:") col.label(text="Display:")

View File

@@ -262,7 +262,6 @@ class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
sc = context.space_data sc = context.space_data
clip = sc.clip clip = sc.clip
settings = clip.tracking.settings
col = layout.column(align=True) col = layout.column(align=True)
row = col.row(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): def draw(self, context):
layout = self.layout layout = self.layout
sc = context.space_data
clip = context.space_data.clip clip = context.space_data.clip
active_track = clip.tracking.plane_tracks.active 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 layout = self.layout
sc = context.space_data sc = context.space_data
clip = sc.clip
col = layout.column() col = layout.column()
col.template_movieclip_information(sc, "clip", sc.clip_user) col.template_movieclip_information(sc, "clip", sc.clip_user)

View File

@@ -458,7 +458,6 @@ class MASK_MT_editor_menus(Menu):
sima = context.space_data sima = context.space_data
ima = sima.image ima = sima.image
show_render = sima.show_render
show_uvedit = sima.show_uvedit show_uvedit = sima.show_uvedit
show_maskedit = sima.show_maskedit show_maskedit = sima.show_maskedit
@@ -759,7 +758,6 @@ class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
toolsettings = context.tool_settings.image_paint toolsettings = context.tool_settings.image_paint
brush = toolsettings.brush brush = toolsettings.brush
tex_slot = brush.texture_slot
col = layout.column() col = layout.column()
col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8) 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 layout = self.layout
brush = context.tool_settings.image_paint.brush brush = context.tool_settings.image_paint.brush
tex_slot_alpha = brush.mask_texture_slot
col = layout.column() col = layout.column()

View File

@@ -274,7 +274,6 @@ class NODE_PT_active_node_generic(Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
space = context.space_data
return context.active_node is not None return context.active_node is not None
def draw(self, context): def draw(self, context):
@@ -293,7 +292,6 @@ class NODE_PT_active_node_color(Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
space = context.space_data
return context.active_node is not None return context.active_node is not None
def draw_header(self, context): def draw_header(self, context):
@@ -323,7 +321,6 @@ class NODE_PT_active_node_properties(Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
space = context.space_data
return context.active_node is not None return context.active_node is not None
def draw(self, context): def draw(self, context):

View File

@@ -486,7 +486,6 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
sequencer = context.scene.sequence_editor
strip = act_strip(context) strip = act_strip(context)
if strip.input_count > 0: if strip.input_count > 0:

View File

@@ -30,8 +30,7 @@ class VIEW3D_HT_header(Header):
layout = self.layout layout = self.layout
view = context.space_data view = context.space_data
mode_string = context.mode # mode_string = context.mode
edit_object = context.edit_object
obj = context.active_object obj = context.active_object
toolsettings = context.tool_settings toolsettings = context.tool_settings
@@ -2793,8 +2792,6 @@ class VIEW3D_PT_view3d_display(Panel):
view = context.space_data view = context.space_data
scene = context.scene scene = context.scene
gs = scene.game_settings
obj = context.object
col = layout.column() col = layout.column()
col.prop(view, "show_only_render") col.prop(view, "show_only_render")

View File

@@ -1100,7 +1100,6 @@ class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
settings = self.paint_settings(context) settings = self.paint_settings(context)
brush = settings.brush brush = settings.brush
tex_slot = brush.texture_slot
col = layout.column() col = layout.column()
@@ -1124,7 +1123,6 @@ class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
layout = self.layout layout = self.layout
brush = context.tool_settings.image_paint.brush brush = context.tool_settings.image_paint.brush
tex_slot_alpha = brush.mask_texture_slot
col = layout.column() col = layout.column()

View File

@@ -164,7 +164,6 @@ def dice(filepath, output, output_prefix, name_style,
minx_icon, miny_icon, maxx_icon, maxy_icon, minx_icon, miny_icon, maxx_icon, maxy_icon,
spacex_icon, spacey_icon, spacex_icon, spacey_icon,
): ):
import struct
is_simple = (max(minx, miny, maxx, maxy, is_simple = (max(minx, miny, maxx, maxy,
minx_icon, miny_icon, maxx_icon, maxy_icon, minx_icon, miny_icon, maxx_icon, maxy_icon,
@@ -209,7 +208,7 @@ def dice(filepath, output, output_prefix, name_style,
# simple, no margins # simple, no margins
if is_simple: if is_simple:
sub_x = x * icon_x sub_x = x * icon_w
sub_y = y * icon_h sub_y = y * icon_h
else: else:
sub_x = minx + ((x * (icon_w + spacex_icon)) + minx_icon) sub_x = minx + ((x * (icon_w + spacex_icon)) + minx_icon)

View File

@@ -96,7 +96,7 @@ def test_urls():
import rna_wiki_reference import rna_wiki_reference
import urllib.error import urllib.error
from urllib.request import urlopen from urllib.request import urlopen
prefix = rna_wiki_reference.url_manual_prefix prefix = rna_wiki_reference.url_manual_prefix
urls = {suffix for (rna_id, suffix) in rna_wiki_reference.url_manual_mapping} 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="") print(" %s ... " % url_full, end="")
sys.stdout.flush() sys.stdout.flush()
try: try:
urllib.request.urlopen(url_full) urlopen(url_full)
print(color_green + "OK" + color_normal) print(color_green + "OK" + color_normal)
except urllib.error.HTTPError: except urllib.error.HTTPError:
print(color_red + "FAIL!" + color_normal) print(color_red + "FAIL!" + color_normal)

View File

@@ -20,15 +20,16 @@
import os import os
# depends on pep8, pyflakes, pylint # depends on pep8, frosted, pylint
# for Ubuntu # for Ubuntu
# #
# sudo apt-get install pylint pyflakes # sudo apt-get install pylint
# #
# sudo apt-get install python-setuptools python-pip # sudo apt-get install python-setuptools python-pip
# sudo pip install pep8 # 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 # on *nix run
# python source/tests/pep8.py > test_pep8.log 2>&1 # 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)) os.system("pep8 --repeat --ignore=%s '%s'" % (",".join(ignore_tmp), f))
# pyflakes # frosted
print("\n\n\n# running pyflakes...") print("\n\n\n# running frosted...")
for f, pep8_type in files: for f, pep8_type in files:
os.system("pyflakes '%s'" % f) os.system("frosted '%s'" % f)
print("\n\n\n# running pylint...") print("\n\n\n# running pylint...")
for f, pep8_type in files: for f, pep8_type in files:

View File

@@ -50,7 +50,6 @@ def parse_rst_py(filepath):
indent_map = {} indent_map = {}
indent_prev = 0 indent_prev = 0
f = open(filepath, encoding="utf-8") f = open(filepath, encoding="utf-8")
indent_lists = []
for i, line in enumerate(f): for i, line in enumerate(f):
line_strip = line.lstrip() line_strip = line.lstrip()
# ^\.\.\s[a-zA-Z09\-]+::.*$ # ^\.\.\s[a-zA-Z09\-]+::.*$