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

* Use six.moves.reduce
* Update numliteral from 0L to 0
* Use open() instead of file()
* Use rich comparison methods instead of cmp()

partial blueprint heat-python34-support

Change-Id: I9ffd85645563192b5d6124f8dbb71c24245eefc4
changes/66/176766/2
Sirushti Murugesan 8 years ago
parent 796680c9c7
commit 640abe0c12
  1. 2
      heat/cloudinit/loguserdata.py
  2. 2
      heat/common/plugin_loader.py
  3. 2
      heat/engine/attributes.py
  4. 2
      heat/engine/cfn/functions.py
  5. 3
      heat/engine/hot/functions.py
  6. 2
      heat/engine/rsrc_defn.py
  7. 22
      heat/engine/scheduler.py

@ -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:

@ -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

@ -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

@ -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):

@ -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 ''

@ -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)

@ -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):

Loading…
Cancel
Save