Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1930 from oxtopus/consistent-identity-comparison-…

…none

Consistent use of identity comparison (`is`/`is not`) for None. Fixes #1930.
  • Loading branch information...
commit 8597c5426344e728dc081b5a924a437fe351a47b 2 parents 2555b8a + 6744439
@danielgtaylor danielgtaylor authored
Showing with 119 additions and 119 deletions.
  1. +6 −6 boto/cloudfront/distribution.py
  2. +1 −1  boto/cloudfront/identity.py
  3. +1 −1  boto/cloudfront/invalidation.py
  4. +1 −1  boto/cloudsearch/layer1.py
  5. +3 −3 boto/connection.py
  6. +1 −1  boto/core/dictresponse.py
  7. +3 −3 boto/dynamodb/item.py
  8. +2 −2 boto/ec2/cloudwatch/__init__.py
  9. +1 −1  boto/ec2/elb/loadbalancer.py
  10. +1 −1  boto/ecs/__init__.py
  11. +3 −3 boto/ecs/item.py
  12. +9 −9 boto/gs/key.py
  13. +2 −2 boto/gs/resumable_upload_handler.py
  14. +1 −1  boto/handler.py
  15. +1 −1  boto/jsonresponse.py
  16. +1 −1  boto/manage/cmdshell.py
  17. +1 −1  boto/manage/server.py
  18. +1 −1  boto/manage/task.py
  19. +8 −8 boto/manage/volume.py
  20. +1 −1  boto/mashups/order.py
  21. +1 −1  boto/mturk/layoutparam.py
  22. +1 −1  boto/mturk/qualification.py
  23. +1 −1  boto/pyami/config.py
  24. +1 −1  boto/pyami/installers/ubuntu/ebs.py
  25. +5 −5 boto/rds/__init__.py
  26. +1 −1  boto/rds/dbsubnetgroup.py
  27. +1 −1  boto/rds/parametergroup.py
  28. +7 −7 boto/route53/record.py
  29. +2 −2 boto/s3/connection.py
  30. +11 −11 boto/s3/key.py
  31. +1 −1  boto/s3/resumable_download_handler.py
  32. +1 −1  boto/sdb/connection.py
  33. +1 −1  boto/sdb/db/key.py
  34. +9 −9 boto/sdb/db/manager/sdbmanager.py
  35. +3 −3 boto/sdb/db/manager/xmlmanager.py
  36. +1 −1  boto/sdb/db/model.py
  37. +8 −8 boto/sdb/db/property.py
  38. +1 −1  boto/sdb/db/query.py
  39. +9 −9 boto/sdb/db/sequence.py
  40. +1 −1  boto/sdb/item.py
  41. +3 −3 boto/sdb/queryresultset.py
  42. +1 −1  boto/services/message.py
  43. +1 −1  boto/sqs/message.py
