ldo / dbussy

Python binding for D-Bus using asyncio
91 stars 22 forks source link

How to strip signatures from arguments #35

Closed thoradia closed 3 years ago

thoradia commented 3 years ago

Hello, I am sure this issue has already been raised, but I could not find an existing solution Is there a way to strip all the signatures from arguments received from ravel? I need this to convert a python dbus program to ravel Thank you in advance for you reply

thoradia commented 3 years ago

In the meantime, I have written this:

import dbussy

def convert_dbussy(data):
    if isinstance(data, list):
        return [convert_dbussy(item) for item in data]
    if isinstance(data, dict):
        return {key: convert_dbussy(data[key]) for key in data.keys()}
    if isinstance(data, tuple) and isinstance(data[0], dbussy.DBUS.Signature):
        return convert_dbussy(data[1])
    return data
ldo commented 3 years ago

Is this for variant-type arguments? Remember, you will only see these where you specify a variant type in your signature.

thoradia commented 3 years ago

It is indeed for variant-type arguments of signals

ldo commented 3 years ago

In that case, the type information is useful. It tells you what type was sent by the requestor.

thoradia commented 3 years ago

That may well be, but the current code runs fine if I strip the signatures from the arguments I get with signals Thank you for your reply