[PATCH phosphor-rest-server 3/3] Remove redundant makelist and search functions
OpenBMC Patches
openbmc-patches at stwcx.xyz
Tue Apr 19 02:20:48 AEST 2016
From: Brad Bishop <bradleyb at us.ibm.com>
Use the functions in the new pyphosphor library.
---
obmc-rest | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/obmc-rest b/obmc-rest
index 226b1b7..357b28e 100644
--- a/obmc-rest
+++ b/obmc-rest
@@ -69,27 +69,14 @@ class UserInGroup:
abort(403, 'Insufficient access')
-def find_case_insensitive(value, lst):
- return next((x for x in lst if x.lower() == value.lower()), None)
-
-
-def makelist(data):
- if isinstance(data, list):
- return data
- elif data:
- return [data]
- else:
- return []
-
-
class RouteHandler(object):
- _require_auth = makelist(valid_user)
+ _require_auth = obmc.utils.makelist(valid_user)
def __init__(self, app, bus, verbs, rules):
self.app = app
self.bus = bus
self.mapper = obmc.mapper.Mapper(bus)
- self._verbs = makelist(verbs)
+ self._verbs = obmc.utils.makelist(verbs)
self._rules = rules
self.intf_match = obmc.utils.misc.org_dot_openbmc_match
@@ -240,7 +227,7 @@ class MethodHandler(RouteHandler):
if methods is None:
return None
- method = find_case_insensitive(method, methods.keys())
+ method = obmc.utils.find_case_insensitive(method, methods.keys())
if method is not None:
iface = dbus.Interface(obj, interface)
return iface.get_dbus_method(method)
@@ -318,7 +305,7 @@ class PropertyHandler(RouteHandler):
properties = self.try_properties_interface(iface.GetAll, i)
if properties is None:
continue
- prop = find_case_insensitive(prop, properties.keys())
+ prop = obmc.utils.find_case_insensitive(prop, properties.keys())
if prop is None:
continue
return prop, i
--
2.7.1
More information about the openbmc
mailing list