diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2016-04-15 13:09:39 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@us.ibm.com> | 2016-04-24 18:15:24 -0400 |
commit | 6d190605f6170bdbf6c3c9fdd5d278d7c7f5084e (patch) | |
tree | 8239f4fc49b61a3126a678220c70c14d9344a119 | |
parent | f4e7498892c883837a706e6a3cff454188db06a4 (diff) | |
download | phosphor-rest-server-6d190605f6170bdbf6c3c9fdd5d278d7c7f5084e.tar.gz phosphor-rest-server-6d190605f6170bdbf6c3c9fdd5d278d7c7f5084e.zip |
Remove redundant makelist and search functions
Use the functions in the new pyphosphor library.
-rw-r--r-- | obmc-rest | 21 |
1 files changed, 4 insertions, 17 deletions
@@ -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.misc.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.misc.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.misc.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.misc.find_case_insensitive(prop, properties.keys()) if prop is None: continue return prop, i |