summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2016-10-14 10:21:11 +0000
committerxudan <xudan16@huawei.com>2016-10-14 12:26:15 +0000
commit2fccbbd5a616186e10c30de6262263df1f1f0740 (patch)
tree8526fd5398d1c159c5f5f4d35a7605fb3780d4f5 /dovetail/utils/dovetail_utils.py
parent2c7f65363fc429fbf58bacfae9edbf8e601d01c7 (diff)
[dovetail_tool] Fix the python style scanned by flake8
JIRA: DOVETAIL-34 Change-Id: Ib9a6dd254f1d77b0cbbfa66e8e1e44df1ce14a4b Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 4c671552..2e33b53a 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -11,12 +11,11 @@
import sys
import subprocess
+from collections import Mapping, Set, Sequence
+
-def exec_cmd(cmd, logger=None,
- exit_on_error=True,
- info=False,
- error_msg="",
- verbose=True):
+def exec_cmd(cmd, logger=None, exit_on_error=True, info=False,
+ error_msg="", verbose=True):
if not error_msg:
error_msg = ("The command '%s' failed." % cmd)
msg_exec = ("Executing command: '%s'" % cmd)
@@ -55,12 +54,16 @@ def exec_cmd(cmd, logger=None,
return returncode, output[0].strip()
-#walkthrough the object, yield path and value
-from collections import Mapping, Set, Sequence
+# walkthrough the object, yield path and value
# dual python 2/3 compatability, inspired by the "six" library
string_types = (str, unicode) if str is bytes else (str, bytes)
-iteritems = lambda mapping: getattr(mapping, 'iteritems', mapping.items)()
+# iteritems = lambda mapping: getattr(mapping, 'iteritems', mapping.items)()
+
+
+def iteritems(mapping):
+ return getattr(mapping, 'iteritems', mapping.items)()
+
def objwalk(obj, path=(), memo=None):
if memo is None:
@@ -68,7 +71,8 @@ def objwalk(obj, path=(), memo=None):
iterator = None
if isinstance(obj, Mapping):
iterator = iteritems
- elif isinstance(obj, (Sequence, Set)) and not isinstance(obj, string_types):
+ elif isinstance(obj, (Sequence, Set)) and not isinstance(obj,
+ string_types):
iterator = enumerate
if iterator:
if id(obj) not in memo:
@@ -80,8 +84,8 @@ def objwalk(obj, path=(), memo=None):
else:
yield path, obj
-def get_obj_by_path(obj,dst_path):
+
+def get_obj_by_path(obj, dst_path):
for path, obj in objwalk(obj):
if path == dst_path:
return obj
-