Skip to content

Commit

Permalink
use identity comparison with None (as suggested by python)
Browse files Browse the repository at this point in the history
  • Loading branch information
ideasman42 committed Mar 29, 2011
1 parent 0fcd203 commit 1d83845
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 47 deletions.
6 changes: 3 additions & 3 deletions io_convert_image_to_mesh_img/import_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def parsePDSLabel(self, labelIter, currentObjectName=None, level = ""):

# When are we done with this level?
endStr = "END"
if not currentObjectName == None:
if not currentObjectName is None:
endStr = "END_OBJECT = %s" % currentObjectName
line = ""

Expand Down Expand Up @@ -408,9 +408,9 @@ def cropXY(self, image_iter, XSize=None, YSize=None, XOffset=0, YOffset=0):
# dimensions shrink as we remove pixels
processed_dims = img_props.processed_dims()

if XSize == None:
if XSize is None:
XSize = processed_dims[0]
if YSize == None:
if YSize is None:
YSize = processed_dims[1]

if XSize + XOffset > processed_dims[0]:
Expand Down
18 changes: 9 additions & 9 deletions io_import_scene_mhx.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def parseDefaultType(typ, args, tokens):
bpyType = typ.capitalize()
print(bpyType, name, data)
loadedData[bpyType][name] = data
if data == None:
if data is None:
return None

for (key, val, sub) in tokens:
Expand Down Expand Up @@ -572,7 +572,7 @@ def parseAction(args, tokens):

act = ob.animation_data.action
loadedData['Action'][name] = act
if act == None:
if act is None:
print("Ignoring action %s" % name)
return act
act.name = name
Expand Down Expand Up @@ -691,7 +691,7 @@ def parseAnimationData(rna, args, tokens):
if not eval(args[1]):
return
print("Parse Animation data")
if rna.animation_data == None:
if rna.animation_data is None:
rna.animation_data_create()
adata = rna.animation_data
for (key, val, sub) in tokens:
Expand Down Expand Up @@ -813,7 +813,7 @@ def parseMaterial(args, tokens):
global todo
name = args[0]
mat = bpy.data.materials.new(name)
if mat == None:
if mat is None:
return None
loadedData['Material'][name] = mat
for (key, val, sub) in tokens:
Expand Down Expand Up @@ -1030,7 +1030,7 @@ def parseImage(args, tokens):
for n in range(1,len(val)):
filename += " " + val[n]
img = loadImage(filename)
if img == None:
if img is None:
return None
img.name = imgName
else:
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def parseObject(args, tokens):
except:
ob = None

if ob == None:
if ob is None:
print("Create", name, data, datName)
ob = createObject(typ, name, data, datName)
print("created", ob)
Expand Down Expand Up @@ -1113,7 +1113,7 @@ def createObject(typ, name, data, datName):

def linkObject(ob, data):
#print("Data", data, ob.data)
if data and ob.data == None:
if data and ob.data is None:
ob.data = data
print("Data linked", ob, ob.data)
scn = bpy.context.scene
Expand Down Expand Up @@ -2174,7 +2174,7 @@ def parseProcess(args, tokens):
eb = None
tb = ebones[val[1]]
typ = val[2]
if eb == None:
if eb is None:
pass
elif typ == 'Inv':
eb.head = tb.tail
Expand Down Expand Up @@ -2309,7 +2309,7 @@ def defaultKey(ext, args, tokens, var, exclude, glbals, lcals):
data = None
# print("Old structrna", nvar, data)

if data == None:
if data is None:
try:
creator = args[3]
except:
Expand Down
4 changes: 2 additions & 2 deletions io_scene_fbx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def execute(self, context):
keywords = self.as_keywords(ignore=("TX_XROT90", "TX_YROT90", "TX_ZROT90", "TX_SCALE", "check_existing", "filter_glob"))
keywords["GLOBAL_MATRIX"] = GLOBAL_MATRIX

import io_scene_fbx.export_fbx
return io_scene_fbx.export_fbx.save(self, context, **keywords)
from . import export_fbx
return export_fbx.save(self, context, **keywords)


def menu_func(self, context):
Expand Down
30 changes: 15 additions & 15 deletions io_scene_x3d/import_x3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def setRoot(self, filename):
self.PROTO_NAMESPACE = {}

def isRoot(self):
if self.filename == None:
if self.filename is None:
return False
else:
return True
Expand Down Expand Up @@ -518,7 +518,7 @@ def getSerialized(self, results, ancestry):
# where the parent of this object is not the real parent
# - In this case we have added the proto as a child to a node instancing it.
# This is a bit arbitary, but its how Proto's are done with this importer.
if child.getProtoName() == None and child.getExternprotoName() == None:
if child.getProtoName() is None and child.getExternprotoName() is None:
child.getSerialized(results, ancestry)
else:

