diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-06-28 16:30:43 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-06-28 17:53:13 -0400 |
commit | 737ea4074848651e8afbedca0125f776575acff1 (patch) | |
tree | 4489c065f019207c258ad91a1d899de8f5cb42a1 /obmc/dbuslib | |
parent | c66de7631fb6ae19e85993ff9afa78e868b43941 (diff) | |
download | pyphosphor-737ea4074848651e8afbedca0125f776575acff1.tar.gz pyphosphor-737ea4074848651e8afbedca0125f776575acff1.zip |
Remove name mangling from find_dbus_interfaces
Double underscore in Python mangles names and sometimes is
used as a way to make things private; however, in general
this isn't considered best practice and there isn't a compelling
reason for it here.
Rather, the convention for denoting a private interface is
to use a single leading underscore.
For more information:
http://www.artima.com/weblogs/viewpost.jsp?thread=211430
Change-Id: Id42b0dc670dc1f90ed52f38ac98a82ff8214ee47
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'obmc/dbuslib')
-rw-r--r-- | obmc/dbuslib/introspection.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/obmc/dbuslib/introspection.py b/obmc/dbuslib/introspection.py index 26f0555..ec252c6 100644 --- a/obmc/dbuslib/introspection.py +++ b/obmc/dbuslib/introspection.py @@ -137,53 +137,53 @@ class IntrospectionParser: def find_dbus_interfaces(conn, service, path, match): - class __FindInterfaces(object): + class _FindInterfaces(object): def __init__(self): self.results = {} @staticmethod - def __introspect(service, path): + def _introspect(service, path): obj = conn.get_object(service, path, introspect=False) iface = dbus.Interface(obj, dbus.INTROSPECTABLE_IFACE) return iface.Introspect() @staticmethod - def __get_managed_objects(service, om): + def _get_managed_objects(service, om): obj = conn.get_object(service, om, introspect=False) iface = dbus.Interface( obj, dbus.BUS_DAEMON_IFACE + '.ObjectManager') return iface.GetManagedObjects() @staticmethod - def __to_path(elements): + def _to_path(elements): return '/' + '/'.join(elements) @staticmethod - def __to_path_elements(path): + def _to_path_elements(path): return filter(bool, path.split('/')) def __call__(self, service, path): self.results = {} - self.__find_interfaces(service, path) + self._find_interfaces(service, path) return self.results @staticmethod - def __match(iface): + def _match(iface): return iface == dbus.BUS_DAEMON_IFACE + '.ObjectManager' \ or match(iface) - def __find_interfaces(self, service, path): - path_elements = self.__to_path_elements(path) - path = self.__to_path(path_elements) - root = ET.fromstring(self.__introspect(service, path)) + def _find_interfaces(self, service, path): + path_elements = self._to_path_elements(path) + path = self._to_path(path_elements) + root = ET.fromstring(self._introspect(service, path)) ifaces = filter( - self.__match, + self._match, [x.attrib.get('name') for x in root.findall('interface')]) self.results[path] = ifaces if dbus.BUS_DAEMON_IFACE + '.ObjectManager' in ifaces: - objs = self.__get_managed_objects(service, path) + objs = self._get_managed_objects(service, path) for k, v in objs.iteritems(): self.results[k] = v else: @@ -191,11 +191,11 @@ def find_dbus_interfaces(conn, service, path, match): bool, [x.attrib.get('name') for x in root.findall('node')]) children = [ - self.__to_path( - path_elements + self.__to_path_elements(x)) + self._to_path( + path_elements + self._to_path_elements(x)) for x in sorted(children)] for child in children: if child not in self.results: - self.__find_interfaces(service, child) + self._find_interfaces(service, child) - return __FindInterfaces()(service, path) + return _FindInterfaces()(service, path) |