summaryrefslogtreecommitdiffstats
path: root/settings_manager.py
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-01-27 10:02:34 -0600
committerGunnar Mills <gmills@us.ibm.com>2018-01-31 12:02:31 -0600
commita16abc5aa2d30b9605e30ffd6bbe3aa05585ae87 (patch)
treeab2946747d427994c7c3ddfe7d671798dd9b3525 /settings_manager.py
parenta29a3eb71fed0e17d60dcbb16a32ba7e6a70b852 (diff)
downloadphosphor-settingsd-a16abc5aa2d30b9605e30ffd6bbe3aa05585ae87.tar.gz
phosphor-settingsd-a16abc5aa2d30b9605e30ffd6bbe3aa05585ae87.zip
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>
Diffstat (limited to 'settings_manager.py')
-rw-r--r--settings_manager.py14
1 files changed, 9 insertions, 5 deletions
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 @@ import obmc.mapper
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 @@ def walk_nest(d, keys =()):
else:
yield keys, d
+
def create_object(settings):
"""Create and format objects.
@@ -47,10 +49,10 @@ def create_object(settings):
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 @@ def create_object(settings):
"/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 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
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 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
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 @@ class HostSettingsObject(DbusProperties, DbusObjectManager):
elif validation == 'custom':
getattr(self, shk['method'])(value)
+
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
OpenPOWER on IntegriCloud