PEP 8 fixes
Added E402 to the ignore errors list.
E402 is "module level import not at top of file"
and ignoring since settings_manager.py needs to modify
the sys.path before importing certain modules.
Since the default ignore list is not used anymore,
rules E121,E123,E126,E226,E24,E704,W503 are now enforced.
Looking at those rules, I believe we should enforce them.
Note E121,E123,E126,E226,E24,E704,W503 are all in the default
ignore list, so if no ignore list is provided in the
setup.cfg these errors are ignored.
from pycodestyle --help
--ignore=errors skip errors and warnings (e.g. E4,W) (default:
E121,E123,E126,E226,E24,E704,W503)
Change-Id: I0f64535eb4b4ba471466c8c9c3dbda1f8b33f702
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/settings_manager.py b/settings_manager.py
index 134bc6d..d778978 100644
--- a/settings_manager.py
+++ b/settings_manager.py
@@ -22,7 +22,8 @@
DBUS_NAME = 'org.openbmc.settings.Host'
CONTROL_INTF = 'org.openbmc.Settings'
-def walk_nest(d, keys =()):
+
+def walk_nest(d, keys=()):
"""Arrange dictionary keys and values.
Walk the dictionary and establish every possible path
@@ -35,6 +36,7 @@
else:
yield keys, d
+
def create_object(settings):
"""Create and format objects.
@@ -47,10 +49,10 @@
queries = {}
for compound_key, val in walk_nest(settings):
obj_name = compound_key[0].lower()
- obj_name = obj_name.replace(".","/")
+ obj_name = obj_name.replace(".", "/")
obj_name = "/" + obj_name + "0"
- for i in compound_key[2:len(compound_key)-2]:
+ for i in compound_key[2:len(compound_key) - 2]:
obj_name = obj_name + "/" + i
setting = compound_key[len(compound_key) - 2]
@@ -83,6 +85,7 @@
"/org/openbmc/settings/" + m.group(1), settings)
return allobjects
+
class HostSettingsObject(DbusProperties, DbusObjectManager):
def __init__(self, bus, name, settings, path):
super(HostSettingsObject, self).__init__(
@@ -93,7 +96,7 @@
self.path = path
self.name = name
self.settings = settings
- self.fname = name[name.rfind("/")+1:] + '-'
+ self.fname = name[name.rfind("/") + 1:] + '-'
# Needed to ignore the validation on default networkconfig values as
# opposed to user giving the same.
@@ -247,7 +250,7 @@
self.validate_list(shk['allowed'], value)
elif validation == 'range':
- self.validate_range(shk['min'], shk['max']+1, value)
+ self.validate_range(shk['min'], shk['max'] + 1, value)
elif validation == 'regex':
self.validate_regex(shk['regex'], value)
@@ -255,6 +258,7 @@
elif validation == 'custom':
getattr(self, shk['method'])(value)
+
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)