def convert(dbus_obj):
_isinstance = partial(isinstance, dbus_obj)<EOL>ConvertType = namedtuple('<STR_LIT>', '<STR_LIT>')<EOL>pyint = ConvertType(int, (dbus.Byte, dbus.Int16, dbus.Int32, dbus.Int64,<EOL>dbus.UInt16, dbus.UInt32, dbus.UInt64))<EOL>pybool = ConvertType(bool, (dbus.Boolean, ))<EOL>pyfloat = ConvertType(float, (dbus.Double, ))<EOL>pylist = ConvertType(lambda _obj: list(map(convert, dbus_obj)),<EOL>(dbus.Array, ))<EOL>pytuple = ConvertType(lambda _obj: tuple(map(convert, dbus_obj)),<EOL>(dbus.Struct, ))<EOL>types_str = (dbus.ObjectPath, dbus.Signature, dbus.String)<EOL>if not PY3:<EOL><INDENT>types_str += (dbus.UTF8String,)<EOL><DEDENT>pystr = ConvertType(str if PY3 else unicode, types_str)<EOL>pydict = ConvertType(<EOL>lambda _obj: dict(zip(map(convert, dbus_obj.keys()),<EOL>map(convert, dbus_obj.values())<EOL>)<EOL>),<EOL>(dbus.Dictionary, )<EOL>)<EOL>for conv in (pyint, pybool, pyfloat, pylist, pytuple, pystr, pydict):<EOL><INDENT>if any(map(_isinstance, conv.dbustypes)):<EOL><INDENT>return conv.pytype(dbus_obj)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return dbus_obj<EOL><DEDENT>
Converts dbus_obj from dbus type to python type.

    :param dbus_obj: dbus object.
    :returns: dbus_obj in python type.