-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate to the last mpris2 python interface
- Loading branch information
Showing
38 changed files
with
1,330 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from . import Interfaces | ||
from . import MediaPlayer2 | ||
from . import Player | ||
from . import Playlists | ||
from . import TrackList | ||
|
||
|
||
if __name__ == '__main__': | ||
print(Interfaces()) | ||
print(MediaPlayer2()) | ||
print(Player()) | ||
print(Playlists()) | ||
print(TrackList()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
''' | ||
This is not part of specification | ||
Helper class to make it work as python lib | ||
''' | ||
|
||
|
||
from .attribute import DbusAttr | ||
from .interface import DbusInterface | ||
from .method import DbusMethod | ||
from .signal import DbusSignal | ||
from .utils import get_mainloop, get_uri, implements, \ | ||
list_all_interface, list_interfaces, list_paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from . import DbusAttr | ||
from . import DbusInterface | ||
from . import DbusMethod | ||
from . import DbusSignal | ||
|
||
if __name__ == '__main__': | ||
print(DbusAttr()) | ||
print(DbusInterface()) | ||
print(DbusMethod()) | ||
print(DbusSignal()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
''' | ||
This is not part of specification | ||
Helper class to make it work as python lib | ||
''' | ||
|
||
from .base import Decorator, ATTR_KEY | ||
|
||
|
||
class DbusAttr(Decorator): | ||
''' | ||
https://docs.python.org/2/howto/descriptor.html#properties | ||
''' | ||
|
||
def __init__(self, meth=None, produces=lambda resp: resp): | ||
self.attr = meth | ||
self.produces = produces | ||
self._update_me(meth) | ||
|
||
def __call__(self, meth): | ||
self.attr = meth | ||
self._update_me(meth) | ||
return self | ||
|
||
def __get__(self, obj, objtype=None): | ||
#static call | ||
if not obj: | ||
return self | ||
|
||
_dbus = getattr(obj, ATTR_KEY) | ||
props = _dbus.properties | ||
iface = _dbus.iface | ||
result = props.Get(iface, self.attr.__name__) | ||
produces = self.produces | ||
return produces(result) | ||
|
||
def __set__(self, obj, value): | ||
if obj: | ||
_dbus = getattr(obj, ATTR_KEY) | ||
props = _dbus.properties | ||
iface = _dbus.iface | ||
props.Set(iface, self.attr.__name__, value) | ||
else: #static call | ||
self.attr = value | ||
|
||
def __delete__(self, obj): | ||
raise AttributeError('can not delete attribute') | ||
|
||
|
||
if __name__ == '__main__': | ||
# examples | ||
from .interface import DbusInterface | ||
|
||
@DbusInterface('org.mpris.MediaPlayer2', | ||
'/org/mpris/MediaPlayer2') | ||
class Example(object): | ||
@DbusAttr | ||
def Identity(self): | ||
pass | ||
|
||
d = Example( | ||
dbus_interface_info={ | ||
'dbus_uri': 'org.mpris.MediaPlayer2.vlc'}) | ||
|
||
assert d.Identity == 'VLC media player' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
''' | ||
This is not part of specification | ||
Helper class to make it work as python lib | ||
''' | ||
|
||
I_PROP = 'org.freedesktop.DBus.Properties' | ||
ARG_KEY = 'dbus_interface_info' | ||
ATTR_KEY = '_dbus_interface_info' | ||
|
||
|
||
class Decorator(object): | ||
def _update_me(self, target=None): | ||
if hasattr(target, "__doc__"): | ||
self.__doc__ = target.__doc__ | ||
if hasattr(target, "__name__"): | ||
self.__name__ = target.__name__ | ||
if hasattr(target, "__bases__"): | ||
self.__bases__ = target.__bases__ |
Oops, something went wrong.