Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkin committed Sep 28, 2016
1 parent 63f2eb6 commit 07e68b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion qubesdbus/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
try:
# Check for mypy dependencies pylint: disable=ungrouped-imports
from typing import Any, Optional, Union # pylint: disable=unused-import
from qubesdbus.service import _DbusServiceObject # pylint:disable=unused-import
except ImportError:
pass

Expand Down
8 changes: 7 additions & 1 deletion qubesdbus/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def GetManagedObjects(self):


class DbusServiceObject(dbus.service.Object):
''' A class implementing a useful shortcut for writing own D-Bus Services
'''
def __init__(self, bus=None, bus_name=None, bus_path=None):
# type: (SessionBus, BusName, str) -> None
if bus is not None:
Expand All @@ -83,12 +85,13 @@ def __init__(self, bus=None, bus_name=None, bus_path=None):
_name = ''.join([NAME_PREFIX, '.', self.__class__.__name__,
str(VERSION)])
self.bus_name = dbus.service.BusName(_name, self.bus)
# avoid pylint super-on-old-class error
# avoid pylint super-on-old-class error
dbus.service.Object.__init__(self, self.bus_name, self.bus_path)


class PropertiesObject(DbusServiceObject):
# pylint: disable=invalid-name
''' Implements `org.freedesktop.DBus.Properties` interface. '''

def __init__(self, name, iface, data, *args, **kwargs):
self.properties = data
Expand All @@ -103,10 +106,12 @@ def __init__(self, name, iface, data, *args, **kwargs):

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def Get(self, _, property_name):
''' Returns the property value '''
return self.properties[property_name]

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def GetAll(self, _):
''' Returns all properties and their values '''
# According to the dbus spec we should be able to return types not only
# string, but it doesn't work. We need to serialize everything to string
# ☹
Expand All @@ -115,6 +120,7 @@ def GetAll(self, _):

@dbus.service.method(dbus_interface="org.freedesktop.DBus.Properties")
def Set(self, _, name, value): # type: (str, dbus.String, Any) -> None
''' Set a property value '''
new_value = value
old_value = self.properties[name]
if new_value == old_value:
Expand Down

0 comments on commit 07e68b3

Please sign in to comment.