replace import *'s with named imports (using * is convenient for some scripts but...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 27 Feb 2011 15:25:24 +0000 (15:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 27 Feb 2011 15:25:24 +0000 (15:25 +0000)
19 files changed:
release/scripts/keyingsets/keyingsets_builtins.py
release/scripts/modules/io_utils.py
release/scripts/op/add_mesh_torus.py
release/scripts/op/nla.py
release/scripts/op/object.py
release/scripts/op/object_align.py
release/scripts/op/object_randomize_transform.py
release/scripts/op/sequencer.py
release/scripts/op/uv.py
release/scripts/op/uvcalc_smart_project.py
release/scripts/op/wm.py
release/scripts/templates/builtin_keyingset.py
release/scripts/templates/operator_export.py
release/scripts/templates/operator_mesh_add.py
release/scripts/templates/operator_modal.py
release/scripts/ui/properties_scene.py
release/scripts/ui/space_console.py
release/scripts/ui/space_userpref_keymap.py
source/tests/pep8.py

index cff4aecac54c5cc049e92b16247eeb3dc91bfcd7..6b0b282fd4735b8b9e68ed961191513575aab3ef 100644 (file)
@@ -26,7 +26,7 @@ to work correctly.
 """
 
 import bpy
-from keyingsets_utils import *
+import keyingsets_utils
 
 ###############################
 # Built-In KeyingSets
@@ -37,13 +37,13 @@ class BUILTIN_KSI_Location(bpy.types.KeyingSetInfo):
     bl_label = "Location"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for location
-    generate = RKS_GEN_location
+    generate = keyingsets_utils.RKS_GEN_location
 
 
 # Rotation
@@ -51,13 +51,13 @@ class BUILTIN_KSI_Rotation(bpy.types.KeyingSetInfo):
     bl_label = "Rotation"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for location
-    generate = RKS_GEN_rotation
+    generate = keyingsets_utils.RKS_GEN_rotation
 
 
 # Scale
@@ -65,13 +65,13 @@ class BUILTIN_KSI_Scaling(bpy.types.KeyingSetInfo):
     bl_label = "Scaling"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for location
-    generate = RKS_GEN_scaling
+    generate = keyingsets_utils.RKS_GEN_scaling
 
 # ------------
 
@@ -81,17 +81,17 @@ class BUILTIN_KSI_LocRot(bpy.types.KeyingSetInfo):
     bl_label = "LocRot"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator
     def generate(self, context, ks, data):
         # location
-        RKS_GEN_location(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_location(self, context, ks, data)
         # rotation
-        RKS_GEN_rotation(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_rotation(self, context, ks, data)
 
 
 # LocScale
@@ -99,17 +99,17 @@ class BUILTIN_KSI_LocScale(bpy.types.KeyingSetInfo):
     bl_label = "LocScale"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator
     def generate(self, context, ks, data):
         # location
-        RKS_GEN_location(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_location(self, context, ks, data)
         # scale
-        RKS_GEN_scaling(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_scaling(self, context, ks, data)
 
 
 # LocRotScale
@@ -117,19 +117,19 @@ class BUILTIN_KSI_LocRotScale(bpy.types.KeyingSetInfo):
     bl_label = "LocRotScale"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator
     def generate(self, context, ks, data):
         # location
-        RKS_GEN_location(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_location(self, context, ks, data)
         # rotation
-        RKS_GEN_rotation(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_rotation(self, context, ks, data)
         # scale
-        RKS_GEN_scaling(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_scaling(self, context, ks, data)
 
 
 # RotScale
@@ -137,17 +137,17 @@ class BUILTIN_KSI_RotScale(bpy.types.KeyingSetInfo):
     bl_label = "RotScale"
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator
     def generate(self, context, ks, data):
         # rotation
-        RKS_GEN_rotation(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_rotation(self, context, ks, data)
         # scaling
-        RKS_GEN_scaling(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_scaling(self, context, ks, data)
 
 # ------------
 
@@ -159,13 +159,13 @@ class BUILTIN_KSI_VisualLoc(bpy.types.KeyingSetInfo):
     bl_options = {'INSERTKEY_VISUAL'}
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for location
-    generate = RKS_GEN_location
+    generate = keyingsets_utils.RKS_GEN_location
 
 
 # Rotation
@@ -175,13 +175,13 @@ class BUILTIN_KSI_VisualRot(bpy.types.KeyingSetInfo):
     bl_options = {'INSERTKEY_VISUAL'}
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for rotation
-    generate = RKS_GEN_rotation
+    generate = keyingsets_utils.RKS_GEN_rotation
 
 
 # VisualLocRot
@@ -191,17 +191,17 @@ class BUILTIN_KSI_VisualLocRot(bpy.types.KeyingSetInfo):
     bl_options = {'INSERTKEY_VISUAL'}
 
     # poll - use predefined callback for selected bones/objects
-    poll = RKS_POLL_selected_items
+    poll = keyingsets_utils.RKS_POLL_selected_items
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator
     def generate(self, context, ks, data):
         # location
-        RKS_GEN_location(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_location(self, context, ks, data)
         # rotation
-        RKS_GEN_rotation(self, context, ks, data)
+        keyingsets_utils.RKS_GEN_rotation(self, context, ks, data)
 
 # ------------
 
@@ -213,13 +213,13 @@ class BUILTIN_KSI_Available(bpy.types.KeyingSetInfo):
     # poll - use predefined callback for selected objects
     # TODO: this should really check whether the selected object (or datablock)
     #         has any animation data defined yet
-    poll = RKS_POLL_selected_objects
+    poll = keyingsets_utils.RKS_POLL_selected_objects
 
     # iterator - use callback for selected bones/objects
-    iterator = RKS_ITER_selected_item
+    iterator = keyingsets_utils.RKS_ITER_selected_item
 
     # generator - use callback for doing this
-    generate = RKS_GEN_available
+    generate = keyingsets_utils.RKS_GEN_available
 
 ###############################
 
@@ -278,7 +278,7 @@ class BUILTIN_KSI_WholeCharacter(bpy.types.KeyingSetInfo):
             path = id_path + prop
         else:
             # standard transforms/properties
-            path = path_add_property(id_path, prop)
+            path = keyingsets_utils.path_add_property(id_path, prop)
 
         # add Keying Set entry for this...
         if use_groups:
@@ -363,5 +363,3 @@ def unregister():
 
 if __name__ == "__main__":
     register()
-
-###############################
index 39b386691887fb267c292f6aed0de42a367ee8fb..69e82f15327d78b2eec0dd623b6a0f169286ec07 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from bpy.props import *
+from bpy.props import StringProperty, BoolProperty
 
 
 class ExportHelper:
index c3c7d92bdedcae711f17d346ff55e2fd2e932f2b..ab2163c9ac6369e3f67a9f8efef80e30a25712c7 100644 (file)
@@ -72,7 +72,7 @@ def add_torus(major_rad, minor_rad, major_seg, minor_seg):
 
     return verts, faces
 
-from bpy.props import *
+from bpy.props import FloatProperty, IntProperty, BoolProperty, FloatVectorProperty
 
 
 class AddTorus(bpy.types.Operator):
index 5711fdf12e5d0bdf6f62eeb71e3ef385208762d6..2dbf071f7e9aa33c057f6cfd4745408aa28f3fcf 100644 (file)
@@ -124,7 +124,7 @@ def bake(frame_start, frame_end, step=1, only_selected=False):
     return action
 
 
-from bpy.props import *
+from bpy.props import IntProperty, BoolProperty
 
 
 class BakeAction(bpy.types.Operator):
index 81ddd4f7c35b1d1b99ed01de56d648c3593fd5a9..7b39281c7b0d282e8716bd67eea90634c3302d25 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from bpy.props import *
+from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty
 
 
 class SelectPattern(bpy.types.Operator):
index d98fe584c1a2670e03293fc4c02e2a8228fbdd29..4dd4ebd78ff822c940c27951035c10a3f3b5e174 100644 (file)
@@ -230,7 +230,7 @@ def align_objects(align_x, align_y, align_z, align_mode, relative_to):
     return True
 
 
-from bpy.props import *
+from bpy.props import EnumProperty
 
 
 class AlignObjects(bpy.types.Operator):
@@ -239,7 +239,7 @@ class AlignObjects(bpy.types.Operator):
     bl_label = "Align Objects"
     bl_options = {'REGISTER', 'UNDO'}
 
-    align_mode = bpy.props.EnumProperty(items=(
+    align_mode = EnumProperty(items=(
             ('OPT_1', "Negative Sides", ""),
             ('OPT_2', "Centers", ""),
             ('OPT_3', "Positive Sides", "")),
@@ -247,7 +247,7 @@ class AlignObjects(bpy.types.Operator):
         description="",
         default='OPT_2')
 
-    relative_to = bpy.props.EnumProperty(items=(
+    relative_to = EnumProperty(items=(
             ('OPT_1', "Scene Origin", ""),
             ('OPT_2', "3D Cursor", ""),
             ('OPT_3', "Selection", ""),
index ee7a5f98b91fe3ed60226451b25328b5c56d1319..bd24d3833d5379ea83781691c2b3b1e26eb65090 100644 (file)
@@ -84,7 +84,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even):
             uniform(0.0, 0.0), uniform(0.0, 0.0), uniform(0.0, 0.0)
 
 
-from bpy.props import *
+from bpy.props import IntProperty, BoolProperty, FloatProperty, FloatVectorProperty
 
 
 class RandomizeLocRotSize(bpy.types.Operator):
index de341bef269dc2e4f129541eeabad54d6a08c5a6..45a27154d840237a39b9cbbdcd7214507efddaa0 100644 (file)
@@ -20,7 +20,7 @@
 
 import bpy
 
-from bpy.props import *
+from bpy.props import IntProperty
 
 
 class SequencerCrossfadeSounds(bpy.types.Operator):
index 83282924b5be2342a3b5eec6b43709a962a6b87a..4729294b0c8e028400343c2f6ee8d3cad2977820 100644 (file)
@@ -19,7 +19,6 @@
 # <pep8 compliant>
 
 import bpy
-from bpy.props import *
 
 
 def write_svg(fw, mesh, image_width, image_height, face_iter):
@@ -239,6 +238,9 @@ def write_png(fw, mesh_source, image_width, image_height, face_iter):
         bpy.data.materials.remove(mat_solid)
 
 
+from bpy.props import StringProperty, BoolProperty, EnumProperty, IntVectorProperty
+
+
 class ExportUVLayout(bpy.types.Operator):
     """Export UV layout to file"""
 
index 7ee7c119c4eb49ed2446a2dc5bc102e1bc0c9fb3..4408b2d3755d7366f9a6842a054c38d95311bf90 100644 (file)
@@ -1115,7 +1115,7 @@ def main(context, island_margin, projection_limit):
     ]
 """
 
