Merge "Update the rest of the code to satisfy flake8 in a py34 env"

This commit is contained in:
Jenkins 2015-04-25 02:24:10 +00:00 committed by Gerrit Code Review
commit d78c6a6e90
7 changed files with 27 additions and 8 deletions

View File

@ -100,7 +100,7 @@ if __name__ == '__main__':
provision_log = os.path.join(VAR_PATH, 'provision-finished')
# touch the file so it is timestamped with when finished
pl = file(provision_log, 'a')
pl = open(provision_log, 'a')
try:
os.utime(provision_log, None)
finally:

View File

@ -76,7 +76,7 @@ def _import_module(importer, module_name, package):
# Make this accessible through the parent package for static imports
local_name = module_name.partition(package.__name__ + '.')[2]
module_components = local_name.split('.')
parent = reduce(getattr, module_components[:-1], package)
parent = six.moves.reduce(getattr, module_components[:-1], package)
setattr(parent, module_components[-1], module)
return module

View File

@ -198,6 +198,6 @@ def select_from_attribute(attribute_value, path):
return collection[key]
try:
return reduce(get_path_component, path, attribute_value)
return six.moves.reduce(get_path_component, path, attribute_value)
except (KeyError, IndexError, TypeError):
return None

View File

@ -449,7 +449,7 @@ class Replace(function.Function):
return string.replace(placeholder, six.text_type(value))
return reduce(replace, six.iteritems(mapping), template)
return six.moves.reduce(replace, six.iteritems(mapping), template)
class Base64(function.Function):

View File

@ -83,7 +83,8 @@ class GetParam(function.Function):
return collection[key]
try:
return reduce(get_path_component, path_components, parameter)
return six.moves.reduce(get_path_component, path_components,
parameter)
except (KeyError, IndexError, TypeError):
return ''

View File

@ -412,6 +412,6 @@ def _hash_data(data):
if isinstance(data, collections.Mapping):
item_hashes = (hash(k) ^ _hash_data(v) for k, v in data.items())
return reduce(operator.xor, item_hashes, 0L)
return six.moves.reduce(operator.xor, item_hashes, 0)
return hash(data)

View File

@ -89,10 +89,28 @@ class Timeout(BaseException):
generator.close()
return False
def __cmp__(self, other):
def __eq__(self, other):
return not self < other and not other < self
def __ne__(self, other):
return not self.__eq__(other)
def __gt__(self, other):
return other < self
def __ge__(self, other):
return not self < other
def __le__(self, other):
return not other < self
def __lt__(self, other):
if not isinstance(other, Timeout):
return NotImplemented
return cmp(self._endtime, other._endtime)
return self._endtime < other._endtime
def __cmp__(self, other):
return self < other
class TimedCancel(Timeout):