提交 58340038 编写于 作者: R Rudá Moura

Merge pull request #423 from ldoktor/pep8

PEP8 fixes: W503
...@@ -214,8 +214,8 @@ class TreeNode(object): ...@@ -214,8 +214,8 @@ class TreeNode(object):
if self.parent else {}) if self.parent else {})
for key, value in self.value.iteritems(): for key, value in self.value.iteritems():
if isinstance(value, list): if isinstance(value, list):
if (key in self._environment if (key in self._environment and
and isinstance(self._environment[key], list)): isinstance(self._environment[key], list)):
self._environment[key] = self._environment[key] + value self._environment[key] = self._environment[key] + value
else: else:
self._environment[key] = value self._environment[key] = value
...@@ -308,8 +308,8 @@ class TreeNode(object): ...@@ -308,8 +308,8 @@ class TreeNode(object):
if not compact: if not compact:
result.pop() result.pop()
(low, high, end) = (mids[0], mids[-1], len(result)) (low, high, end) = (mids[0], mids[-1], len(result))
prefixes = ([pad] * (low + 1) + [_pad + '|'] * (high - low - 1) prefixes = ([pad] * (low + 1) + [_pad + '|'] * (high - low - 1) +
+ [pad] * (end - high)) [pad] * (end - high))
mid = (low + high) / 2 mid = (low + high) / 2
prefixes[mid] = char1 + '-' * (length - 2) + prefixes[mid][-1] prefixes[mid] = char1 + '-' * (length - 2) + prefixes[mid][-1]
result = [p + l for (p, l) in zip(prefixes, result)] result = [p + l for (p, l) in zip(prefixes, result)]
......
...@@ -298,8 +298,8 @@ class DpkgBackend(BaseBackend): ...@@ -298,8 +298,8 @@ class DpkgBackend(BaseBackend):
n_cmd = (self.lowlevel_base_cmd + ' -f ' + name + n_cmd = (self.lowlevel_base_cmd + ' -f ' + name +
' Package 2>/dev/null') ' Package 2>/dev/null')
name = process.system_output(n_cmd) name = process.system_output(n_cmd)
i_cmd = (self.lowlevel_base_cmd + "--show -f='${Status}' " i_cmd = (self.lowlevel_base_cmd + "--show -f='${Status}' " +
+ name + ' 2>/dev/null') name + ' 2>/dev/null')
# Checking if package is installed # Checking if package is installed
package_status = process.system_output(i_cmd, ignore_status=True) package_status = process.system_output(i_cmd, ignore_status=True)
dpkg_not_installed = (package_status != self.INSTALLED_OUTPUT) dpkg_not_installed = (package_status != self.INSTALLED_OUTPUT)
......
...@@ -213,8 +213,8 @@ class RunRemote(plugin.Plugin): ...@@ -213,8 +213,8 @@ class RunRemote(plugin.Plugin):
:return: True when enable_arg enabled and all required args are set :return: True when enable_arg enabled and all required args are set
:raise sys.exit: When missing required argument. :raise sys.exit: When missing required argument.
""" """
if (not hasattr(app_args, enable_arg) if (not hasattr(app_args, enable_arg) or
or not getattr(app_args, enable_arg)): not getattr(app_args, enable_arg)):
return False return False
missing = [] missing = []
for arg in required_args: for arg in required_args:
......
...@@ -136,8 +136,8 @@ class RunVM(plugin.Plugin): ...@@ -136,8 +136,8 @@ class RunVM(plugin.Plugin):
:return: True when enable_arg enabled and all required args are set :return: True when enable_arg enabled and all required args are set
:raise sys.exit: When missing required argument. :raise sys.exit: When missing required argument.
""" """
if (not hasattr(app_args, enable_arg) if (not hasattr(app_args, enable_arg) or
or not getattr(app_args, enable_arg)): not getattr(app_args, enable_arg)):
return False return False
missing = [] missing = []
for arg in required_args: for arg in required_args:
......
...@@ -93,8 +93,8 @@ def strip_console_codes(output, custom_codes=None): ...@@ -93,8 +93,8 @@ def strip_console_codes(output, custom_codes=None):
while index < len(output): while index < len(output):
tmp_index = 0 tmp_index = 0
tmp_word = "" tmp_word = ""
while (len(re.findall("\x1b", tmp_word)) < 2 while (len(re.findall("\x1b", tmp_word)) < 2 and
and index + tmp_index < len(output)): index + tmp_index < len(output)):
tmp_word += output[index + tmp_index] tmp_word += output[index + tmp_index]
tmp_index += 1 tmp_index += 1
......
...@@ -38,8 +38,8 @@ def measure_duration(func): ...@@ -38,8 +38,8 @@ def measure_duration(func):
return func(*args, **kwargs) return func(*args, **kwargs)
finally: finally:
duration = time.time() - start duration = time.time() - start
__MEASURE_DURATION[func] = (__MEASURE_DURATION.get(func, 0) __MEASURE_DURATION[func] = (__MEASURE_DURATION.get(func, 0) +
+ duration) duration)
LOGGER.debug("PERF: %s: (%ss, %ss)", func, duration, LOGGER.debug("PERF: %s: (%ss, %ss)", func, duration,
__MEASURE_DURATION[func]) __MEASURE_DURATION[func])
return wrapper return wrapper
...@@ -111,8 +111,8 @@ class MultiplexTests(unittest.TestCase): ...@@ -111,8 +111,8 @@ class MultiplexTests(unittest.TestCase):
expected_rc = 0 expected_rc = 0
output = self.run_and_check(cmd_line, expected_rc) output = self.run_and_check(cmd_line, expected_rc)
for msg in ('A', 'ASDFASDF', 'This is very long\nmultiline\ntext.'): for msg in ('A', 'ASDFASDF', 'This is very long\nmultiline\ntext.'):
msg = ('[stdout] Custom variable: ' msg = ('[stdout] Custom variable: ' +
+ '\n[stdout] '.join(msg.splitlines())) '\n[stdout] '.join(msg.splitlines()))
self.assertIn(msg, output, "Multiplexed variable should produce:" self.assertIn(msg, output, "Multiplexed variable should produce:"
"\n %s\nwhich is not present in the output:\n %s" "\n %s\nwhich is not present in the output:\n %s"
% ("\n ".join(msg.splitlines()), % ("\n ".join(msg.splitlines()),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册