-from bpy.props import *
+from bpy.props import FloatProperty
 
 
 class SmartProject(bpy.types.Operator):
index 89e9641ba93995a2aaab20490fb915979d08839a..ae40665ecd24eb66bfb6e3c144b9010abdcd46f6 100644 (file)
 # <pep8 compliant>
 
 import bpy
-
-from bpy.props import *
+from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty
 from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear
 
-
 class MESH_OT_delete_edgeloop(bpy.types.Operator):
     '''Delete an edge loop by merging the faces on each side to a single face loop'''
     bl_idname = "mesh.delete_edgeloop"
@@ -702,9 +700,6 @@ class WM_OT_doc_edit(bpy.types.Operator):
         return wm.invoke_props_dialog(self, width=600)
 
 
-from bpy.props import *
-
-
 rna_path = StringProperty(name="Property Edit",
     description="Property data_path edit", maxlen=1024, default="", options={'HIDDEN'})
 
index 0b808e9cd26cc93d61d0ae85d6249424149257a7..19f92dc75e774de0043d6eee7b8b8e346c136206 100644 (file)
@@ -1,5 +1,4 @@
 import bpy
-from keyingsets_utils import *
 
 
 class BUILTIN_KSI_hello(bpy.types.KeyingSetInfo):
@@ -7,7 +6,7 @@ class BUILTIN_KSI_hello(bpy.types.KeyingSetInfo):
 
     # poll - test for whether Keying Set can be used at all
     def poll(ksi, context):
