Commit e36d0394 authored by Olivier Aubert's avatar Olivier Aubert
Browse files add documentation

parent 3a1a4609
...@@ -8,6 +8,10 @@ class VLCObject(object): ...@@ -8,6 +8,10 @@ class VLCObject(object):
object.__setattr__(self, '_o', vlc.Object(id)) object.__setattr__(self, '_o', vlc.Object(id))
def find(self, typ): def find(self, typ):
"""Returns a VLCObject for the given child.
See vlc.Object.find_object.__doc__ for the different values of typ.
t=self._o.find_object(typ) t=self._o.find_object(typ)
if t is not None: if t is not None:
return VLCObject(['object-id']) return VLCObject(['object-id'])
...@@ -15,13 +19,16 @@ class VLCObject(object): ...@@ -15,13 +19,16 @@ class VLCObject(object):
return None return None
def __str__(self): def __str__(self):
"""Returns a string representation of the object.
return "VLCObject %d (%s) : %s" % (i['object-id'], return "VLCObject %d (%s) : %s" % (i['object-id'],
i['object-type'], i['object-type'],
i['object-name']) i['object-name'])
def tree(self, prefix=" "): def tree(self, prefix=" "):
"""Displays the children as a tree.""" """Displays all children as a tree of VLCObject
print prefix, self print prefix, self
for i in self._o.children(): for i in self._o.children():
t=VLCObject(i) t=VLCObject(i)
...@@ -29,8 +36,10 @@ class VLCObject(object): ...@@ -29,8 +36,10 @@ class VLCObject(object):
return return
def __getattribute__(self, attr): def __getattribute__(self, attr):
#print "Getting %s" % attr """Converts attribute access to access to variables.
if attr == '__members__': if attr == '__members__':
# Return the list of variables
o=object.__getattribute__(self, '_o') o=object.__getattribute__(self, '_o')
l=dir(o) l=dir(o)
l.extend([ n.replace('-','_') for n in o.list() ]) l.extend([ n.replace('-','_') for n in o.list() ])
...@@ -48,19 +57,20 @@ class VLCObject(object): ...@@ -48,19 +57,20 @@ class VLCObject(object):
raise e raise e
def __setattr__(self, name, value): def __setattr__(self, name, value):
"""Handle attribute assignment.
n=name.replace('_', '-') n=name.replace('_', '-')
if n in self._o.list(): if n in self._o.list():
self._o.set(n, value) self._o.set(n, value)
else: else:
object.__setattr__(self, name, value) object.__setattr__(self, name, value)
#mc=vlc.MediaControl() def test(f='/tmp/k.mpg'):
def test():
global mc,o global mc,o
mc=vlc.MediaControl() mc=vlc.MediaControl()
mc.playlist_add_item('/tmp/k.mpg') mc.playlist_add_item(f)
mc.start(0) mc.start(0)
o=VLCObject(0) o=VLCObject(0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment