From 3c23caa4c0b31b9908a43737369b715915a8fe62 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Jul 2016 03:52:13 +1000 Subject: Cleanup: use identity for None comparisons --- rigify/generate.py | 2 +- rigify/rig_ui_template.py | 8 +++--- rigify/rigs/biped/arm/fk.py | 2 +- rigify/rigs/biped/arm/ik.py | 2 +- rigify/rigs/biped/leg/fk.py | 2 +- rigify/rigs/biped/leg/ik.py | 4 +-- rigify/rigs/biped/limb_common.py | 50 +++++++++++++++++------------------ rigify/rigs/finger.py | 2 +- rigify/rigs/palm.py | 2 +- rigify/rigs/pitchipoy/super_finger.py | 2 +- rigify/utils.py | 2 +- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/rigify/generate.py b/rigify/generate.py index 27ccf141..4fb83f5d 100644 --- a/rigify/generate.py +++ b/rigify/generate.py @@ -279,7 +279,7 @@ def generate_rig(context, metarig): obj.select = True bpy.ops.object.mode_set(mode='EDIT') scripts = rig.generate() - if scripts != None: + if scripts is not None: ui_scripts += [scripts[0]] t.tick("Generate rigs: ") except Exception as e: diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py index c37b9db6..717410da 100644 --- a/rigify/rig_ui_template.py +++ b/rigify/rig_ui_template.py @@ -386,7 +386,7 @@ class Rigify_Arm_FK2IK(bpy.types.Operator): @classmethod def poll(cls, context): - return (context.active_object != None and context.mode == 'POSE') + return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): use_global_undo = context.user_preferences.edit.use_global_undo @@ -416,7 +416,7 @@ class Rigify_Arm_IK2FK(bpy.types.Operator): @classmethod def poll(cls, context): - return (context.active_object != None and context.mode == 'POSE') + return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): use_global_undo = context.user_preferences.edit.use_global_undo @@ -447,7 +447,7 @@ class Rigify_Leg_FK2IK(bpy.types.Operator): @classmethod def poll(cls, context): - return (context.active_object != None and context.mode == 'POSE') + return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): use_global_undo = context.user_preferences.edit.use_global_undo @@ -479,7 +479,7 @@ class Rigify_Leg_IK2FK(bpy.types.Operator): @classmethod def poll(cls, context): - return (context.active_object != None and context.mode == 'POSE') + return (context.active_object is not None and context.mode == 'POSE') def execute(self, context): use_global_undo = context.user_preferences.edit.use_global_undo diff --git a/rigify/rigs/biped/arm/fk.py b/rigify/rigs/biped/arm/fk.py index 740b3277..03ff6fc9 100644 --- a/rigify/rigs/biped/arm/fk.py +++ b/rigify/rigs/biped/arm/fk.py @@ -73,7 +73,7 @@ class Rig: # Create hand widget ob = create_widget(self.obj, hand) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data diff --git a/rigify/rigs/biped/arm/ik.py b/rigify/rigs/biped/arm/ik.py index a57256ea..e4cd2b5d 100644 --- a/rigify/rigs/biped/arm/ik.py +++ b/rigify/rigs/biped/arm/ik.py @@ -77,7 +77,7 @@ class Rig: # vishand = bone_list[6] ob = create_widget(self.obj, hand) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data diff --git a/rigify/rigs/biped/leg/fk.py b/rigify/rigs/biped/leg/fk.py index 743e3a19..bf055fa5 100644 --- a/rigify/rigs/biped/leg/fk.py +++ b/rigify/rigs/biped/leg/fk.py @@ -117,7 +117,7 @@ class Rig: # Create foot widget ob = create_widget(self.obj, foot) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data diff --git a/rigify/rigs/biped/leg/ik.py b/rigify/rigs/biped/leg/ik.py index b0df999d..82422e27 100644 --- a/rigify/rigs/biped/leg/ik.py +++ b/rigify/rigs/biped/leg/ik.py @@ -326,7 +326,7 @@ class Rig: create_circle_widget(self.obj, toe, radius=0.7, head_tail=0.5) ob = create_widget(self.obj, foot_roll) - if ob != None: + if ob is not None: verts = [(0.3999999761581421, 0.766044557094574, 0.6427875757217407), (0.17668449878692627, 3.823702598992895e-08, 3.2084670920085046e-08), (-0.17668461799621582, 9.874240447516058e-08, 8.285470443070153e-08), (-0.39999961853027344, 0.7660449147224426, 0.6427879333496094), (0.3562471270561218, 0.6159579753875732, 0.5168500542640686), (-0.35624682903289795, 0.6159582138061523, 0.5168502926826477), (0.20492683351039886, 0.09688037633895874, 0.0812922865152359), (-0.20492687821388245, 0.0968804731965065, 0.08129236847162247)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (1, 6), (4, 6), (2, 7), (5, 7)] mesh = ob.data @@ -337,7 +337,7 @@ class Rig: mod.levels = 2 ob = create_widget(self.obj, foot) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data diff --git a/rigify/rigs/biped/limb_common.py b/rigify/rigs/biped/limb_common.py index 8cd5ad1c..eadd6374 100644 --- a/rigify/rigs/biped/limb_common.py +++ b/rigify/rigs/biped/limb_common.py @@ -48,7 +48,7 @@ class FKLimb: bpy.ops.object.mode_set(mode='EDIT') # Create non-scaling parent bone - if self.org_parent != None: + if self.org_parent is not None: loc = Vector(self.obj.data.edit_bones[self.org_bones[0]].head) parent = make_nonscaling_child(self.obj, self.org_parent, loc, "_fk") else: @@ -69,7 +69,7 @@ class FKLimb: eantistr = copy_bone(self.obj, self.org_bones[1], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[1], "_antistr.fk")))) # Create the hinge bones - if parent != None: + if parent is not None: socket1 = copy_bone(self.obj, ulimb, make_mechanism_name(ulimb + ".socket1")) socket2 = copy_bone(self.obj, ulimb, make_mechanism_name(ulimb + ".socket2")) @@ -85,7 +85,7 @@ class FKLimb: elimb_mch_e = eb[elimb_mch] - if parent != None: + if parent is not None: socket1_e = eb[socket1] socket2_e = eb[socket2] @@ -105,7 +105,7 @@ class FKLimb: fantistr_e.use_connect = False fantistr_e.parent = ulimb_e - if parent != None: + if parent is not None: socket1_e.use_connect = False socket1_e.parent = eb[parent] @@ -121,7 +121,7 @@ class FKLimb: eantistr_e.length /= 8 put_bone(self.obj, eantistr, Vector(flimb_e.tail)) - if parent != None: + if parent is not None: socket1_e.length /= 4 socket2_e.length /= 3 @@ -136,7 +136,7 @@ class FKLimb: fantistr_p = pb[fantistr] eantistr_p = pb[eantistr] - if parent != None: + if parent is not None: socket2_p = pb[socket2] # Lock axes @@ -154,7 +154,7 @@ class FKLimb: flimb_p.lock_rotation = (True, True, False) # Set up custom properties - if parent != None: + if parent is not None: prop = rna_idprop_ui_prop_get(ulimb_p, "isolate", create=True) ulimb_p["isolate"] = 0.0 prop["soft_min"] = prop["min"] = 0.0 @@ -230,7 +230,7 @@ class FKLimb: add_antistretch_drivers(eantistr_p) # Hinge constraints / drivers - if parent != None: + if parent is not None: con = socket2_p.constraints.new('COPY_LOCATION') con.name = "copy_location" con.target = self.obj @@ -282,7 +282,7 @@ class FKLimb: create_limb_widget(self.obj, flimb) ob = create_widget(self.obj, elimb) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data @@ -324,10 +324,10 @@ class IKLimb: bpy.ops.object.mode_set(mode='EDIT') # Create non-scaling parent bone - if self.org_parent != None: + if self.org_parent is not None: loc = Vector(self.obj.data.edit_bones[self.org_bones[0]].head) parent = make_nonscaling_child(self.obj, self.org_parent, loc, "_ik") - if self.pole_parent == None: + if self.pole_parent is None: self.pole_parent = parent else: parent = None @@ -348,7 +348,7 @@ class IKLimb: pole = copy_bone(self.obj, self.org_bones[0], pole_target_name) if self.pole_parent == self.org_bones[2]: self.pole_parent = elimb_mch - if self.pole_parent != None: + if self.pole_parent is not None: pole_par = copy_bone(self.obj, self.pole_parent, make_mechanism_name(insert_before_lr(pole_target_name, "_parent"))) viselimb = copy_bone(self.obj, self.org_bones[2], "VIS-" + strip_org(insert_before_lr(self.org_bones[2], ".ik"))) @@ -357,7 +357,7 @@ class IKLimb: # Get edit bones eb = self.obj.data.edit_bones - if parent != None: + if parent is not None: parent_e = eb[parent] ulimb_e = eb[ulimb] flimb_e = eb[flimb] @@ -368,7 +368,7 @@ class IKLimb: ulimb_str_e = eb[ulimb_str] flimb_str_e = eb[flimb_str] pole_e = eb[pole] - if self.pole_parent != None: + if self.pole_parent is not None: pole_par_e = eb[pole_par] viselimb_e = eb[viselimb] vispole_e = eb[vispole] @@ -376,7 +376,7 @@ class IKLimb: # Parenting ulimb_e.use_connect = False ulimb_nostr_e.use_connect = False - if parent != None: + if parent is not None: ulimb_e.parent = parent_e ulimb_nostr_e.parent = parent_e @@ -396,7 +396,7 @@ class IKLimb: flimb_str_e.parent = ulimb_e.parent pole_e.use_connect = False - if self.pole_parent != None: + if self.pole_parent is not None: pole_par_e.parent = None pole_e.parent = pole_par_e @@ -431,7 +431,7 @@ class IKLimb: pole_e.head = flimb_e.head + v2 pole_e.tail = pole_e.head + (Vector((0, 1, 0)) * (v1.length / 8)) pole_e.roll = 0.0 - if parent != None: + if parent is not None: pole_par_e.length *= 0.75 viselimb_e.tail = viselimb_e.head + Vector((0, 0, v1.length / 32)) @@ -455,7 +455,7 @@ class IKLimb: ulimb_str_p = pb[ulimb_str] flimb_str_p = pb[flimb_str] pole_p = pb[pole] - if self.pole_parent != None: + if self.pole_parent is not None: pole_par_p = pb[pole_par] viselimb_p = pb[viselimb] vispole_p = pb[vispole] @@ -506,7 +506,7 @@ class IKLimb: prop["soft_min"] = prop["min"] = 0.0 prop["soft_max"] = prop["max"] = 1.0 - if self.pole_parent != None: + if self.pole_parent is not None: prop = rna_idprop_ui_prop_get(pole_p, "follow", create=True) pole_p["follow"] = 1.0 prop["soft_min"] = prop["min"] = 0.0 @@ -642,7 +642,7 @@ class IKLimb: con.owner_space = 'LOCAL' # Pole target parent - if self.pole_parent != None: + if self.pole_parent is not None: con = pole_par_p.constraints.new('COPY_TRANSFORMS') con.name = "parent" con.target = self.obj @@ -741,7 +741,7 @@ class IKLimb: create_sphere_widget(self.obj, pole) ob = create_widget(self.obj, elimb) - if ob != None: + if ob is not None: verts = [(0.7, 1.5, 0.0), (0.7, -0.25, 0.0), (-0.7, -0.25, 0.0), (-0.7, 1.5, 0.0), (0.7, 0.723, 0.0), (-0.7, 0.723, 0.0), (0.7, 0.0, 0.0), (-0.7, 0.0, 0.0)] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7)] mesh = ob.data @@ -777,7 +777,7 @@ class RubberHoseLimb: bpy.ops.object.mode_set(mode='EDIT') # Create non-scaling parent bone - if self.org_parent != None: + if self.org_parent is not None: loc = Vector(self.obj.data.edit_bones[self.org_bones[0]].head) parent = make_nonscaling_child(self.obj, self.org_parent, loc, "_rh") else: @@ -805,7 +805,7 @@ class RubberHoseLimb: flimb_e.parent = ulimb_e flimb_e.use_connect = True - if parent != None: + if parent is not None: elimb_e.use_connect = False ulimb_e.parent = eb[parent] @@ -877,7 +877,7 @@ class RubberHoseLimb: # Get edit bones eb = self.obj.data.edit_bones - if parent != None: + if parent is not None: parent_e = eb[parent] else: parent_e = None @@ -907,7 +907,7 @@ class RubberHoseLimb: fhoseend_par_e = eb[fhoseend_par] # Parenting - if parent != None: + if parent is not None: ulimb1_e.use_connect = False ulimb1_e.parent = parent_e diff --git a/rigify/rigs/finger.py b/rigify/rigs/finger.py index d33dd09f..70bbc112 100644 --- a/rigify/rigs/finger.py +++ b/rigify/rigs/finger.py @@ -252,7 +252,7 @@ class Rig: # Create control widgets w = create_widget(self.obj, ctrl) - if w != None: + if w is not None: mesh = w.data verts = [(0, 0, 0), (0, 1, 0), (0.05, 1, 0), (0.05, 1.1, 0), (-0.05, 1.1, 0), (-0.05, 1, 0)] if 'Z' in self.primary_rotation_axis: diff --git a/rigify/rigs/palm.py b/rigify/rigs/palm.py index f5568210..6bcaad11 100644 --- a/rigify/rigs/palm.py +++ b/rigify/rigs/palm.py @@ -146,7 +146,7 @@ class Rig: # Create control widget w = create_widget(self.obj, ctrl) - if w != None: + if w is not None: mesh = w.data verts = [(0.15780271589756012, 2.086162567138672e-07, -0.30000004172325134), (0.15780259668827057, 1.0, -0.2000001072883606), (-0.15780280530452728, 0.9999999403953552, -0.20000004768371582), (-0.15780259668827057, -2.086162567138672e-07, -0.29999998211860657), (-0.15780256688594818, -2.7089754439657554e-07, 0.30000004172325134), (-0.1578027755022049, 0.9999998807907104, 0.19999995827674866), (0.15780262649059296, 0.9999999403953552, 0.19999989867210388), (0.1578027456998825, 1.4633496903115883e-07, 0.29999998211860657), (0.15780268609523773, 0.2500001788139343, -0.27500003576278687), (-0.15780264139175415, 0.24999985098838806, -0.2749999761581421), (0.15780262649059296, 0.7500000596046448, -0.22500008344650269), (-0.1578027606010437, 0.7499998807907104, -0.2250000238418579), (0.15780265629291534, 0.75, 0.22499991953372955), (0.15780271589756012, 0.2500000596046448, 0.2749999761581421), (-0.15780261158943176, 0.2499997615814209, 0.27500003576278687), (-0.1578027307987213, 0.7499998807907104, 0.22499997913837433)] if 'Z' in self.palm_rotation_axis: diff --git a/rigify/rigs/pitchipoy/super_finger.py b/rigify/rigs/pitchipoy/super_finger.py index 3b39c770..86733921 100644 --- a/rigify/rigs/pitchipoy/super_finger.py +++ b/rigify/rigs/pitchipoy/super_finger.py @@ -280,7 +280,7 @@ class Rig: # Create ctrl master widget w = create_widget(self.obj, master_name) - if w != None: + if w is not None: mesh = w.data verts = [(0, 0, 0), (0, 1, 0), (0.05, 1, 0), (0.05, 1.1, 0), (-0.05, 1.1, 0), (-0.05, 1, 0)] if 'Z' in self.params.primary_rotation_axis: diff --git a/rigify/utils.py b/rigify/utils.py index c4d14d94..1531403f 100644 --- a/rigify/utils.py +++ b/rigify/utils.py @@ -392,7 +392,7 @@ def create_circle_polygon(number_verts, axis, radius=1.0, head_tail=0.0): def create_widget(rig, bone_name, bone_transform_name=None): """ Creates an empty widget object for a bone, and returns the object. """ - if bone_transform_name == None: + if bone_transform_name is None: bone_transform_name = bone_name obj_name = WGT_PREFIX + bone_name -- cgit v1.2.3