r245 - branches/rewrite/src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Wed, 22 Sep 2004 10:05:18 -0600


Author: otavio
Date: Wed Sep 22 10:05:17 2004
New Revision: 245

Modified:
   branches/rewrite/src/DisplayInfo.py
Log:
Refactory for better organization and access control.

Modified: branches/rewrite/src/DisplayInfo.py
==============================================================================
--- branches/rewrite/src/DisplayInfo.py	(original)
+++ branches/rewrite/src/DisplayInfo.py	Wed Sep 22 10:05:17 2004
@@ -19,16 +19,20 @@
 import sys
 import os
 
-class DisplayInfo:
-    info_windows = []
+class BaseDisplayInfo:
+    _info_windows = []
 
     def add(self, window):
         if window not in self.info_windows:
-            self.info_windows.append(window)
+            self._info_windows.append(window)
             
     def refresh(self):
+        map(lambda x: x.refresh(), self._info_windows)
+
+class TextDisplayInfo(BaseDisplayInfo):
+    def refresh(self):
         sys.stdout.write('\r')
-        map(lambda x: x.refresh(), self.info_windows)
+        DisplayInfo.refresh(self)
 
 class TextProgressBar:
     def __init__(self, min=0, max=100, text=''):
@@ -41,4 +45,5 @@
         sys.stdout.write("[ %.2f%% %s]" % (self.current*100/(self.max - self.min), os.path.basename(self.text).split('_')[0]))
         sys.stdout.flush()
 
+DisplayInfo = TextDisplayInfo
 ProgressBar = TextProgressBar