Update gdbus.py

This commit is contained in:
Pascal Vizeli 2018-04-24 15:40:14 +02:00 committed by GitHub
parent 6f770b78af
commit 7363951a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,18 @@
import asyncio
import logging
import shlex
import re
import xml.etree.ElementTree as ET
from ..exceptions import DBusFatalError, DBusParseError
_LOGGER = logging.getLogger(__name__)
RE_GVARIANT_TULPE = re.compile(r"^\((.*),\)$")
RE_GVARIANT_VARIANT = re.compile(
r"(?<=(?: |{|\[))<((?:'|\").*?(?:'|\")|\d+(?:\.\d+)?)>(?=(?:|]|}|,))")
RE_GVARIANT_STRING = re.compile(r"(?<=(?: |{|\[))'(.*?)'(?=(?:|]|}|,))")
INTROSPECT = ("gdbus introspect --system --dest {bus} "
"--object-path {obj} --xml")
CALL = ("gdbus call --system --dest {bus} --object-path {inf} "
@ -60,6 +66,7 @@ class DBus:
@staticmethod
def _gvariant(raw):
"""Parse GVariant input to python."""
raw = RE_GVARIANT_TULPE.sub(r"[\1]", raw)
return raw
async def call_dbus(self, interface, method, *args):