Author: dmeyer
Date: Thu Mar 20 11:59:01 2008
New Revision: 3209

Log:
make it possible to override the progress class

Modified:
   trunk/base/src/notifier/coroutine.py
   trunk/base/src/notifier/thread.py
   trunk/base/test/progress.py

Modified: trunk/base/src/notifier/coroutine.py
==============================================================================
--- trunk/base/src/notifier/coroutine.py        (original)
+++ trunk/base/src/notifier/coroutine.py        Thu Mar 20 11:59:01 2008
@@ -98,6 +98,9 @@
     it has stop() and set_interval() member functions. If stop() is called,
     the InProgress object will emit the finished signal.
     """
+    if progress is True:
+        progress = InProgress.Progress
+
     def decorator(func):
         def newfunc(*args, **kwargs):
             def wrap(obj):
@@ -105,7 +108,7 @@
                     obj.progress = args[0]
                 return obj
             if progress:
-                args = [ InProgress.Progress(), ] + list(args)
+                args = [ progress(), ] + list(args)
             result = func(*args, **kwargs)
             if not hasattr(result, 'next'):
                 # Decorated function doesn't have a next attribute, which

Modified: trunk/base/src/notifier/thread.py
==============================================================================
--- trunk/base/src/notifier/thread.py   (original)
+++ trunk/base/src/notifier/thread.py   Thu Mar 20 11:59:01 2008
@@ -104,11 +104,14 @@
     the main thread.  (In this case, currently the priority kwarg is
     ignored.)
     """
+    if progress is True:
+        progress = InProgress.Progress
+
     def decorator(func):
 
         def newfunc(*args, **kwargs):
             if progress:
-                args = [ InProgress.Progress(), ] + list(args)
+                args = [ progress(), ] + list(args)
             if name is MAINTHREAD:
                 if not async and is_mainthread():
                     # Fast-path case: mainthread synchronous call from the 
mainthread

Modified: trunk/base/test/progress.py
==============================================================================
--- trunk/base/test/progress.py (original)
+++ trunk/base/test/progress.py Thu Mar 20 11:59:01 2008
@@ -21,6 +21,22 @@
     for i in range(20):
         progress.update()
         yield kaa.NotFinished
+
+def update3(progress):
+    sys.stdout.write('\r%s' % progress.values)
+    sys.stdout.flush()
+
+class MyProgress(kaa.Signal):
+    def __init__(self):
+        super(MyProgress, self).__init__()
+        self.values = []
+        
[EMAIL PROTECTED](interval=0.1, progress=MyProgress)
+def scan3(progress):
+    for i in range(20):
+        progress.values.append(i)
+        progress.emit(progress)
+        yield kaa.NotFinished
         
 @kaa.coroutine()
 def test():
@@ -32,6 +48,10 @@
     async.progress.connect(update)
     yield async
     print
+    async = scan3()
+    async.progress.connect(update3)
+    yield async
+    print
     sys.exit(0)
     
 test()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to