-        return (context.active_object) or (context.selected_objects)
+        return context.active_object or context.selected_objects
 
     # iterator - go over all relevant data, calling generate()
     def iterator(ksi, context, ks):
index 5390d32aeffa7a77837d462f55c04f0040afa5c0..af359517e405793da700b95bcd36853680b1d5a9 100644 (file)
@@ -13,8 +13,7 @@ def write_some_data(context, filepath, use_some_setting):
 # ExportHelper is a helper class, defines filename and
 # invoke() function which calls the file selector.
 from io_utils import ExportHelper
-
-from bpy.props import *
+from bpy.props import StringProperty, BoolProperty, EnumProperty
 
 
 class ExportSomeData(bpy.types.Operator, ExportHelper):
@@ -31,7 +30,9 @@ class ExportSomeData(bpy.types.Operator, ExportHelper):
     # to the class instance from the operator settings before calling.
     use_setting = BoolProperty(name="Example Boolean", description="Example Tooltip", default=True)
 
-    type = bpy.props.EnumProperty(items=(('OPT_A', "First Option", "Description one"), ('OPT_B', "Second Option", "Description two.")),
+    type = EnumProperty(items=(('OPT_A', "First Option", "Description one"),
+                               ('OPT_B', "Second Option", "Description two."),
+                               ),
                         name="Example Enum",
                         description="Choose between two items",
                         default='OPT_A')
index 77d172b3068cde22f38f0b23633992470c1466b5..65b08eebb4e4a24b1f2ee887055e3948e38f435f 100644 (file)
@@ -34,7 +34,7 @@ def add_box(width, height, depth):
     return vertices, faces
 
 
-from bpy.props import *
+from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty
 
 
 class AddBox(bpy.types.Operator):
index 6eb3843d6a641602e16af02bb6257c645149f2a8..78dbd4c6b433d5e47239f75e650d5668f58df896 100644 (file)
@@ -1,5 +1,5 @@
 import bpy
-from bpy.props import *
+from bpy.props import IntProperty, FloatProperty
 
 
 class ModalOperator(bpy.types.Operator):
index 48eed73927b73bd302cbb043a61ff9e29e7b9eb3..e28753f2df8099dc3c9ff83765298acc069fed16 100644 (file)
@@ -195,9 +195,6 @@ class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, bpy.types.Panel):
     _context_path = "scene"
     _property_type = bpy.types.Scene
 
