Server IP : 103.169.32.36 / Your IP : 216.73.217.13 Web Server : Apache System : Linux web.dpmptsp 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : apache ( 48) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python2.7/site-packages/slip/dbus/ |
Upload File : |
| Current File : /lib/python2.7/site-packages/slip/dbus/introspection.py |
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Classes and functions to easily access DBus introspection data."""
from xml.etree.ElementTree import ElementTree
from StringIO import StringIO
class IElemMeta(type):
"""Metaclass for introspection elements.
Sets elemname class member automatically from class name if not set
explicitly. Registers classes for their element names."""
elemnames_to_classes = {}
@classmethod
def clsname_to_elemname(cls, clsname):
elemname = ""
for c in clsname:
c_lower = c.lower()
if c_lower != c:
if len(elemname):
elemname += "_"
elemname += c_lower
return elemname
def __new__(cls, name, bases, dct):
if name == "IElem":
return type.__new__(cls, name, bases, dct)
if 'elemname' not in dct:
if not name.startswith("IElem"):
raise TypeError("Class '%s' needs to set elemname (or be "
"called 'IElem...'))" % name)
dct['elemname'] = IElemMeta.clsname_to_elemname(name[5:])
elemname = dct['elemname']
if elemname in IElemMeta.elemnames_to_classes:
raise TypeError("Class '%s' tries to register duplicate elemname "
"'%s'" % (name, elemname))
kls = type.__new__(cls, name, bases, dct)
IElemMeta.elemnames_to_classes[elemname] = kls
return kls
class IElem(object):
"""Base class for introspection elements."""
__metaclass__ = IElemMeta
def __new__(cls, elem, parent=None):
kls = IElemMeta.elemnames_to_classes.get(elem.tag,
IElemMeta.elemnames_to_classes[None])
return super(IElem, cls).__new__(kls, elem, parent)
def __init__(self, elem, parent=None):
self.elem = elem
self.parent = parent
self.child_elements = [ IElem(c, parent=self) for c in elem ]
def __str__(self):
s = "%s %r" % (self.elemname if self.elemname else "unknown:%s" %
self.elem.tag, self.attrib)
for c in self.child_elements:
for cc in str(c).split("\n"):
s+="\n %s" % (cc)
return s
@property
def attrib(self):
return self.elem.attrib
class IElemUnknown(IElem):
"""Catch-all for unknown introspection elements."""
elemname = None
class IElemNameMixin(object):
"""Mixin for introspection elements with names."""
@property
def name(self):
return self.attrib['name']
class IElemNode(IElem, IElemNameMixin):
"""Introspection node."""
def __init__(self, elem, parent=None):
super(IElemNode, self).__init__(elem, parent)
self.child_nodes = [ c for c in self.child_elements if isinstance(c, IElemNode) ]
class IElemInterface(IElem):
"""Introspection interface."""
class IElemMethod(IElem):
"""Introspection interface method."""
class IElemArg(IElem):
"""Introspection method argument."""
class IElemSignal(IElem, IElemNameMixin):
"""Introspection interface signal."""
def introspect(string_or_file):
tree = ElementTree()
# assume string if read() method doesn't exist, works for string, unicode,
# dbus.String
if not hasattr(string_or_file, "read"):
string_or_file = StringIO(string_or_file)
xml_root = tree.parse(string_or_file)
elem_root = IElem(xml_root)
return elem_root
| N4m3 |
5!z3 |
L45t M0d!f!3d |
0wn3r / Gr0up |
P3Rm!55!0n5 |
0pt!0n5 |
| .. |
-- |
December 20 2023 04:36:22 |
0 / 0 |
0755 |
|
| | | | | |
| __init__.py |
0.143 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| __init__.pyc |
0.355 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| __init__.pyo |
0.355 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| bus.py |
1.331 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| bus.pyc |
0.724 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| bus.pyo |
0.724 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| constants.py |
1.498 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| constants.pyc |
0.254 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| constants.pyo |
0.254 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| introspection.py |
3.374 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| introspection.pyc |
5.578 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| introspection.pyo |
5.578 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| mainloop.py |
3.325 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| mainloop.pyc |
3.826 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| mainloop.pyo |
3.826 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| polkit.py |
8.883 KB |
April 11 2018 01:48:59 |
0 / 0 |
0644 |
|
| polkit.pyc |
9.185 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| polkit.pyo |
8.928 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| proxies.py |
1.864 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| proxies.pyc |
1.489 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| proxies.pyo |
1.489 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| service.py |
7.873 KB |
March 08 2013 10:55:58 |
0 / 0 |
0644 |
|
| service.pyc |
6.591 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|
| service.pyo |
6.591 KB |
April 11 2018 01:49:00 |
0 / 0 |
0644 |
|