Author: dmeyer
Date: Tue Jan  8 13:47:11 2008
New Revision: 2960

Log:
move class Progress into InProgress

Modified:
   trunk/base/src/notifier/__init__.py
   trunk/base/src/notifier/async.py
   trunk/base/src/notifier/url.py

Modified: trunk/base/src/notifier/__init__.py
==============================================================================
--- trunk/base/src/notifier/__init__.py (original)
+++ trunk/base/src/notifier/__init__.py Tue Jan  8 13:47:11 2008
@@ -38,7 +38,7 @@
 from event import Event, EventHandler, WeakEventHandler
 from yieldfunc import YieldContinue, YieldCallback, YieldFunction, 
yield_execution
 from jobserver import ThreadCallback, execute_in_thread
-from async import Progress, InProgress
+from async import InProgress
 from decorators import execute_in_timer, execute_in_mainloop
 
 # Here's what will be imported into the kaa namespace.
@@ -57,9 +57,6 @@
     # FIXME: I don't like the following functions in the global kaa namespace
     'is_mainthread', 'wakeup',
     
-    # FIXME: this this needed somewhere? Maybe make it a subclass of InProgress
-    'Progress',
-
     # XXX: DEPRECATED wrappers From this module
     'init', 'shutdown', 'step', 'running', 'signals', 'loop'
 ]

Modified: trunk/base/src/notifier/async.py
==============================================================================
--- trunk/base/src/notifier/async.py    (original)
+++ trunk/base/src/notifier/async.py    Tue Jan  8 13:47:11 2008
@@ -29,7 +29,7 @@
 #
 # -----------------------------------------------------------------------------
 
-__all__ = [ 'Progress', 'InProgress' ]
+__all__ = [ 'InProgress' ]
 
 # python imports
 import logging
@@ -42,54 +42,6 @@
 log = logging.getLogger('notifier.async')
 
 
-class Progress(Signal):
-    """
-    Generic progress status object for InProgress. This object can be connected
-    to an InProgress object with set_status and the caller can monitor the
-    progress. The caller can read the current position (pos) of the maximum
-    (max) or the percentage of both (percentage).
-    """
-    def __init__(self):
-        super(Progress, self).__init__()
-        self.percentage = 0
-        self.pos = 0
-        self.max = 0
-
-
-    def set(self, pos, max=None):
-        """
-        Set new status. The new status is pos of max.
-        """
-        if max is not None:
-            self.max = max
-        self.pos = pos
-        if pos > self.max:
-            self.max = pos
-        if self.max:
-            self.percentage = (self.pos * 100) / self.max
-        else:
-            self.percentage = 0
-        self.emit()
-
-
-    def update(self, diff):
-        """
-        Update position by the given difference.
-        """
-        self.set(self.pos + diff)
-
-
-    def get_progressbar(self, width=70):
-        """
-        Return a small ASCII art progressbar.
-        """
-        n = 0
-        if self.max:
-            n = int((self.pos / float(self.max)) * (width-3))
-        s = '|%%%ss|' % (width-2)
-        return s % ("="*n + ">").ljust(width-2)
-
-
 class InProgress(Signal):
     """
     An InProgress class used to return from function calls
@@ -97,6 +49,54 @@
     to an object of this class like Signals. The memeber 'exception_handler'
     is a second signal to get notification of an exception raised later.
     """
+    class Progress(Signal):
+        """
+        Generic progress status object for InProgress. This object can be 
connected
+        to an InProgress object with set_status and the caller can monitor the
+        progress. The caller can read the current position (pos) of the maximum
+        (max) or the percentage of both (percentage).
+        """
+        def __init__(self):
+            super(Progress, self).__init__()
+            self.percentage = 0
+            self.pos = 0
+            self.max = 0
+    
+    
+        def set(self, pos, max=None):
+            """
+            Set new status. The new status is pos of max.
+            """
+            if max is not None:
+                self.max = max
+            self.pos = pos
+            if pos > self.max:
+                self.max = pos
+            if self.max:
+                self.percentage = (self.pos * 100) / self.max
+            else:
+                self.percentage = 0
+            self.emit()
+    
+    
+        def update(self, diff):
+            """
+            Update position by the given difference.
+            """
+            self.set(self.pos + diff)
+    
+    
+        def get_progressbar(self, width=70):
+            """
+            Return a small ASCII art progressbar.
+            """
+            n = 0
+            if self.max:
+                n = int((self.pos / float(self.max)) * (width-3))
+            s = '|%%%ss|' % (width-2)
+            return s % ("="*n + ">").ljust(width-2)
+    
+    
     def __init__(self):
         Signal.__init__(self)
         self.exception_handler = Signal()

Modified: trunk/base/src/notifier/url.py
==============================================================================
--- trunk/base/src/notifier/url.py      (original)
+++ trunk/base/src/notifier/url.py      Tue Jan  8 13:47:11 2008
@@ -46,7 +46,7 @@
 import urllib2
 
 # kaa.notifier imports
-from kaa.notifier import Thread, Signals, InProgress, Progress
+from kaa.notifier import Thread, Signals, InProgress
 
 # add password manager to urllib
 pm = urllib2.HTTPPasswordMgrWithDefaultRealm()
@@ -146,7 +146,7 @@
         # stupid url encoding in url
         url = url[:8+url[8:].find('/')] + \
               urllib.quote(url[8+url[8:].find('/'):])
-    s = Progress()
+    s = InProgress.Progress()
     t = Thread(download, url, filename, tmpname, s)
     t.wait_on_exit(False)
     async = t.start()

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to