diff options
author | anishmangal2002 <anishmangal2002@gmail.com> | 2010-05-20 19:45:49 (GMT) |
---|---|---|
committer | anishmangal2002 <anishmangal2002@gmail.com> | 2010-05-20 19:45:49 (GMT) |
commit | ee64655f6a54a98adfa1eab832210a082d47945e (patch) | |
tree | 56427bb5a414005985cc1f79aba7a2b0f47e09c0 /groupthink/dbus_tools.py | |
parent | c1f8d644fc2551acd39317f3554c2cb4c23c770d (diff) |
Replaced groupthink symbolic link with actual folder.v36
Diffstat (limited to 'groupthink/dbus_tools.py')
-rw-r--r-- | groupthink/dbus_tools.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/groupthink/dbus_tools.py b/groupthink/dbus_tools.py new file mode 100644 index 0000000..423e51a --- /dev/null +++ b/groupthink/dbus_tools.py @@ -0,0 +1,26 @@ +import dbus + +inttypes = (dbus.Int16, dbus.Int32, dbus.Int64, + dbus.Byte, dbus.UInt16, dbus.UInt32, dbus.UInt64) +booltypes = (dbus.Boolean) +floattypes = (dbus.Double) +strtypes = (dbus.ByteArray, dbus.String, dbus.UTF8String, dbus.Signature, + dbus.ObjectPath) + +def undbox(x): + if isinstance(x, inttypes): + return int(x) + elif isinstance(x, booltypes): + return bool(x) + elif isinstance(x, strtypes): + return str(x) + elif isinstance(x, floattypes): + return float(x) + elif isinstance(x, (dbus.Struct, tuple)): + return tuple(undbox(y) for y in x) + elif isinstance(x, (dbus.Array, list)): + return [undbox(y) for y in x] + elif isinstance(x, (dbus.Dictionary, dict)): + return dict((undbox(a),undbox(b)) for (a,b) in x.iteritems()) + else: + return x |