Merge "Removed many unnecessary uses of dict.keys"
This commit is contained in:
commit
61db4d6ef8
@ -267,7 +267,7 @@ class AccountReaper(Daemon):
|
||||
self.stats_objects_possibly_remaining
|
||||
if self.stats_return_codes:
|
||||
log += _(', return codes: ')
|
||||
for code in sorted(self.stats_return_codes.keys()):
|
||||
for code in sorted(self.stats_return_codes):
|
||||
log += '%s %sxxs, ' % (self.stats_return_codes[code], code)
|
||||
log = log[:-2]
|
||||
log += _(', elapsed: %.02fs') % (time() - begin)
|
||||
|
@ -50,7 +50,7 @@ def utf8encode(*args):
|
||||
|
||||
|
||||
def utf8encodekeys(metadata):
|
||||
uni_keys = [k for k in metadata.keys() if isinstance(k, unicode)]
|
||||
uni_keys = [k for k in metadata if isinstance(k, unicode)]
|
||||
for k in uni_keys:
|
||||
sv = metadata[k]
|
||||
del metadata[k]
|
||||
@ -274,7 +274,7 @@ class DatabaseBroker(object):
|
||||
timestamp = normalize_timestamp(timestamp)
|
||||
# first, clear the metadata
|
||||
cleared_meta = {}
|
||||
for k in self.metadata.iterkeys():
|
||||
for k in self.metadata:
|
||||
cleared_meta[k] = ('', timestamp)
|
||||
self.update_metadata(cleared_meta)
|
||||
# then mark the db as deleted
|
||||
|
@ -106,7 +106,7 @@ class MemcacheRing(object):
|
||||
for i in xrange(NODE_WEIGHT):
|
||||
self._ring[md5hash('%s-%s' % (server, i))] = server
|
||||
self._tries = tries if tries <= len(servers) else len(servers)
|
||||
self._sorted = sorted(self._ring.keys())
|
||||
self._sorted = sorted(self._ring)
|
||||
self._client_cache = dict(((server, []) for server in servers))
|
||||
self._connect_timeout = connect_timeout
|
||||
self._io_timeout = io_timeout
|
||||
|
@ -56,7 +56,7 @@ def get_response_body(data_format, data_dict, error_list):
|
||||
return json.dumps(data_dict)
|
||||
if data_format and data_format.endswith('/xml'):
|
||||
output = '<delete>\n'
|
||||
for key in sorted(data_dict.keys()):
|
||||
for key in sorted(data_dict):
|
||||
xml_key = key.replace(' ', '_').lower()
|
||||
output += '<%s>%s</%s>\n' % (xml_key, data_dict[key], xml_key)
|
||||
output += '<errors>\n'
|
||||
@ -69,7 +69,7 @@ def get_response_body(data_format, data_dict, error_list):
|
||||
return output
|
||||
|
||||
output = ''
|
||||
for key in sorted(data_dict.keys()):
|
||||
for key in sorted(data_dict):
|
||||
output += '%s: %s\n' % (key, data_dict[key])
|
||||
output += 'Errors:\n'
|
||||
output += '\n'.join(
|
||||
|
@ -25,7 +25,7 @@ from swift.common.swob import Request, Response
|
||||
|
||||
def interpret_conf_limits(conf, name_prefix):
|
||||
conf_limits = []
|
||||
for conf_key in conf.keys():
|
||||
for conf_key in conf:
|
||||
if conf_key.startswith(name_prefix):
|
||||
cont_size = int(conf_key[len(name_prefix):])
|
||||
rate = float(conf[conf_key])
|
||||
|
@ -164,7 +164,7 @@ def parse_input(raw_data):
|
||||
req_keys = set(['path', 'etag', 'size_bytes'])
|
||||
try:
|
||||
for seg_dict in parsed_data:
|
||||
if (set(seg_dict.keys()) != req_keys or
|
||||
if (set(seg_dict) != req_keys or
|
||||
'/' not in seg_dict['path'].lstrip('/')):
|
||||
raise HTTPBadRequest('Invalid SLO Manifest File')
|
||||
except (AttributeError, TypeError):
|
||||
|
@ -171,7 +171,7 @@ class Ring(object):
|
||||
self.tier2devs[tier].append(dev)
|
||||
|
||||
tiers_by_length = defaultdict(list)
|
||||
for tier in self.tier2devs.keys():
|
||||
for tier in self.tier2devs:
|
||||
tiers_by_length[len(tier)].append(tier)
|
||||
self.tiers_by_length = sorted(tiers_by_length.values(),
|
||||
key=lambda x: len(x[0]))
|
||||
|
@ -235,7 +235,7 @@ class HeaderEnvironProxy(UserDict.DictMixin):
|
||||
|
||||
def keys(self):
|
||||
keys = [key[5:].replace('_', '-').title()
|
||||
for key in self.environ.iterkeys() if key.startswith('HTTP_')]
|
||||
for key in self.environ if key.startswith('HTTP_')]
|
||||
if 'CONTENT_LENGTH' in self.environ:
|
||||
keys.append('Content-Length')
|
||||
if 'CONTENT_TYPE' in self.environ:
|
||||
|
@ -406,7 +406,7 @@ class ContainerController(object):
|
||||
"last_modified"]:
|
||||
SubElement(obj_element, field).text = str(
|
||||
record.pop(field)).decode('utf-8')
|
||||
for field in sorted(record.keys()):
|
||||
for field in sorted(record):
|
||||
SubElement(obj_element, field).text = str(
|
||||
record[field]).decode('utf-8')
|
||||
ret.body = tostring(doc, encoding='UTF-8').replace(
|
||||
|
Loading…
x
Reference in New Issue
Block a user