View
12 boto/cloudfront/distribution.py
@@ -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
@@ -730,11 +730,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,
View
2  boto/cloudfront/identity.py
@@ -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
View
2  boto/cloudfront/invalidation.py
@@ -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:
View
2  boto/cloudsearch/layer1.py
@@ -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:
View
6 boto/connection.py
@@ -684,7 +684,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)
@@ -986,11 +986,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()
View
2  boto/core/dictresponse.py
@@ -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:
View
6 boto/dynamodb/item.py
@@ -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 = {}
View
4 boto/ec2/cloudwatch/__init__.py
@@ -178,11 +178,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.')
View
2  boto/ec2/elb/loadbalancer.py
@@ -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)])
View
2  boto/ecs/__init__.py
@@ -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
View
6 boto/ecs/item.py
@@ -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
@@ -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()
View
18 boto/gs/key.py
@@ -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,
@@ -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()
@@ -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:
@@ -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,
@@ -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)
@@ -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)
@@ -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,
@@ -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,
View
4 boto/gs/resumable_upload_handler.py
@@ -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))
View
2  boto/handler.py
@@ -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):
View
2  boto/jsonresponse.py
@@ -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:
View
2  boto/manage/cmdshell.py
@@ -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])
View
2  boto/manage/server.py
@@ -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.
View
2  boto/manage/task.py
@@ -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
View
16 boto/manage/volume.py
@@ -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
@@ -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
@@ -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()
@@ -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:
@@ -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
@@ -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:
@@ -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:
@@ -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)
View
2  boto/mashups/order.py
@@ -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)
View
2  boto/mturk/layoutparam.py
@@ -22,7 +22,7 @@
class LayoutParameters(object):
def __init__(self, layoutParameters=None):
- if layoutParameters == None:
+ if layoutParameters is None:
layoutParameters = []
self.layoutParameters = layoutParameters
View
2  boto/mturk/qualification.py
@@ -22,7 +22,7 @@
class Qualifications(object):
def __init__(self, requirements=None):
- if requirements == None:
+ if requirements is None:
requirements = []
self.requirements = requirements
View
2  boto/pyami/config.py
@@ -223,7 +223,7 @@ def load_from_sdb(self, domain_name, item_name):
d = json.loads(item[section])
for attr_name in d.keys():
attr_value = d[attr_name]
- if attr_value == None:
+ if attr_value is None:
attr_value = 'None'
if isinstance(attr_value, bool):
self.setbool(section, attr_name, attr_value)
View
2  boto/pyami/installers/ubuntu/ebs.py
@@ -219,7 +219,7 @@ def install(self):
# Set up the backup cleanup script
minute = boto.config.get('EBS', 'backup_cleanup_cron_minute')
hour = boto.config.get('EBS', 'backup_cleanup_cron_hour')
- if (minute != None) and (hour != None):
+ if (minute is not None) and (hour is not None):
# Snapshot clean up can either be done via the manage module, or via the new tag based
# snapshot code, if the snapshots have been tagged with the name of the associated
# volume. Check for the presence of the new configuration flag, and use the appropriate
View
10 boto/rds/__init__.py
@@ -1384,11 +1384,11 @@ def get_all_db_subnet_groups(self, name=None, max_records=None, marker=None):
:return: A list of :class:`boto.rds.dbsubnetgroup.DBSubnetGroup`
"""
params = dict()
- if name != None:
+ if name is not None:
params['DBSubnetGroupName'] = name
- if max_records != None:
+ if max_records is not None:
params['MaxRecords'] = max_records
- if marker != None:
+ if marker is not None:
params['Marker'] = marker
return self.get_list('DescribeDBSubnetGroups', params, [('DBSubnetGroup',DBSubnetGroup)])
@@ -1407,9 +1407,9 @@ def modify_db_subnet_group(self, name, description=None, subnet_ids=None):
:return: The newly created ParameterGroup
"""
params = {'DBSubnetGroupName': name}
- if description != None:
+ if description is not None:
params['DBSubnetGroupDescription'] = description
- if subnet_ids != None:
+ if subnet_ids is not None:
self.build_list_params(params, subnet_ids, 'SubnetIds.member')
return self.get_object('ModifyDBSubnetGroup', params, DBSubnetGroup)
View
2  boto/rds/dbsubnetgroup.py
@@ -40,7 +40,7 @@ def __init__(self, connection=None, name=None, description=None, subnet_ids=None
self.connection = connection
self.name = name
self.description = description
- if subnet_ids != None:
+ if subnet_ids is not None:
self.subnet_ids = subnet_ids
else:
self.subnet_ids = []
View
2  boto/rds/parametergroup.py
@@ -175,7 +175,7 @@ def set_value(self, value):
raise TypeError('unknown type (%s)' % self.type)
def get_value(self):
- if self._value == None:
+ if self._value is None:
return self._value
if self.type == 'string':
return self._value
View
14 boto/route53/record.py
@@ -218,7 +218,7 @@ def __init__(self, name=None, type=None, ttl=600, resource_records=None,
self.name = name
self.type = type
self.ttl = ttl
- if resource_records == None:
+ if resource_records is None:
resource_records = []
self.resource_records = resource_records
self.alias_hosted_zone_id = alias_hosted_zone_id
@@ -241,7 +241,7 @@ def set_alias(self, alias_hosted_zone_id, alias_dns_name):
def to_xml(self):
"""Spit this resource record set out as XML"""
- if self.alias_hosted_zone_id != None and self.alias_dns_name != None:
+ if self.alias_hosted_zone_id is not None and self.alias_dns_name is not None:
# Use alias
body = self.AliasBody % (self.alias_hosted_zone_id, self.alias_dns_name)
else:
@@ -258,10 +258,10 @@ def to_xml(self):
weight = ""
- if self.identifier != None and self.weight != None:
+ if self.identifier is not None and self.weight is not None:
weight = self.WRRBody % {"identifier": self.identifier, "weight":
self.weight}
- elif self.identifier != None and self.region != None:
+ elif self.identifier is not None and self.region is not None:
weight = self.RRRBody % {"identifier": self.identifier, "region":
self.region}
@@ -275,16 +275,16 @@ def to_xml(self):
def to_print(self):
rr = ""
- if self.alias_hosted_zone_id != None and self.alias_dns_name != None:
+ if self.alias_hosted_zone_id is not None and self.alias_dns_name is not None:
# Show alias
rr = 'ALIAS ' + self.alias_hosted_zone_id + ' ' + self.alias_dns_name
else:
# Show resource record(s)
rr = ",".join(self.resource_records)
- if self.identifier != None and self.weight != None:
+ if self.identifier is not None and self.weight is not None:
rr += ' (WRR id=%s, w=%s)' % (self.identifier, self.weight)
- elif self.identifier != None and self.region != None:
+ elif self.identifier is not None and self.region is not None:
rr += ' (LBR id=%s, region=%s)' % (self.identifier, self.region)
return rr
View
4 boto/s3/connection.py
@@ -270,9 +270,9 @@ def build_post_form_args(self, bucket_name, key, expires_in=6000,
"""
- if fields == None:
+ if fields is None:
fields = []
- if conditions == None:
+ if conditions is None:
conditions = []
expiration = time.gmtime(int(time.time() + expires_in))
View
22 boto/s3/key.py
@@ -258,7 +258,7 @@ def open_read(self, headers=None, query_args='',
with the stored object in the response. See
http://goo.gl/EWOPb for details.
"""
- if self.resp == None:
+ if self.resp is None:
self.mode = 'r'
provider = self.bucket.connection.provider
@@ -538,19 +538,19 @@ def update_metadata(self, d):
# convenience methods for setting/getting ACL
def set_acl(self, acl_str, headers=None):
- if self.bucket != None:
+ if self.bucket is not None:
self.bucket.set_acl(acl_str, self.name, headers=headers)
def get_acl(self, headers=None):
- if self.bucket != None:
+ if self.bucket is not None:
return self.bucket.get_acl(self.name, headers=headers)
def get_xml_acl(self, headers=None):
- if self.bucket != None:
+ if self.bucket is not None:
return self.bucket.get_xml_acl(self.name, headers=headers)
def set_xml_acl(self, acl_str, headers=None):
- if self.bucket != None:
+ if self.bucket is not None:
return self.bucket.set_xml_acl(acl_str, self.name, headers=headers)
def set_canned_acl(self, acl_str, headers=None):
@@ -882,7 +882,7 @@ def sender(http_conn, method, path, data, headers):
'Content-Type', headers)
elif self.path:
self.content_type = mimetypes.guess_type(self.path)[0]
- if self.content_type == None:
+ if self.content_type is None:
self.content_type = self.DefaultContentType
headers['Content-Type'] = self.content_type
else:
@@ -1060,7 +1060,7 @@ class of the new Key to be REDUCED_REDUNDANCY. The Reduced
if provider.storage_class_header:
headers[provider.storage_class_header] = self.storage_class
- if self.bucket != None:
+ if self.bucket is not None:
if not replace:
if self.bucket.lookup(self.name):
return
@@ -1194,7 +1194,7 @@ class of the new Key to be REDUCED_REDUNDANCY. The Reduced
# What if different providers provide different classes?
if hasattr(fp, 'name'):
self.path = fp.name
- if self.bucket != None:
+ if self.bucket is not None:
if not md5 and provider.supports_chunked_transfer():
# defer md5 calculation to on the fly and
# we don't know anything about size yet.
@@ -1233,7 +1233,7 @@ class of the new Key to be REDUCED_REDUNDANCY. The Reduced
self.md5 = md5[0]
self.base64md5 = md5[1]
- if self.name == None:
+ if self.name is None:
self.name = self.md5
if not replace:
if self.bucket.lookup(self.name):
@@ -1574,7 +1574,7 @@ def get_contents_to_file(self, fp, headers=None,
with the stored object in the response. See
http://goo.gl/EWOPb 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,
@@ -1641,7 +1641,7 @@ def get_contents_to_filename(self, filename, headers=None,
os.remove(filename)
raise
# if last_modified date was sent from s3, try to set file's timestamp
- if self.last_modified != None:
+ if self.last_modified is not None:
try:
modified_tuple = rfc822.parsedate_tz(self.last_modified)
modified_stamp = int(rfc822.mktime_tz(modified_tuple))
View
2  boto/s3/resumable_download_handler.py
@@ -140,7 +140,7 @@ def _load_tracker_file_etag(self):
# is attempted on an object), but warn user for other errors.
if e.errno != errno.ENOENT:
# Will restart because
- # self.etag_value_for_current_download == None.
+ # self.etag_value_for_current_download is None.
print('Couldn\'t read URI tracker file (%s): %s. Restarting '
'download from scratch.' %
(self.tracker_file_name, e.strerror))
View
2  boto/sdb/connection.py
@@ -493,7 +493,7 @@ def get_attributes(self, domain_or_name, item_name, attribute_names=None,
response = self.make_request('GetAttributes', params)
body = response.read()
if response.status == 200:
- if item == None:
+ if item is None:
item = self.item_cls(domain, item_name)
h = handler.XmlHandler(item, self)
xml.sax.parseString(body, h)
View
2  boto/sdb/db/key.py
@@ -50,7 +50,7 @@ def id_or_name(self):
return self.id
def has_id_or_name(self):
- return self.id != None
+ return self.id is not None
def parent(self):
raise NotImplementedError("Key parents are not currently supported")
View
18 boto/sdb/db/manager/sdbmanager.py
@@ -107,7 +107,7 @@ def encode_list(self, prop, value):
def encode_map(self, prop, value):
import urllib
- if value == None:
+ if value is None:
return None
if not isinstance(value, dict):
raise ValueError('Expected a dict value, got %s' % type(value))
@@ -117,7 +117,7 @@ def encode_map(self, prop, value):
if self.model_class in item_type.mro():
item_type = self.model_class
encoded_value = self.encode(item_type, value[key])
- if encoded_value != None:
+ if encoded_value is not None:
new_value.append('%s:%s' % (urllib.quote(key), encoded_value))
return new_value
@@ -136,7 +136,7 @@ def decode_list(self, prop, value):
item_type = getattr(prop, "item_type")
dec_val = {}
for val in value:
- if val != None:
+ if val is not None:
k, v = self.decode_map_element(item_type, val)
try:
k = int(k)
@@ -351,7 +351,7 @@ def encode_blob(self, value):
else:
raise SDBPersistenceError("Invalid Blob ID: %s" % value.id)
- if value.value != None:
+ if value.value is not None:
key.set_contents_from_string(value.value)
return value.id
@@ -415,7 +415,7 @@ def __init__(self, cls, db_name, db_user, db_passwd,
self.converter = SDBConverter(self)
self._sdb = None
self._domain = None
- if consistent == None and hasattr(cls, "__consistent__"):
+ if consistent is None and hasattr(cls, "__consistent__"):
consistent = cls.__consistent__
self.consistent = consistent
@@ -456,7 +456,7 @@ def _object_lister(self, cls, query_lister):
yield obj
def encode_value(self, prop, value):
- if value == None:
+ if value is None:
return None
if not prop:
return str(value)
@@ -544,7 +544,7 @@ def _build_filter(self, property, name, op, val):
name = 'itemName()'
if name != "itemName()":
name = '`%s`' % name
- if val == None:
+ if val is None:
if op in ('is', '='):
return "%(name)s is null" % {"name": name}
elif op in ('is not', '!='):
@@ -585,7 +585,7 @@ def _build_filter_part(self, cls, filters, order_by=None, select=None):
query = "WHERE %s AND `__type__` = '%s'" % (filters, cls.__name__)
if order_by in ["__id__", "itemName()"]:
query += " ORDER BY itemName() %s" % order_by_method
- elif order_by != None:
+ elif order_by is not None:
query += " ORDER BY `%s` %s" % (order_by, order_by_method)
return query
@@ -667,7 +667,7 @@ def save_object(self, obj, expected_value=None):
value = self.encode_value(property, value)
if value == []:
value = None
- if value == None:
+ if value is None:
del_attrs.append(property.name)
continue
attrs[property.name] = value
View
6 boto/sdb/db/manager/xmlmanager.py
@@ -147,7 +147,7 @@ def decode_datetime(self, value):
def encode_reference(self, value):
if isinstance(value, basestring):
return value
- if value == None:
+ if value is None:
return ''
else:
val_node = self.manager.doc.createElement("object")
@@ -296,7 +296,7 @@ def get_object_from_doc(self, cls, id, doc):
prop = obj.find_property(prop_name)
value = self.decode_value(prop, prop_node)
value = prop.make_value_from_datastore(value)
- if value != None:
+ if value is not None:
try:
setattr(obj, prop.name, value)
except:
@@ -321,7 +321,7 @@ def get_props_from_doc(self, cls, id, doc):
prop = cls.find_property(prop_name)
value = self.decode_value(prop, prop_node)
value = prop.make_value_from_datastore(value)
- if value != None:
+ if value is not None:
props[prop.name] = value
return (cls, props, id)
View
2  boto/sdb/db/model.py
@@ -270,7 +270,7 @@ def find_subclass(cls, name):
return cls
for sc in cls.__sub_classes__:
r = sc.find_subclass(name)
- if r != None:
+ if r is not None:
return r
class Expando(Model):
View
16 boto/sdb/db/property.py
@@ -85,7 +85,7 @@ def default_value(self):
return self.default
def validate(self, value):
- if self.required and value == None:
+ if self.required and value is None:
raise ValueError('%s is a required property' % self.name)
if self.choices and value and not value in self.choices:
raise ValueError('%s not a valid choice for %s.%s' % (value, self.model_class.__name__, self.name))
@@ -111,7 +111,7 @@ def get_choices(self):
def validate_string(value):
- if value == None:
+ if value is None:
return
elif isinstance(value, basestring):
if len(value) > 1024:
@@ -328,7 +328,7 @@ def empty(self, value):
return value is None
def __set__(self, obj, value):
- if value == "" or value == None:
+ if value == "" or value is None:
value = 0
return super(IntegerProperty, self).__set__(obj, value)
@@ -408,7 +408,7 @@ def default_value(self):
return super(DateTimeProperty, self).default_value()
def validate(self, value):
- if value == None:
+ if value is None:
return
if isinstance(value, datetime.date):
return value
@@ -441,7 +441,7 @@ def default_value(self):
def validate(self, value):
value = super(DateProperty, self).validate(value)
- if value == None:
+ if value is None:
return
if not isinstance(value, self.data_type):
raise TypeError('Validation Error, expecting %s, got %s' % (self.data_type, type(value)))
@@ -501,7 +501,7 @@ def __get__(self, obj, objtype):
def __set__(self, obj, value):
"""Don't allow this object to be associated to itself
This causes bad things to happen"""
- if value != None and (obj.id == value or (hasattr(value, "id") and obj.id == value.id)):
+ if value is not None and (obj.id == value or (hasattr(value, "id") and obj.id == value.id)):
raise ValueError("Can not associate an object with itself!")
return super(ReferenceProperty, self).__set__(obj, value)
@@ -533,7 +533,7 @@ def check_instance(self, value):
def validate(self, value):
if self.validator:
self.validator(value)
- if self.required and value == None:
+ if self.required and value is None:
raise ValueError('%s is a required property' % self.name)
if value == self.default_value():
return
@@ -658,7 +658,7 @@ def __set__(self, obj, value):
item_type = self.item_type
if isinstance(value, item_type):
value = [value]
- elif value == None: # Override to allow them to set this to "None" to remove everything
+ elif value is None: # Override to allow them to set this to "None" to remove everything
value = []
return super(ListProperty, self).__set__(obj, value)
View
2  boto/sdb/db/query.py
@@ -39,7 +39,7 @@ def __iter__(self):
return iter(self.manager.query(self))
def next(self):
- if self.__local_iter__ == None:
+ if self.__local_iter__ is None:
self.__local_iter__ = self.__iter__()
return self.__local_iter__.next()
View
18 boto/sdb/db/sequence.py
@@ -59,7 +59,7 @@ def __call__(self, val, last=None):
# If they pass us in a string that's not at least
# the lenght of our sequence, then return the
# first element in our sequence
- if val == None or len(val) < self.sequence_length:
+ if val is None or len(val) < self.sequence_length:
return self.sequence_string[0]
last_value = val[-self.sequence_length:]
if (not self.rollover) and (last_value == self.last_item):
@@ -79,21 +79,21 @@ def _inc(self, val):
# Simple Sequence Functions
#
def increment_by_one(cv=None, lv=None):
- if cv == None:
+ if cv is None:
return 0
return cv + 1
def double(cv=None, lv=None):
- if cv == None:
+ if cv is None:
return 1
return cv * 2
def fib(cv=1, lv=0):
"""The fibonacci sequence, this incrementer uses the
last value"""
- if cv == None:
+ if cv is None:
cv = 1
- if lv == None:
+ if lv is None:
lv = 0
return cv + lv
@@ -136,10 +136,10 @@ def __init__(self, id=None, domain_name=None, fnc=increment_by_one, init_val=Non
self.last_value = None
self.domain_name = domain_name
self.id = id
- if init_val == None:
+ if init_val is None:
init_val = fnc(init_val)
- if self.id == None:
+ if self.id is None:
import uuid
self.id = str(uuid.uuid4())
@@ -162,7 +162,7 @@ def set(self, val):
expected_value = []
new_val = {}
new_val['timestamp'] = now
- if self._value != None:
+ if self._value is not None:
new_val['last_value'] = self._value
expected_value = ['current_value', str(self._value)]
new_val['current_value'] = val
@@ -184,7 +184,7 @@ def get(self):
self.timestamp = val['timestamp']
if 'current_value' in val:
self._value = self.item_type(val['current_value'])
- if "last_value" in val and val['last_value'] != None:
+ if "last_value" in val and val['last_value'] is not None:
self.last_value = self.item_type(val['last_value'])
return self._value
View
2  boto/sdb/item.py
@@ -123,7 +123,7 @@ def save(self, replace=True):
if replace:
del_attrs = []
for name in self:
- if self[name] == None:
+ if self[name] is None:
del_attrs.append(name)
if len(del_attrs) > 0:
self.domain.delete_attributes(self.name, del_attrs)
View
6 boto/sdb/queryresultset.py
@@ -33,7 +33,7 @@ def query_lister(domain, query='', max_items=None, attr_names=None):
yield item
num_results += 1
next_token = rs.next_token
- more_results = next_token != None
+ more_results = next_token is not None
class QueryResultSet(object):
@@ -59,7 +59,7 @@ def select_lister(domain, query='', max_items=None):
yield item
num_results += 1
next_token = rs.next_token
- more_results = next_token != None
+ more_results = next_token is not None
class SelectResultSet(object):
@@ -86,7 +86,7 @@ def __iter__(self):
self.next_token = rs.next_token
if self.max_items and num_results >= self.max_items:
raise StopIteration
- more_results = self.next_token != None
+ more_results = self.next_token is not None
def next(self):
return self.__iter__().next()
View
2  boto/services/message.py
@@ -34,7 +34,7 @@ def for_key(self, key, params=None, bucket_name=None):
self['OriginalLocation'] = t[0]
self['OriginalFileName'] = t[1]
mime_type = mimetypes.guess_type(t[1])[0]
- if mime_type == None:
+ if mime_type is None:
mime_type = 'application/octet-stream'
self['Content-Type'] = mime_type
s = os.stat(key.path)
View
2  boto/sqs/message.py
@@ -177,7 +177,7 @@ class MHMessage(Message):
"""
def __init__(self, queue=None, body=None, xml_attrs=None):
- if body == None or body == '':
+ if body is None or body == '':
body = {}
super(MHMessage, self).__init__(queue, body)
Please sign in to comment.
Something went wrong with that request. Please try again.