summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Holmstrom <gholms@fedoraproject.org>2012-03-10 18:18:48 -0800
committerMitch Garnaat <mitch@garnaat.com>2012-03-27 10:25:40 -0700
commitca67a94fe4f01b5c4ced5457c632b1e4cdda7fc1 (patch)
tree36edf72619d4a9ffffafe21dae049618e7357827
parent061cc2f9bae5cbe032936dc13940c9aec79502de (diff)
downloadboto-ca67a94fe4f01b5c4ced5457c632b1e4cdda7fc1.tar.gz
Replace has_key with in operators
-rw-r--r--boto/auth.py6
-rw-r--r--boto/connection.py6
-rw-r--r--boto/ec2/image.py6
-rw-r--r--boto/ec2/snapshot.py4
-rw-r--r--boto/fps/connection.py4
-rwxr-xr-xboto/gs/acl.py4
-rw-r--r--boto/provider.py4
-rw-r--r--boto/route53/connection.py2
-rw-r--r--boto/s3/key.py6
-rw-r--r--boto/sdb/db/manager/sdbmanager.py10
-rw-r--r--boto/sdb/db/manager/xmlmanager.py2
-rw-r--r--boto/sdb/db/model.py2
-rw-r--r--boto/sdb/db/sequence.py6
-rw-r--r--boto/sdb/domain.py2
-rw-r--r--boto/sdb/item.py2
-rw-r--r--boto/services/result.py4
-rw-r--r--boto/services/service.py4
-rw-r--r--boto/sqs/message.py4
-rw-r--r--boto/utils.py6
-rw-r--r--boto/vpc/dhcpoptions.py2
-rw-r--r--tests/dynamodb/test_layer2.py4
-rw-r--r--tests/ec2/test_connection.py4
-rw-r--r--tests/s3/test_versioning.py2
-rw-r--r--tests/sqs/test_connection.py12
24 files changed, 54 insertions, 54 deletions
diff --git a/boto/auth.py b/boto/auth.py
index 14bd0fa2..b8e00ef0 100644
--- a/boto/auth.py
+++ b/boto/auth.py
@@ -127,7 +127,7 @@ class HmacAuthV1Handler(AuthHandler, HmacKeys):
headers = http_request.headers
method = http_request.method
auth_path = http_request.auth_path
- if not headers.has_key('Date'):
+ if 'Date' not in headers:
headers['Date'] = formatdate(usegmt=True)
if self._provider.security_token:
@@ -156,7 +156,7 @@ class HmacAuthV2Handler(AuthHandler, HmacKeys):
def add_auth(self, http_request, **kwargs):
headers = http_request.headers
- if not headers.has_key('Date'):
+ if 'Date' not in headers:
headers['Date'] = formatdate(usegmt=True)
b64_hmac = self.sign_string(headers['Date'])
@@ -176,7 +176,7 @@ class HmacAuthV3Handler(AuthHandler, HmacKeys):
def add_auth(self, http_request, **kwargs):
headers = http_request.headers
- if not headers.has_key('Date'):
+ if 'Date' not in headers:
headers['Date'] = formatdate(usegmt=True)
b64_hmac = self.sign_string(headers['Date'])
diff --git a/boto/connection.py b/boto/connection.py
index e170d0b3..d169a23c 100644
--- a/boto/connection.py
+++ b/boto/connection.py
@@ -358,8 +358,8 @@ class HTTPRequest(object):
self.headers['User-Agent'] = UserAgent
# I'm not sure if this is still needed, now that add_auth is
# setting the content-length for POST requests.
- if not self.headers.has_key('Content-Length'):
- if not self.headers.has_key('Transfer-Encoding') or \
+ if 'Content-Length' not in self.headers:
+ if 'Transfer-Encoding' not in self.headers or \
self.headers['Transfer-Encoding'] != 'chunked':
self.headers['Content-Length'] = str(len(self.body))
@@ -559,7 +559,7 @@ class AWSAuthConnection(object):
self.proxy_port = proxy_port
self.proxy_user = proxy_user
self.proxy_pass = proxy_pass
- if os.environ.has_key('http_proxy') and not self.proxy:
+ if 'http_proxy' in os.environ and not self.proxy:
pattern = re.compile(
'(?:http://)?' \
'(?:(?P<user>\w+):(?P<pass>.*)@)?' \
diff --git a/boto/ec2/image.py b/boto/ec2/image.py
index de1b5d26..0baf8889 100644
--- a/boto/ec2/image.py
+++ b/boto/ec2/image.py
@@ -300,17 +300,17 @@ class ImageAttribute:
if name == 'launchPermission':
self.name = 'launch_permission'
elif name == 'group':
- if self.attrs.has_key('groups'):
+ if 'groups' in self.attrs:
self.attrs['groups'].append(value)
else:
self.attrs['groups'] = [value]
elif name == 'userId':
- if self.attrs.has_key('user_ids'):
+ if 'user_ids' in self.attrs:
self.attrs['user_ids'].append(value)
else:
self.attrs['user_ids'] = [value]
elif name == 'productCode':
- if self.attrs.has_key('product_codes'):
+ if 'product_codes' in self.attrs:
self.attrs['product_codes'].append(value)
else:
self.attrs['product_codes'] = [value]
diff --git a/boto/ec2/snapshot.py b/boto/ec2/snapshot.py
index d52abe44..241cef26 100644
--- a/boto/ec2/snapshot.py
+++ b/boto/ec2/snapshot.py
@@ -124,12 +124,12 @@ class SnapshotAttribute:
if name == 'createVolumePermission':
self.name = 'create_volume_permission'
elif name == 'group':
- if self.attrs.has_key('groups'):
+ if 'groups' in self.attrs:
self.attrs['groups'].append(value)
else:
self.attrs['groups'] = [value]
elif name == 'userId':
- if self.attrs.has_key('user_ids'):
+ if 'user_ids' in self.attrs:
self.attrs['user_ids'].append(value)
else:
self.attrs['user_ids'] = [value]
diff --git a/boto/fps/connection.py b/boto/fps/connection.py
index 27eef8f9..d2fcb58c 100644
--- a/boto/fps/connection.py
+++ b/boto/fps/connection.py
@@ -146,7 +146,7 @@ class FPSConnection(AWSQueryConnection):
params["signatureMethod"] = 'HmacSHA256'
params["signatureVersion"] = '2'
- if(not params.has_key('callerReference')):
+ if('callerReference' not in params):
params['callerReference'] = str(uuid.uuid4())
parts = ''
@@ -191,7 +191,7 @@ class FPSConnection(AWSQueryConnection):
params["signatureMethod"] = 'HmacSHA256'
params["signatureVersion"] = '2'
- if(not params.has_key('callerReference')):
+ if('callerReference' not in params):
params['callerReference'] = str(uuid.uuid4())
parts = ''
diff --git a/boto/gs/acl.py b/boto/gs/acl.py
index 93bb4a9c..02a5c9ba 100755
--- a/boto/gs/acl.py
+++ b/boto/gs/acl.py
@@ -189,7 +189,7 @@ class Entry:
# __contains__() method works). At one time gsutil disallowed
# xmlplus-based parsers, until this more specific problem was
# determined.
- if not attrs.has_key(TYPE):
+ if TYPE not in attrs:
raise InvalidAclError('Missing "%s" in "%s" part of ACL' %
(TYPE, SCOPE))
self.scope = Scope(self, attrs[TYPE])
@@ -238,7 +238,7 @@ class Scope:
self.id = id
self.domain = domain
self.email_address = email_address
- if not self.ALLOWED_SCOPE_TYPE_SUB_ELEMS.has_key(self.type):
+ if self.type not in self.ALLOWED_SCOPE_TYPE_SUB_ELEMS:
raise InvalidAclError('Invalid %s %s "%s" ' %
(SCOPE, TYPE, self.type))
diff --git a/boto/provider.py b/boto/provider.py
index 37ceae72..e9a73975 100644
--- a/boto/provider.py
+++ b/boto/provider.py
@@ -176,14 +176,14 @@ class Provider(object):
access_key_name, secret_key_name = self.CredentialMap[self.name]
if access_key is not None:
self.access_key = access_key
- elif os.environ.has_key(access_key_name.upper()):
+ elif access_key_name.upper() in os.environ:
self.access_key = os.environ[access_key_name.upper()]
elif config.has_option('Credentials', access_key_name):
self.access_key = config.get('Credentials', access_key_name)
if secret_key is not None:
self.secret_key = secret_key
- elif os.environ.has_key(secret_key_name.upper()):
+ elif secret_key_name.upper() in os.environ:
self.secret_key = os.environ[secret_key_name.upper()]
elif config.has_option('Credentials', secret_key_name):
self.secret_key = config.get('Credentials', secret_key_name)
diff --git a/boto/route53/connection.py b/boto/route53/connection.py
index 0ae63c14..a5183da1 100644
--- a/boto/route53/connection.py
+++ b/boto/route53/connection.py
@@ -101,7 +101,7 @@ class Route53Connection(AWSAuthConnection):
h.parse(body)
if zone_list:
e['ListHostedZonesResponse']['HostedZones'].extend(zone_list)
- while e['ListHostedZonesResponse'].has_key('NextMarker'):
+ while 'NextMarker' in e['ListHostedZonesResponse']:
next_marker = e['ListHostedZonesResponse']['NextMarker']
zone_list = e['ListHostedZonesResponse']['HostedZones']
e = self.get_all_hosted_zones(next_marker, zone_list)
diff --git a/boto/s3/key.py b/boto/s3/key.py
index e8da98f3..4a9a8296 100644
--- a/boto/s3/key.py
+++ b/boto/s3/key.py
@@ -628,9 +628,9 @@ class Key(object):
headers['User-Agent'] = UserAgent
if self.storage_class != 'STANDARD':
headers[provider.storage_class_header] = self.storage_class
- if headers.has_key('Content-Encoding'):
+ if 'Content-Encoding' in headers:
self.content_encoding = headers['Content-Encoding']
- if headers.has_key('Content-Type'):
+ if 'Content-Type' in headers:
# Some use cases need to suppress sending of the Content-Type
# header and depend on the receiving server to set the content
# type. This can be achieved by setting headers['Content-Type']
@@ -1167,7 +1167,7 @@ class Key(object):
cb(data_len, cb_size)
if m:
self.md5 = m.hexdigest()
- if self.size is None and not torrent and not headers.has_key("Range"):
+ if self.size is None and not torrent and "Range" not in headers:
self.size = data_len
self.close()
self.bucket.connection.debug = save_debug
diff --git a/boto/sdb/db/manager/sdbmanager.py b/boto/sdb/db/manager/sdbmanager.py
index 7f20350e..ef7117fe 100644
--- a/boto/sdb/db/manager/sdbmanager.py
+++ b/boto/sdb/db/manager/sdbmanager.py
@@ -471,9 +471,9 @@ class SDBManager(object):
def load_object(self, obj):
if not obj._loaded:
a = self.domain.get_attributes(obj.id,consistent_read=self.consistent)
- if a.has_key('__type__'):
+ if '__type__' in a:
for prop in obj.properties(hidden=False):
- if a.has_key(prop.name):
+ if prop.name in a:
value = self.decode_value(prop, a[prop.name])
value = prop.make_value_from_datastore(value)
try:
@@ -486,13 +486,13 @@ class SDBManager(object):
obj = None
if not a:
a = self.domain.get_attributes(id,consistent_read=self.consistent)
- if a.has_key('__type__'):
+ if '__type__' in a:
if not cls or a['__type__'] != cls.__name__:
cls = find_class(a['__module__'], a['__type__'])
if cls:
params = {}
for prop in cls.properties(hidden=False):
- if a.has_key(prop.name):
+ if prop.name in a:
value = self.decode_value(prop, a[prop.name])
value = prop.make_value_from_datastore(value)
params[prop.name] = value
@@ -716,7 +716,7 @@ class SDBManager(object):
def get_key_value(self, obj, name):
a = self.domain.get_attributes(obj.id, name,consistent_read=self.consistent)
- if a.has_key(name):
+ if name in a:
return a[name]
else:
return None
diff --git a/boto/sdb/db/manager/xmlmanager.py b/boto/sdb/db/manager/xmlmanager.py
index 3608b2c2..aca2d7c2 100644
--- a/boto/sdb/db/manager/xmlmanager.py
+++ b/boto/sdb/db/manager/xmlmanager.py
@@ -495,7 +495,7 @@ class XMLManager(object):
def get_key_value(self, obj, name):
a = self.domain.get_attributes(obj.id, name)
- if a.has_key(name):
+ if name in a:
return a[name]
else:
return None
diff --git a/boto/sdb/db/model.py b/boto/sdb/db/model.py
index eab82763..65a33963 100644
--- a/boto/sdb/db/model.py
+++ b/boto/sdb/db/model.py
@@ -154,7 +154,7 @@ class Model(object):
setattr(self, prop.name, prop.default_value())
except ValueError:
pass
- if kw.has_key('manager'):
+ if 'manager' in kw:
self._manager = kw['manager']
self.id = id
for key in kw:
diff --git a/boto/sdb/db/sequence.py b/boto/sdb/db/sequence.py
index a01330e8..10f1ac27 100644
--- a/boto/sdb/db/sequence.py
+++ b/boto/sdb/db/sequence.py
@@ -180,11 +180,11 @@ class Sequence(object):
"""Get the value"""
val = self.db.get_attributes(self.id, consistent_read=True)
if val:
- if val.has_key('timestamp'):
+ if 'timestamp' in val:
self.timestamp = val['timestamp']
- if val.has_key('current_value'):
+ if 'current_value' in val:
self._value = self.item_type(val['current_value'])
- if val.has_key("last_value") and val['last_value'] != None:
+ if val.get('last_value') is not None:
self.last_value = self.item_type(val['last_value'])
return self._value
diff --git a/boto/sdb/domain.py b/boto/sdb/domain.py
index f348c8aa..d4faf046 100644
--- a/boto/sdb/domain.py
+++ b/boto/sdb/domain.py
@@ -343,7 +343,7 @@ class DomainDumpParser(ContentHandler):
if self.value and self.attribute:
value = self.value.strip()
attr_name = self.attribute.strip()
- if self.attrs.has_key(attr_name):
+ if attr_name in self.attrs:
self.attrs[attr_name].append(value)
else:
self.attrs[attr_name] = [value]
diff --git a/boto/sdb/item.py b/boto/sdb/item.py
index 86bc70ca..999c7f0b 100644
--- a/boto/sdb/item.py
+++ b/boto/sdb/item.py
@@ -75,7 +75,7 @@ class Item(dict):
else:
self.name = self.decode_value(value)
elif name == 'Value':
- if self.has_key(self.last_key):
+ if self.last_key in self:
if not isinstance(self[self.last_key], list):
self[self.last_key] = [self[self.last_key]]
value = self.decode_value(value)
diff --git a/boto/services/result.py b/boto/services/result.py
index 32a6d6a6..8117673f 100644
--- a/boto/services/result.py
+++ b/boto/services/result.py
@@ -76,7 +76,7 @@ class ResultProcessor:
self.log_message(record, path)
self.calculate_stats(record)
outputs = record['OutputKey'].split(',')
- if record.has_key('OutputBucket'):
+ if 'OutputBucket' in record:
bucket = boto.lookup('s3', record['OutputBucket'])
else:
bucket = boto.lookup('s3', record['Bucket'])
@@ -92,7 +92,7 @@ class ResultProcessor:
def get_results_from_queue(self, path, get_file=True, delete_msg=True):
m = self.queue.read()
while m:
- if m.has_key('Batch') and m['Batch'] == self.batch:
+ if 'Batch' in m and m['Batch'] == self.batch:
self.process_record(m, path, get_file)
if delete_msg:
self.queue.delete_message(m)
diff --git a/boto/services/service.py b/boto/services/service.py
index 8ee1a8be..e0e987ce 100644
--- a/boto/services/service.py
+++ b/boto/services/service.py
@@ -92,7 +92,7 @@ class Service(ScriptBase):
def save_results(self, results, input_message, output_message):
output_keys = []
for file, type in results:
- if input_message.has_key('OutputBucket'):
+ if 'OutputBucket' in input_message:
output_bucket = input_message['OutputBucket']
else:
output_bucket = input_message['Bucket']
@@ -105,7 +105,7 @@ class Service(ScriptBase):
def write_message(self, message):
message['Service-Write'] = get_ts()
message['Server'] = self.name
- if os.environ.has_key('HOSTNAME'):
+ if 'HOSTNAME' in os.environ:
message['Host'] = os.environ['HOSTNAME']
else:
message['Host'] = 'unknown'
diff --git a/boto/sqs/message.py b/boto/sqs/message.py
index 8fabd478..cdd21795 100644
--- a/boto/sqs/message.py
+++ b/boto/sqs/message.py
@@ -198,7 +198,7 @@ class MHMessage(Message):
return s
def __getitem__(self, key):
- if self._body.has_key(key):
+ if key in self._body:
return self._body[key]
else:
raise KeyError(key)
@@ -217,7 +217,7 @@ class MHMessage(Message):
return self._body.items()
def has_key(self, key):
- return self._body.has_key(key)
+ return key in self._body
def update(self, d):
self._body.update(d)
diff --git a/boto/utils.py b/boto/utils.py
index a2bf386d..55f91f37 100644
--- a/boto/utils.py
+++ b/boto/utils.py
@@ -98,13 +98,13 @@ def canonical_string(method, path, headers, expires=None,
interesting_headers[lk] = headers[key].strip()
# these keys get empty strings if they don't exist
- if not interesting_headers.has_key('content-type'):
+ if 'content-type' not in interesting_headers:
interesting_headers['content-type'] = ''
- if not interesting_headers.has_key('content-md5'):
+ if 'content-md5' not in interesting_headers:
interesting_headers['content-md5'] = ''
# just in case someone used this. it's not necessary in this lib.
- if interesting_headers.has_key(provider.date_header):
+ if provider.date_header in interesting_headers:
interesting_headers['date'] = ''
# if you're using expires for query string auth, then it trumps date
diff --git a/boto/vpc/dhcpoptions.py b/boto/vpc/dhcpoptions.py
index 810d9cf8..74846838 100644
--- a/boto/vpc/dhcpoptions.py
+++ b/boto/vpc/dhcpoptions.py
@@ -38,7 +38,7 @@ class DhcpConfigSet(dict):
def startElement(self, name, attrs, connection):
if name == 'valueSet':
- if not self.has_key(self._name):
+ if self._name not in self:
self[self._name] = DhcpValueSet()
return self[self._name]
diff --git a/tests/dynamodb/test_layer2.py b/tests/dynamodb/test_layer2.py
index 63708a1a..6b361a5f 100644
--- a/tests/dynamodb/test_layer2.py
+++ b/tests/dynamodb/test_layer2.py
@@ -199,9 +199,9 @@ class DynamoDBLayer2Test (unittest.TestCase):
item1_updated = table.get_item(item1_key, item1_range,
consistent_read=True)
assert item1_updated['Replies'] == item1_attrs['Replies'] + 2
- self.assertFalse(item1_updated.has_key(removed_attr))
+ self.assertFalse(removed_attr in item1_updated)
self.assertTrue(removed_tag not in item1_updated['Tags'])
- self.assertTrue(item1_updated.has_key('RepliesBy'))
+ self.assertTrue('RepliesBy' in item1_updated)
self.assertTrue(item1_updated['RepliesBy'] == replies_by_set)
# Put a few more items into the table
diff --git a/tests/ec2/test_connection.py b/tests/ec2/test_connection.py
index 6b7ece1f..bb1c5c89 100644
--- a/tests/ec2/test_connection.py
+++ b/tests/ec2/test_connection.py
@@ -48,14 +48,14 @@ class EC2ConnectionTest (unittest.TestCase):
status = image.set_launch_permissions(group_names=['all'])
assert status
d = image.get_launch_permissions()
- assert d.has_key('groups')
+ assert 'groups' in d
assert len(d['groups']) > 0
# now remove that permission
status = image.remove_launch_permissions(group_names=['all'])
assert status
time.sleep(10)
d = image.get_launch_permissions()
- assert not d.has_key('groups')
+ assert 'groups' not in d
# create 2 new security groups
group1_name = 'test-%d' % int(time.time())
diff --git a/tests/s3/test_versioning.py b/tests/s3/test_versioning.py
index 2d569af9..b3e74a5c 100644
--- a/tests/s3/test_versioning.py
+++ b/tests/s3/test_versioning.py
@@ -46,7 +46,7 @@ class S3VersionTest (unittest.TestCase):
def test_1_versions(self):
# check versioning off
d = self.bucket.get_versioning_status()
- self.assertFalse(d.has_key('Versioning'))
+ self.assertFalse('Versioning' in d)
# enable versioning
self.bucket.configure_versioning(versioning=True)
diff --git a/tests/sqs/test_connection.py b/tests/sqs/test_connection.py
index 6996a54a..83c00734 100644
--- a/tests/sqs/test_connection.py
+++ b/tests/sqs/test_connection.py
@@ -66,14 +66,14 @@ class SQSConnectionTest (unittest.TestCase):
# now try to get queue attributes
a = q.get_attributes()
- assert a.has_key('ApproximateNumberOfMessages')
- assert a.has_key('VisibilityTimeout')
+ assert 'ApproximateNumberOfMessages' in a
+ assert 'VisibilityTimeout' in a
a = q.get_attributes('ApproximateNumberOfMessages')
- assert a.has_key('ApproximateNumberOfMessages')
- assert not a.has_key('VisibilityTimeout')
+ assert 'ApproximateNumberOfMessages' in a
+ assert 'VisibilityTimeout' not in a
a = q.get_attributes('VisibilityTimeout')
- assert not a.has_key('ApproximateNumberOfMessages')
- assert a.has_key('VisibilityTimeout')
+ assert 'ApproximateNumberOfMessages' not in a
+ assert 'VisibilityTimeout' in a
# now change the visibility timeout
timeout = 45