Fix objmgr using pycodestyle (pep8) rules
Create a setup.cfg file which is used by pycodestyle
(formerly pep8) to override defaults. This file can
be used by the build verification to check if a repo
can have format-check run.
Fix long lines, bare excepctions, and lambda error messages.
Change-Id: If7f4590c098e04aad6b507c410934f433c739bc7
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/obmc/mapper/bindings.py b/obmc/mapper/bindings.py
index d436bb3..dadec32 100644
--- a/obmc/mapper/bindings.py
+++ b/obmc/mapper/bindings.py
@@ -58,13 +58,15 @@
path, interfaces, signature='sas'),
retries, interval)
- def get_subtree_paths(self, path='/', depth=0, retries=5, interfaces=[], interval=0.2):
+ def get_subtree_paths(
+ self, path='/', depth=0, retries=5, interfaces=[], interval=0.2):
return self.retry(
lambda: self.iface.GetSubTreePaths(
path, depth, interfaces, signature='sias'),
retries, interval)
- def get_subtree(self, path='/', depth=0, retries=5, interfaces=[], interval=0.2):
+ def get_subtree(
+ self, path='/', depth=0, retries=5, interfaces=[], interval=0.2):
return self.retry(
lambda: self.iface.GetSubTree(
path, depth, interfaces, signature='sias'),
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py
index 785d91d..0bbcf9f 100644
--- a/obmc/mapper/server.py
+++ b/obmc/mapper/server.py
@@ -469,7 +469,7 @@
def get_owner(name):
try:
return (name, self.bus.get_name_owner(name))
- except:
+ except Exception:
traceback.print_exception(*sys.exc_info())
if not owners:
@@ -541,14 +541,14 @@
# Remove interfaces from a service that
# aren't in a filter.
- svc_map = lambda svc: (
+ svc_map = def svc: (
svc[0],
list(set(ifaces).intersection(svc[1])))
# Remove services where no interfaces remain after mapping.
- svc_filter = lambda svc: svc[1]
+ svc_filter = def svc: svc[1]
- obj_map = lambda o: (
+ obj_map = def o: (
tuple(*filter(svc_filter, map(svc_map, [o]))))
return dict(filter(lambda x: x, map(obj_map, item.iteritems())))
@@ -557,7 +557,7 @@
if not ifaces:
return dict(item)
- obj_map = lambda x: (
+ obj_map = def x: (
x[0],
ObjectMapper.filter_interfaces(
x[1],
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..5fd2a3e
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[pycodestyle]
+max-line-length = 80