-
-from bpy.props import *
-
 #  XXX, move operator to op/ dir
 
 
index 97720947e37c44f0ebe08a7a9747b97fda64d544..035b48e36d5b03bcc2110d446896eb1bd14a02b0 100644 (file)
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.props import *
+from bpy.props import StringProperty
 
 
 class CONSOLE_HT_header(bpy.types.Header):
index 34d461fbef214cbf6be4469d7a304e67e452bd59..3c002047b0694817ec18cf058594fe96723721e6 100644 (file)
@@ -404,7 +404,7 @@ class InputKeyMapPanel(bpy.types.Panel):
             self.draw_hierarchy(display_keymaps, col)
 
 
-from bpy.props import *
+from bpy.props import StringProperty, BoolProperty, IntProperty
 
 
 def export_properties(prefix, properties, lines=None):
index ee71c877533440055b1b48aea57a7247054a424a..c4c2da3f18586ac89d170e0fda166a4403e479cf 100644 (file)
@@ -87,7 +87,15 @@ def main():
     for f in files_skip:
         print("    %s" % f)
 
-    # pyflakes
+    # strict imports
+    print("\n\n\n# running pep8...")
+    import re
+    import_check = re.compile(r"\s*from\s+[A-z\.]+\s+import \*\s*")
+    for f, pep8_type in files:
+        for i, l in enumerate(open(f, 'r', encoding='utf8')):
+            if import_check.match(l):
+                print("%s:%d:0: global import bad practice" % (f, i + 1))
+
     print("\n\n\n# running pep8...")
     for f, pep8_type in files:
         if pep8_type == 1:
@@ -96,6 +104,7 @@ def main():
         else:
             os.system("pep8 --repeat '%s'" % (f))
 
+    # pyflakes
     print("\n\n\n# running pyflakes...")
     for f, pep8_type in files:
         os.system("pyflakes '%s'" % f)