gget r104 - trunk/gget



Author: johans
Date: Thu Aug 21 11:45:08 2008
New Revision: 104
URL: http://svn.gnome.org/viewvc/gget?rev=104&view=rev

Log:
Finished refactoring/name changing. Module names should confirm to PEP 8 now.

Added:
   trunk/gget/download.py
      - copied unchanged from r103, /trunk/gget/Download.py
Removed:
   trunk/gget/Download.py
Modified:
   trunk/gget/Makefile.am
   trunk/gget/dbus_service.py
   trunk/gget/dialogs.py
   trunk/gget/download_list.py
   trunk/gget/download_manager.py
   trunk/gget/window.py

Modified: trunk/gget/Makefile.am
==============================================================================
--- trunk/gget/Makefile.am	(original)
+++ trunk/gget/Makefile.am	Thu Aug 21 11:45:08 2008
@@ -4,7 +4,7 @@
 	config.py		\
 	dbus_service.py		\
 	dialogs.py		\
-	Download.py		\
+	download.py		\
 	download_list.py	\
 	download_manager.py	\
 	gui.py			\

Modified: trunk/gget/dbus_service.py
==============================================================================
--- trunk/gget/dbus_service.py	(original)
+++ trunk/gget/dbus_service.py	Thu Aug 21 11:45:08 2008
@@ -22,9 +22,9 @@
 
 import gtk.gdk
 
-import Download
 import config
 import dialogs
+import download
 import utils
 from gget import NAME
 
@@ -243,7 +243,7 @@
         r["uri"] = self.download.uri
         r["path"] = self.download.path
         r["file"] = self.download.file_name
-        r["status"] = Download.STATUS_STRINGS[self.download.status]
+        r["status"] = download.STATUS_STRINGS[self.download.status]
         r["mime-type"] = self.download.mime_type
         r["total size"] = str(self.download.total_size)
         r["date started"] = self.download.get_date_str("started")

Modified: trunk/gget/dialogs.py
==============================================================================
--- trunk/gget/dialogs.py	(original)
+++ trunk/gget/dialogs.py	Thu Aug 21 11:45:08 2008
@@ -29,9 +29,10 @@
 import gnome.ui
 
 import config
+import download
 import gui
-import Download
 import utils
+from download import COMPLETED
 from download_list import DownloadList
 from download_manager import DownloadManager
 from status_icon import TrayIcon
@@ -204,7 +205,7 @@
                     download.current_size))
 
     def __download_status_changed(self, download, status):
-        if status == Download.COMPLETED:
+        if status == COMPLETED:
             self.date_completed_label.set_text(download.get_date_str("completed"))
 
     def __close_button_clicked(self, button):

Modified: trunk/gget/download_list.py
==============================================================================
--- trunk/gget/download_list.py	(original)
+++ trunk/gget/download_list.py	Thu Aug 21 11:45:08 2008
@@ -25,8 +25,8 @@
 import gobject
 
 import config
-import Download
 import utils
+from download import Download, DATE_FORMAT_DIGIT, CONNECTING, DOWNLOADING, COMPLETED
 
 XML_HEADER = '<?xml version="1.0" encoding="UTF-8" ?>\n'
 DOWNLOADS_FILE = "downloads.xml"
@@ -70,12 +70,11 @@
                 date_started = download_element.findtext("date_started")
                 date_completed = download_element.findtext("date_completed")
 
-                download = Download.Download(uri, path, date_started,
-                        date_completed)
+                download = Download(uri, path, date_started, date_completed)
                 download.file_name = file_name
                 download.total_size = int(total_size)
                 download.status = int(status)
-                if download.status == Download.COMPLETED:
+                if download.status == COMPLETED:
                     download.percent_complete = 100
                 else:
                     download.percent_complete = 100 * download.current_size / download.total_size
@@ -94,7 +93,7 @@
         if path is None:
             path = self.config.default_folder
 
-        download = Download.Download(uri, path)
+        download = Download(uri, path)
         self.__append_download(download)
         self.__add_download_to_xml(download)
         return download
@@ -125,11 +124,11 @@
         status_element.text = str(download.status)
         date_started_element = ET.SubElement(download_element, "date_started")
         date_started_element.text = download.get_date_str("started",
-                Download.DATE_FORMAT_DIGIT)
+                DATE_FORMAT_DIGIT)
         date_completed_element = ET.SubElement(download_element,
                                                "date_completed")
         date_completed_element.text = download.get_date_str("completed",
-                Download.DATE_FORMAT_DIGIT)
+                DATE_FORMAT_DIGIT)
 
         self.__save_xml()
 
@@ -150,11 +149,13 @@
         download_element = self.__get_download_element(download)
         if download_element:
             status_element = download_element.find("status")
-            status_element.text = str(status)
-            if status == Download.COMPLETED:
+            if status_element:
+                status_element.text = str(status)
+            if status == COMPLETED:
                 date_completed = download_element.find("date_completed")
-                date_completed.text = download.get_date_str("completed",
-                        Download.DATE_FORMAT_DIGIT)
+                if date_completed:
+                    date_completed.text = download.get_date_str("completed",
+                            DATE_FORMAT_DIGIT)
             self.__save_xml()
 
     def __get_download_element(self, download):
@@ -192,14 +193,14 @@
         """Removes all completed downloads in the list (and xml tree)."""
         downloads = list(self.downloads)
         for download in downloads:
-            if download.status == Download.COMPLETED:
+            if download.status == COMPLETED:
                 self.remove_download(download)
 
     def has_active_downloads(self):
         """Checks if there are any active downloads in progress."""
         downloads = list(self.downloads)
         for download in downloads:
-            if download.status in [Download.CONNECTING, Download.DOWNLOADING]:
+            if download.status in [CONNECTING, DOWNLOADING]:
                 return True
         return False
 