Expand Down Expand Up @@ -624,7 +624,7 @@ def getFieldAsInt(self, field, default, ancestry):
self_real = self.getRealNode() # incase we're an instance

f = self_real.getFieldName(field, ancestry)
if f == None:
if f is None:
return default
if ',' in f:
f = f[:f.index(',')] # strip after the comma
Expand All @@ -643,7 +643,7 @@ def getFieldAsFloat(self, field, default, ancestry):
self_real = self.getRealNode() # incase we're an instance

f = self_real.getFieldName(field, ancestry)
if f == None:
if f is None:
return default
if ',' in f:
f = f[:f.index(',')] # strip after the comma
Expand All @@ -662,7 +662,7 @@ def getFieldAsFloatTuple(self, field, default, ancestry):
self_real = self.getRealNode() # incase we're an instance

f = self_real.getFieldName(field, ancestry)
if f == None:
if f is None:
return default
# if ',' in f: f = f[:f.index(',')] # strip after the comma

Expand All @@ -689,7 +689,7 @@ def getFieldAsBool(self, field, default, ancestry):
self_real = self.getRealNode() # incase we're an instance

f = self_real.getFieldName(field, ancestry)
if f == None:
if f is None:
return default
if ',' in f:
f = f[:f.index(',')] # strip after the comma
Expand All @@ -710,7 +710,7 @@ def getFieldAsString(self, field, default, ancestry):
self_real = self.getRealNode() # incase we're an instance

f = self_real.getFieldName(field, ancestry)
if f == None:
if f is None:
return default
if len(f) < 1:
print('\t"%s" wrong length for string conversion for field "%s"' % (f, field))
Expand Down Expand Up @@ -763,7 +763,7 @@ def array_as_number(array_string):
if not data_split:
return []
array_data = ' '.join(data_split)
if array_data == None:
if array_data is None:
return []

array_data = array_data.replace(',', ' ')
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def __parse(self, i, IS_PROTO_DATA=False):
except:
pass

if values == None: # dont parse
if values is None: # dont parse
values = l_split

# This should not extend over multiple lines however it is possible
Expand Down Expand Up @@ -1250,7 +1250,7 @@ def gzipOpen(path):
else:
print('\tNote, gzip module could not be imported, compressed files will fail to load')

