diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-25 11:56:13 -0400 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-25 11:56:13 -0400 |
commit | b61ab7fcf14bee53db60376f9130b2b8ee58be94 (patch) | |
tree | 406b46d9c5858c6d72e525cc43630c1cecfaa077 /phosphor-mapper | |
parent | 067db7287a647789e7d5d5dbccc514c5c835a944 (diff) | |
download | phosphor-objmgr-b61ab7fcf14bee53db60376f9130b2b8ee58be94.tar.gz phosphor-objmgr-b61ab7fcf14bee53db60376f9130b2b8ee58be94.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: Ie0dab2118c4d9ad97f47ef83a5b68ad82e5f9dd2
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'phosphor-mapper')
-rw-r--r-- | phosphor-mapper | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/phosphor-mapper b/phosphor-mapper index d44e8f6..e1f3635 100644 --- a/phosphor-mapper +++ b/phosphor-mapper @@ -38,53 +38,53 @@ class MapperNotFoundException(dbus.exceptions.DBusException): 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: @@ -92,14 +92,14 @@ 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) class Association(dbus.service.Object): |