Modified: trunk/gget/download_manager.py
==============================================================================
--- trunk/gget/download_manager.py	(original)
+++ trunk/gget/download_manager.py	Thu Aug 21 11:45:08 2008
@@ -29,8 +29,8 @@
 import metalink
 
 import config
-import Download
 import utils
+from download import CONNECTING, DOWNLOADING, CANCELED, COMPLETED, ERROR
 from download_list import DownloadList
 from gget import NAME, VERSION
 
@@ -104,14 +104,14 @@
         download if its not already completed."""
         download.connect("status-changed", self.__status_changed)
 
-        if not download.status in [Download.COMPLETED, Download.CANCELED]:
+        if not download.status in [COMPLETED, CANCELED]:
             self.start_download(download)
 
     def __status_changed(self, download, status):
         """Called when the status of a download changes. If a canceled download
         is resumed we need to start the download again."""
-        if status == Download.DOWNLOADING and \
-           download.old_status == Download.CANCELED:
+        if status == DOWNLOADING and \
+           download.old_status == CANCELED:
             self.start_download(download)
 
     def start_download(self, download):
@@ -125,8 +125,8 @@
         # in a thread, see http://spyced.blogspot.com/2007/06/workaround-for-sysexcepthook-bug.html
         # sys.excepthook(*sys.exc_info())
 
-        if download.status in [-1, Download.DOWNLOADING]:
-            download.set_status(Download.CONNECTING)
+        if download.status in [-1, DOWNLOADING]:
+            download.set_status(CONNECTING)
         try:
             result = metalink.get(download.uri, download.path,
                     handlers={"status": download.update,
@@ -135,7 +135,7 @@
                               "pause": download.is_paused})
 
             if not result:
-                download.set_status(Download.ERROR)
+                download.set_status(ERROR)
                 print "Failed downloading of file %s" % download.uri
 
         except Exception, e:

Modified: trunk/gget/window.py
==============================================================================
--- trunk/gget/window.py	(original)
+++ trunk/gget/window.py	Thu Aug 21 11:45:08 2008
@@ -30,9 +30,10 @@
 import gnome.ui
 
 import config
-import Download
+import download
 import gui
 import utils
+from download import CONNECTING, DOWNLOADING, PAUSED, CANCELED, COMPLETED
 from dialogs import AboutDialog, AddDownloadDialog, DetailsDialog, ErrorDialog, PreferencesDialog, QuitDialog
 from gget import NAME
 
@@ -500,12 +501,12 @@
             has_paused = has_canceled = has_active = False
             if downloads:
                 for download in downloads:
-                    if download.status == Download.PAUSED:
+                    if download.status == PAUSED:
                         has_paused = True
-                    elif download.status == Download.CANCELED:
+                    elif download.status == CANCELED:
                         has_canceled = True
-                    elif download.status == Download.CONNECTING or \
-                         download.status == Download.DOWNLOADING:
+                    elif download.status == CONNECTING or \
+                         download.status == DOWNLOADING:
                         has_active = True
 
             if has_paused or has_canceled:
@@ -550,7 +551,7 @@
         """Sets the appropriate sensitivity property for widgets based on the
         given status."""
 
-        if status == Download.COMPLETED:
+        if status == COMPLETED:
             self.pause_tool_button.set_sensitive(False)
             self.pause_imi.set_sensitive(False)
             self.resume_tool_button.set_sensitive(False)
@@ -558,7 +559,7 @@
             self.cancel_tool_button.set_sensitive(False)
             self.cancel_imi.set_sensitive(False)
 
-        elif status == Download.CANCELED:
+        elif status == CANCELED:
             self.pause_tool_button.set_sensitive(False)
             self.pause_imi.set_sensitive(False)
             self.resume_tool_button.set_sensitive(True)
@@ -566,7 +567,7 @@
             self.cancel_tool_button.set_sensitive(False)
             self.cancel_imi.set_sensitive(False)
 
-        elif status == Download.PAUSED:
+        elif status == PAUSED:
             self.pause_tool_button.set_sensitive(False)
             self.pause_imi.set_sensitive(False)
             self.resume_tool_button.set_sensitive(True)
@@ -574,7 +575,7 @@
             self.cancel_tool_button.set_sensitive(True)
             self.cancel_imi.set_sensitive(True)
 
-        elif status == Download.DOWNLOADING or status == Download.CONNECTING:
+        elif status == DOWNLOADING or status == CONNECTING:
             self.pause_tool_button.set_sensitive(True)
             self.pause_imi.set_sensitive(True)
             self.resume_tool_button.set_sensitive(False)
@@ -807,8 +808,8 @@
         gui.queue_resize(self.downloads_treeview)
 
         # Enable clear button if necessary
-        if not self.clear_tool_button.props.sensitive and download.status == \
-                Download.COMPLETED:
+        if not self.clear_tool_button.props.sensitive and \
+           download.status == COMPLETED:
             self.clear_tool_button.set_sensitive(True)
 
     def __download_removed(self, download_list, download):
@@ -820,7 +821,7 @@
         has_completed = False
         iter_to_remove = None
         for row in self.downloads_model:
-            if row[0].status == Download.COMPLETED:
+            if row[0].status == COMPLETED:
                 has_completed = True
 
             if row[0] is download:
@@ -845,8 +846,8 @@
         self.__downloads_treeview_selection_changed(self.downloads_treeview_selection)
 
         # Enable clear button if necessary
-        if not self.clear_tool_button.props.sensitive and status == \
-                Download.COMPLETED:
+        if not self.clear_tool_button.props.sensitive and \
+           status == COMPLETED:
             self.clear_tool_button.set_sensitive(True)
 
         self.update_download_row(download)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]