[PATCHv2 4a/4] Clean up 'import's

Sebastian Spaeth Sebastian at SSpaeth.de
Mon Jan 10 11:12:42 GMT 2011


Make imports conform to PEP8 (one import per line), remove redundant or
unneeded imports.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---

 I am sorry, the previous patch 4/4 would not lead to working code, I
 must have somehow missed out testing that version. I reworked patch 4
 now to work properly and split it into a 4a which reorganizes the
 imports and a 4b which actually implements the single-threading.

 offlineimap/init.py |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/offlineimap/init.py b/offlineimap/init.py
index 4347bf1..f652328 100644
--- a/offlineimap/init.py
+++ b/offlineimap/init.py
@@ -16,18 +16,20 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
+import os
+import sys
+import threading
 import imaplib
-from offlineimap import imapserver, threadutil, version, syncmaster, accounts
-from offlineimap.localeval import LocalEval
-from offlineimap.threadutil import InstanceLimitedThread, ExitNotifyThread
-import offlineimap.ui
-from offlineimap.CustomConfig import CustomConfigParser
-from optparse import OptionParser
-import re, os, sys
-from threading import *
-import threading, socket
 import signal
+import socket
 import logging
+from optparse import OptionParser
+import offlineimap
+from offlineimap import accounts, threadutil, syncmaster
+from offlineimap.ui import UI_LIST, setglobalui, getglobalui
+from offlineimap.localeval import LocalEval
+from offlineimap.CustomConfig import CustomConfigParser
+
 
 try:
     import fcntl
@@ -153,7 +155,7 @@ class OfflineImap:
               "configuration file. The UI specified with -u will "
               "be forced to be used, even if checks determine that it is "
               "not usable. Possible interface choices are: %s " %
-              ", ".join(offlineimap.ui.UI_LIST.keys()))
+              ", ".join(UI_LIST.keys()))
 
         (options, args) = parser.parse_args()
 
@@ -194,12 +196,12 @@ class OfflineImap:
         if options.interface != None:
             ui_type = options.interface
         try:
-            ui = offlineimap.ui.UI_LIST[ui_type](config)
+            ui = UI_LIST[ui_type](config)
         except KeyError:
             logging.error("UI '%s' does not exist, choose one of: %s" % \
-                              (ui_type,', '.join(offlineimap.ui.UI_LIST.keys())))
+                              (ui_type,', '.join(UI_LIST.keys())))
             sys.exit(1)
-        offlineimap.ui.UIBase.setglobalui(ui)
+        setglobalui(ui)
 
         #set up additional log files
         if options.logfile:
@@ -247,7 +249,7 @@ class OfflineImap:
     
         def sigterm_handler(self, signum, frame):
             # die immediately
-            ui = offlineimap.ui.getglobalui()
+            ui = getglobalui()
             ui.terminate(errormsg="terminating...")
 
         signal.signal(signal.SIGTERM,sigterm_handler)
@@ -325,7 +327,7 @@ class OfflineImap:
             signal.signal(signal.SIGUSR2,sig_handler)
     
             threadutil.initexitnotify()
-            t = ExitNotifyThread(target=syncmaster.syncitall,
+            t = threadutil.ExitNotifyThread(target=syncmaster.syncitall,
                                  name='Sync Runner',
                                  kwargs = {'accounts': syncaccounts,
                                            'config': config,
-- 
1.7.1





More information about the OfflineIMAP-project mailing list