Skip to content

Commit

Permalink
Consistent use of identity comparison (is/is not) for None
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtopus committed Dec 19, 2013
1 parent dcf3cbd commit 125a839
Show file tree
Hide file tree
Showing 43 changed files with 122 additions and 120 deletions.
12 changes: 6 additions & 6 deletions boto/cloudfront/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@ def update(self, enabled=None, cnames=None, comment=None):
self.config.cnames, self.config.comment,
self.config.trusted_signers,
self.config.default_root_object)
if enabled != None:
if enabled is not None:
new_config.enabled = enabled
if cnames != None:
if cnames is not None:
new_config.cnames = cnames
if comment != None:
if comment is not None:
new_config.comment = comment
self.etag = self.connection.set_distribution_config(self.id, self.etag, new_config)
self.config = new_config
Expand Down Expand Up @@ -729,11 +729,11 @@ def update(self, enabled=None, cnames=None, comment=None):
self.config.cnames,
self.config.comment,
self.config.trusted_signers)
if enabled != None:
if enabled is not None:
new_config.enabled = enabled
if cnames != None:
if cnames is not None:
new_config.cnames = cnames
if comment != None:
if comment is not None:
new_config.comment = comment
self.etag = self.connection.set_streaming_distribution_config(self.id,
self.etag,
Expand Down
2 changes: 1 addition & 1 deletion boto/cloudfront/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def update(self, comment=None):
new_config = OriginAccessIdentityConfig(self.connection,
self.config.caller_reference,
self.config.comment)
if comment != None:
if comment is not None:
new_config.comment = comment
self.etag = self.connection.set_origin_identity_config(self.id, self.etag, new_config)
self.config = new_config
Expand Down
2 changes: 1 addition & 1 deletion boto/cloudfront/invalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def escape(self, p):

def to_xml(self):
"""Get this batch as XML"""
assert self.connection != None
assert self.connection is not None
s = '<?xml version="1.0" encoding="UTF-8"?>\n'
s += '<InvalidationBatch xmlns="http://cloudfront.amazonaws.com/doc/%s/">\n' % self.connection.Version
for p in self.paths:
Expand Down
2 changes: 1 addition & 1 deletion boto/cloudsearch/layer1.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_response(self, doc_path, action, params, path='/',
for p in doc_path:
inner = inner.get(p)
if not inner:
return None if list_marker == None else []
return None if list_marker is None else []
if isinstance(inner, list):
return inner
else:
Expand Down
6 changes: 3 additions & 3 deletions boto/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def handle_proxy(self, proxy, proxy_port, proxy_user, proxy_pass):
self.proxy_port = self.port

self.no_proxy = os.environ.get('no_proxy', '') or os.environ.get('NO_PROXY', '')
self.use_proxy = (self.proxy != None)
self.use_proxy = (self.proxy is not None)

def get_http_connection(self, host, port, is_secure):
conn = self._pool.get_http_connection(host, port, is_secure)
Expand Down Expand Up @@ -982,11 +982,11 @@ def build_base_http_request(self, method, path, auth_path,
path = self.get_path(path)
if auth_path is not None:
auth_path = self.get_path(auth_path)
if params == None:
if params is None:
params = {}
else:
params = params.copy()
if headers == None:
if headers is None:
headers = {}
else:
headers = headers.copy()
Expand Down
2 changes: 1 addition & 1 deletion boto/core/dictresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, root_node, connection):
def startElement(self, name, attrs):
self.current_text = ''
t = self.nodes[-1][1].startElement(name, attrs, self.connection)
if t != None:
if t is not None:
if isinstance(t, tuple):
self.nodes.append(t)
else:
Expand Down
6 changes: 3 additions & 3 deletions boto/dynamodb/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def __init__(self, table, hash_key=None, range_key=None, attrs=None):
self._updates = None
self._hash_key_name = self.table.schema.hash_key_name
self._range_key_name = self.table.schema.range_key_name
if attrs == None:
if attrs is None:
attrs = {}
if hash_key == None:
if hash_key is None:
hash_key = attrs.get(self._hash_key_name, None)
self[self._hash_key_name] = hash_key
if self._range_key_name:
if range_key == None:
if range_key is None:
range_key = attrs.get(self._range_key_name, None)
self[self._range_key_name] = range_key
self._updates = {}
Expand Down
4 changes: 2 additions & 2 deletions boto/ec2/cloudwatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def aslist(a):
metric_data['StatisticValues.Minimum'] = s['minimum']
metric_data['StatisticValues.SampleCount'] = s['samplecount']
metric_data['StatisticValues.Sum'] = s['sum']
if value != None:
if value is not None:
msg = 'You supplied a value and statistics for a ' + \
'metric.Posting statistics and not value.'
boto.log.warn(msg)
elif value != None:
elif value is not None:
metric_data['Value'] = v
else:
raise Exception('Must specify a value or statistics to put.')
Expand Down
2 changes: 1 addition & 1 deletion boto/ec2/elb/loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def create_listeners(self, listeners):
listeners)

def create_listener(self, inPort, outPort=None, proto="tcp"):
if outPort == None:
if outPort is None:
outPort = inPort
return self.create_listeners([(inPort, outPort, proto)])

Expand Down
2 changes: 1 addition & 1 deletion boto/ecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_response(self, action, params, page=0, itemSet=None):
boto.log.error('%s' % body)
raise self.ResponseError(response.status, response.reason, body)

if itemSet == None:
if itemSet is None:
rs = ItemSet(self, action, params, page)
else:
rs = itemSet
Expand Down
6 changes: 3 additions & 3 deletions boto/ecs/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(self, connection, action, params, page=0):
def startElement(self, name, attrs, connection):
if name == "Item":
self.curItem = Item(self._connection)
elif self.curItem != None:
elif self.curItem is not None:
self.curItem.startElement(name, attrs, connection)
return None

Expand All @@ -123,13 +123,13 @@ def endElement(self, name, value, connection):
self.objs.append(self.curItem)
self._xml.write(self.curItem.to_xml())
self.curItem = None
elif self.curItem != None:
elif self.curItem is not None:
self.curItem.endElement(name, value, connection)
return None

def next(self):
"""Special paging functionality"""
if self.iter == None:
if self.iter is None:
self.iter = iter(self.objs)
try:
return self.iter.next()
Expand Down
18 changes: 9 additions & 9 deletions boto/gs/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def get_contents_to_file(self, fp, headers=None,
with the stored object in the response. See
http://goo.gl/sMkcC for details.
"""
if self.bucket != None:
if self.bucket is not None:
if res_download_handler:
res_download_handler.get_file(self, fp, headers, cb, num_cb,
torrent=torrent,
Expand Down Expand Up @@ -528,7 +528,7 @@ def set_contents_from_file(self, fp, headers=None, replace=True,

if hasattr(fp, 'name'):
self.path = fp.name
if self.bucket != None:
if self.bucket is not None:
if isinstance(fp, KeyFile):
# Avoid EOF seek for KeyFile case as it's very inefficient.
key = fp.getkey()
Expand All @@ -552,12 +552,12 @@ def set_contents_from_file(self, fp, headers=None, replace=True,
fp.seek(spos)
size = self.size

if md5 == None:
if md5 is None:
md5 = self.compute_md5(fp, size)
self.md5 = md5[0]
self.base64md5 = md5[1]

if self.name == None:
if self.name is None:
self.name = self.md5

if not replace:
Expand Down Expand Up @@ -792,7 +792,7 @@ def set_acl(self, acl_or_str, headers=None, generation=None,
the acl will only be updated if its current metageneration number is
this value.
"""
if self.bucket != None:
if self.bucket is not None:
self.bucket.set_acl(acl_or_str, self.name, headers=headers,
generation=generation,
if_generation=if_generation,
Expand All @@ -809,7 +809,7 @@ def get_acl(self, headers=None, generation=None):
:rtype: :class:`.gs.acl.ACL`
"""
if self.bucket != None:
if self.bucket is not None:
return self.bucket.get_acl(self.name, headers=headers,
generation=generation)

Expand All @@ -824,7 +824,7 @@ def get_xml_acl(self, headers=None, generation=None):
:rtype: str
"""
if self.bucket != None:
if self.bucket is not None:
return self.bucket.get_xml_acl(self.name, headers=headers,
generation=generation)

Expand Down Expand Up @@ -852,7 +852,7 @@ def set_xml_acl(self, acl_str, headers=None, generation=None,
the acl will only be updated if its current metageneration number is
this value.
"""
if self.bucket != None:
if self.bucket is not None:
return self.bucket.set_xml_acl(acl_str, self.name, headers=headers,
generation=generation,
if_generation=if_generation,
Expand Down Expand Up @@ -883,7 +883,7 @@ def set_canned_acl(self, acl_str, headers=None, generation=None,
the acl will only be updated if its current metageneration number is
this value.
"""
if self.bucket != None:
if self.bucket is not None:
return self.bucket.set_canned_acl(
acl_str,
self.name,
Expand Down
4 changes: 2 additions & 2 deletions boto/gs/resumable_upload_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def _load_tracker_uri_from_file(self):
# Ignore non-existent file (happens first time an upload
# is attempted on a file), but warn user for other errors.
if e.errno != errno.ENOENT:
# Will restart because self.tracker_uri == None.
# Will restart because self.tracker_uri is None.
print('Couldn\'t read URI tracker file (%s): %s. Restarting '
'upload from scratch.' %
(self.tracker_file_name, e.strerror))
except InvalidUriError, e:
# Warn user, but proceed (will restart because
# self.tracker_uri == None).
# self.tracker_uri is None).
print('Invalid tracker URI (%s) found in URI tracker file '
'(%s). Restarting upload from scratch.' %
(uri, self.tracker_file_name))
Expand Down
2 changes: 1 addition & 1 deletion boto/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, root_node, connection):
def startElement(self, name, attrs):
self.current_text = ''
new_node = self.nodes[-1][1].startElement(name, attrs, self.connection)
if new_node != None:
if new_node is not None:
self.nodes.append((name, new_node))

def endElement(self, name):
Expand Down
2 changes: 1 addition & 1 deletion boto/jsonresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, root_node, connection):
def startElement(self, name, attrs):
self.current_text = ''
t = self.nodes[-1][1].startElement(name, attrs, self.connection)
if t != None:
if t is not None:
if isinstance(t, tuple):
self.nodes.append(t)
else:
Expand Down
2 changes: 1 addition & 1 deletion boto/manage/cmdshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def run(self):
log_fp = StringIO.StringIO()
process = subprocess.Popen(self.command, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while process.poll() == None:
while process.poll() is None:
time.sleep(1)
t = process.communicate()
log_fp.write(t[0])
Expand Down
4 changes: 2 additions & 2 deletions boto/manage/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def create(cls, config_file=None, logical_volume = None, cfg = None, **params):
group = params.get('group')
zone = params.get('zone')
# deal with possibly passed in logical volume:
if logical_volume != None:
if logical_volume is not None:
cfg.set('EBS', 'logical_volume_name', logical_volume.name)
cfg_fp = StringIO.StringIO()
cfg.write(cfg_fp)
Expand All @@ -323,7 +323,7 @@ def create(cls, config_file=None, logical_volume = None, cfg = None, **params):
i = 0
elastic_ip = params.get('elastic_ip')
instances = reservation.instances
if elastic_ip != None and instances.__len__() > 0:
if elastic_ip is not None and instances.__len__() > 0:
instance = instances[0]
print 'Waiting for instance to start so we can set its elastic IP address...'
# Sometimes we get a message from ec2 that says that the instance does not exist.
Expand Down
2 changes: 1 addition & 1 deletion boto/manage/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _run(self, msg, vtimeout):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
nsecs = 5
current_timeout = vtimeout
while process.poll() == None:
while process.poll() is None:
boto.log.info('nsecs=%s, timeout=%s' % (nsecs, current_timeout))
if nsecs >= current_timeout:
current_timeout += vtimeout
Expand Down
16 changes: 8 additions & 8 deletions boto/manage/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def create_from_snapshot(self, name, snapshot, size=None):
if size < self.size:
size = self.size
ec2 = self.get_ec2_connection()
if self.zone_name == None or self.zone_name == '':
if self.zone_name is None or self.zone_name == '':
# deal with the migration case where the zone is not set in the logical volume:
current_volume = ec2.get_all_volumes([self.volume_id])[0]
self.zone_name = current_volume.zone
Expand All @@ -155,7 +155,7 @@ def create_from_snapshot(self, name, snapshot, size=None):
def get_ec2_connection(self):
if self.server:
return self.server.ec2
if not hasattr(self, 'ec2') or self.ec2 == None:
if not hasattr(self, 'ec2') or self.ec2 is None:
self.ec2 = boto.ec2.connect_to_region(self.region_name)
return self.ec2

Expand Down Expand Up @@ -209,7 +209,7 @@ def attach(self, server=None):

def detach(self, force=False):
state = self.attachment_state
if state == 'available' or state == None or state == 'detaching':
if state == 'available' or state is None or state == 'detaching':
print 'already detached'
return None
ec2 = self.get_ec2_connection()
Expand All @@ -218,7 +218,7 @@ def detach(self, force=False):
self.put()

def checkfs(self, use_cmd=None):
if self.server == None:
if self.server is None:
raise ValueError('server attribute must be set to run this command')
# detemine state of file system on volume, only works if attached
if use_cmd:
Expand All @@ -233,7 +233,7 @@ def checkfs(self, use_cmd=None):
return True

def wait(self):
if self.server == None:
if self.server is None:
raise ValueError('server attribute must be set to run this command')
with closing(self.server.get_cmdshell()) as cmd:
# wait for the volume device to appear
Expand All @@ -243,7 +243,7 @@ def wait(self):
time.sleep(10)

def format(self):
if self.server == None:
if self.server is None:
raise ValueError('server attribute must be set to run this command')
status = None
with closing(self.server.get_cmdshell()) as cmd:
Expand All @@ -253,7 +253,7 @@ def format(self):
return status

def mount(self):
if self.server == None:
if self.server is None:
raise ValueError('server attribute must be set to run this command')
boto.log.info('handle_mount_point')
with closing(self.server.get_cmdshell()) as cmd:
Expand Down Expand Up @@ -302,7 +302,7 @@ def snapshot(self):
# we need to freeze the XFS file system
try:
self.freeze()
if self.server == None:
if self.server is None:
snapshot = self.get_ec2_connection().create_snapshot(self.volume_id)
else:
snapshot = self.server.ec2.create_snapshot(self.volume_id)
Expand Down
2 changes: 1 addition & 1 deletion boto/mashups/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def display(self):
item.ami.id, item.groups, item.key.name)

def place(self, block=True):
if get_domain() == None:
if get_domain() is None:
print 'SDB Persistence Domain not set'
domain_name = self.get_string('Specify SDB Domain')
set_domain(domain_name)
Expand Down
Loading

0 comments on commit 125a839

Please sign in to comment.