r236 - branches/rewrite/src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Tue, 21 Sep 2004 21:01:52 -0600


Author: otavio
Date: Tue Sep 21 21:01:52 2004
New Revision: 236

Added:
   branches/rewrite/src/DisplayInfo.py   (contents, props changed)
Log:
Add initial draft.

Added: branches/rewrite/src/DisplayInfo.py
==============================================================================
--- (empty file)
+++ branches/rewrite/src/DisplayInfo.py	Tue Sep 21 21:01:52 2004
@@ -0,0 +1,41 @@
+# debpartial-mirror - partial debian mirror package tool
+# (c) 2004 Otavio Salvador <otavio@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# $Id$
+
+import sys
+
+class DisplayInfo:
+    info_windows = []
+    
+    def add(self, window):
+        if window not in self.info_windows:
+            self.info_windows.append(window)
+            
+    def refresh(self):
+        map(lambda x: x.refresh(), self.info_windows)
+
+class TextProgressBar:
+    def __init__(self, min=0, max=100, text=''):
+        self.min = min
+        self.max = max
+        self.text = text
+        self.current = min
+
+    def refresh(self):
+        sys.stdout.write("[ %.2f%% %s]\r" % (100*(self.current/(self.max - self.min)), self.text))
+
+ProgressBar = TextProgressBar