[vlc-commits] commit: fixed getargspec and _callbacks underscores (Jean Brouwers )

git at videolan.org git at videolan.org
Wed Dec 8 21:41:33 CET 2010


vlc/python | branch: master | Jean Brouwers <MrJean1 at Gmail.com> | Tue Dec  7 21:35:46 2010 -0800| [83372674e7b3a04387c35ab3c7721cb0b3bef3ed] | committer: Olivier Aubert 

fixed getargspec and _callbacks underscores

Signed-off-by: Olivier Aubert <olivier.aubert at liris.cnrs.fr>

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=83372674e7b3a04387c35ab3c7721cb0b3bef3ed
---

 header.py   |    5 +----
 override.py |   13 ++++++-------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/header.py b/header.py
index a226154..6044541 100755
--- a/header.py
+++ b/header.py
@@ -42,10 +42,7 @@ import os
 import sys
 
 # Used by EventManager in override.py
-try:
-    from inspect import getargspec
-except ImportError:
-    getargspec = None
+from inspect import getargspec
 
 build_date  = ''  # build time stamp and __version__, see generate.py
 
diff --git a/override.py b/override.py
index 5e6aa49..762ea54 100644
--- a/override.py
+++ b/override.py
@@ -284,8 +284,7 @@ class EventManager:
     @note: Only a single notification can be registered
     for each event type in an EventManager instance.
     """
-    _callback_handler_ = None
-    _callbacks_ = {}
+    _callbacks = {}
 
     def __new__(cls, ptr=None):
         if ptr is None:
@@ -312,7 +311,7 @@ class EventManager:
         if not hasattr(callback, '__call__'):  # callable()
             raise VLCException("%s required: %r" % ('callable', callback))
          # check that the callback expects arguments
-        if getargspec and not any(getargspec(callback)[:2]):  # list(...)
+        if not any(getargspec(callback)[:2]):  # list(...)
             raise VLCException("%s required: %r" % ('argument', callback))
 
         if self._callback_handler is None:
@@ -326,7 +325,7 @@ class EventManager:
                 first parameter, hence this closure.
                 """
                 try: # retrieve Python callback and arguments
-                    call, args, kwds = self._callbacks_[k]
+                    call, args, kwds = self._callbacks[k]
                      # deref event.contents to simplify callback code
                     call(event.contents, *args, **kwds)
                 except KeyError:  # detached?
@@ -349,6 +348,6 @@ class EventManager:
             raise VLCException("%s required: %r" % ('EventType', eventtype))
 
         k = eventtype.value
-        if k in self._callbacks_:
-            del self._callbacks_[k] # remove, regardless of libvlc return value
-            libvlc_event_detach(self, eventtype, self._callback_handler_, k)
+        if k in self._callbacks:
+            del self._callbacks[k] # remove, regardless of libvlc return value
+            libvlc_event_detach(self, eventtype, self._callback_handler, k)



More information about the vlc-commits mailing list