if data == None:
if data is None:
try:
data = open(path, 'rU').read()
except:
Expand All @@ -1266,7 +1266,7 @@ def vrml_parse(path):
'''
data = gzipOpen(path)

if data == None:
if data is None:
return None, 'Failed to open file: ' + path

# Stripped above
Expand Down Expand Up @@ -1393,7 +1393,7 @@ def x3d_parse(path):
# Could add a try/except here, but a console error is more useful.
data = gzipOpen(path)

if data == None:
if data is None:
return None, 'Failed to open file: ' + path

doc = xml.dom.minidom.parseString(data)
Expand Down Expand Up @@ -2111,13 +2111,13 @@ def importShape(node, ancestry):
if ima:
ima_url = ima.getFieldAsString('url', None, ancestry)

if ima_url == None:
if ima_url is None:
try:
ima_url = ima.getFieldAsStringArray('url', ancestry)[0] # in some cases we get a list of images.
except:
ima_url = None

if ima_url == None:
if ima_url is None:
print("\twarning, image with no URL, this is odd")
else:
bpyima = image_utils.image_load(ima_url, dirName(node.getFilename()), place_holder=False, recursive=False, convert_callback=imageConvertCompat)
Expand Down Expand Up @@ -2604,7 +2604,7 @@ def load_web3d(path, PREF_FLAT=False, PREF_CIRCLE_DIV=16, HELPER_FUNC=None):

# Assign anim curves
node = defDict[key]
if node.blendObject == None: # Add an object if we need one for animation
if node.blendObject is None: # Add an object if we need one for animation
node.blendObject = bpy.data.objects.new('AnimOb', None) # , name)
bpy.context.scene.objects.link(node.blendObject)

Expand Down
2 changes: 1 addition & 1 deletion light_field_tools/light_field_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def addMeshObj(self, mesh):
scene.objects.link(nobj)
nobj.select = True

if scene.objects.active == None or scene.objects.active.mode == 'OBJECT':
if scene.objects.active is None or scene.objects.active.mode == 'OBJECT':
scene.objects.active = nobj


Expand Down
2 changes: 1 addition & 1 deletion object_animrenderbake.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def invoke(self, context, event):
img = uvdata.image
break

if img == None:
if img is None:
self.report({'ERROR'}, "No valid image found to bake to")
return {'CANCELLED'}

Expand Down
3 changes: 1 addition & 2 deletions rigify/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def generate_rig(context, metarig):
# Parent any free-floating bones to the root.
bpy.ops.object.mode_set(mode='EDIT')
for bone in bones:
if obj.data.edit_bones[bone].parent == None:
if obj.data.edit_bones[bone].parent is None:
obj.data.edit_bones[bone].use_connect = False
obj.data.edit_bones[bone].parent = obj.data.edit_bones[root_bone]
bpy.ops.object.mode_set(mode='OBJECT')
Expand Down Expand Up @@ -351,4 +351,3 @@ def param_name(param_name, rig_type):
""" Get the actual parameter name, sans-rig-type.
"""
return param_name[len(rig_type) + 1:]

2 changes: 1 addition & 1 deletion rigify/rigs/biped/arm/fk.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, obj, bone, params):
raise MetarigError("RIGIFY ERROR: Bone '%s': input to rig type must be a chain of 3 bones." % (strip_org(bone)))

# Get (optional) parent
if self.obj.data.bones[bone].parent == None:
if self.obj.data.bones[bone].parent is None:
self.org_parent = None
else:
self.org_parent = self.obj.data.bones[bone].parent.name
Expand Down
5 changes: 2 additions & 3 deletions rigify/rigs/biped/leg/deform.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, obj, bone, params):
else:
heel = b.name

if foot == None or heel == None:
if foot is None or heel is None:
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

# Get the toe
Expand All @@ -108,7 +108,7 @@ def __init__(self, obj, bone, params):
if b.use_connect == True:
toe = b.name

if toe == None:
if toe is None:
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

self.org_bones = leg_bones + [foot, toe, heel]
Expand Down Expand Up @@ -261,4 +261,3 @@ def generate(self):
con.name = "track_to"
con.target = self.obj
con.subtarget = stip

6 changes: 3 additions & 3 deletions rigify/rigs/biped/leg/fk.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, obj, bone, params):
else:
heel = b.name

if foot == None or heel == None:
if foot is None or heel is None:
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

# Get the toe
Expand All @@ -69,13 +69,13 @@ def __init__(self, obj, bone, params):
toe = b.name

# Get the toe
if toe == None:
if toe is None:
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

self.org_bones = leg_bones + [foot, toe, heel]

# Get (optional) parent
if self.obj.data.bones[bone].parent == None:
if self.obj.data.bones[bone].parent is None:
self.org_parent = None
else:
self.org_parent = self.obj.data.bones[bone].parent.name
Expand Down
4 changes: 2 additions & 2 deletions rigify/rigs/biped/leg/ik.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, obj, bone, params, ikfk_switch=False):
if len(b.children) > 0:
rocker = b.children[0].name

if foot == None or heel == None:
if foot is None or heel is None:
print("blah")
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

Expand All @@ -123,7 +123,7 @@ def __init__(self, obj, bone, params, ikfk_switch=False):
toe = b.name

# Get toe
if toe == None:
if toe is None:
raise MetarigError("RIGIFY ERROR: Bone '%s': incorrect bone configuration for rig type." % (strip_org(bone)))

self.org_bones = leg_bones + [foot, toe, heel, rocker]
Expand Down
2 changes: 1 addition & 1 deletion rigify/rigs/misc/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, obj, bone, params):
"""
bb = obj.data.bones

if bb[bone].children == None:
if bb[bone].children is None:
raise MetarigError("RIGIFY ERROR: bone '%s': rig type requires one child." % org_name(bone.name))
if bb[bone].use_connect == True:
raise MetarigError("RIGIFY ERROR: bone '%s': rig type cannot be connected to parent." % org_name(bone.name))
Expand Down
2 changes: 1 addition & 1 deletion rigify/rigs/palm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def bone_siblings(obj, bone):
"""
parent = obj.data.bones[bone].parent

if parent == None:
if parent is None:
return []

bones = []
Expand Down
6 changes: 3 additions & 3 deletions rigify/rigs/spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def gen_control(self):
# Parenting
bone_e.use_connect = False
helper_e.use_connect = False
if prev_bone == None:
if prev_bone is None:
helper_e.parent = eb[hip_control]
bone_e.parent = helper_e

Expand Down Expand Up @@ -314,7 +314,7 @@ def gen_control(self):
flip_bone(self.obj, bone)
bone_e.tail = Vector(eb[b[0]].head)
#bone_e.head = Vector(eb[b[0]].tail)
if prev_bone == None:
if prev_bone is None:
pass # Position base bone wherever you want, for now do nothing (i.e. position at hips)
else:
put_bone(self.obj, bone, eb[prev_bone].tail)
Expand All @@ -331,7 +331,7 @@ def gen_control(self):
con = bone_p.constraints.new('COPY_LOCATION')
con.name = "copy_location"
con.target = self.obj
if prev_bone == None:
if prev_bone is None:
con.subtarget = hip_control # Position base bone wherever you want, for now hips
else:
con.subtarget = prev_bone
Expand Down

0 comments on commit 1d83845

Please sign in to comment.