/head: changeset 34
Updated!
This commit is contained in:
		@@ -1,11 +1,25 @@
 | 
				
			|||||||
import UIBase
 | 
					from UIBase import UIBase
 | 
				
			||||||
from getpass import getpass
 | 
					from getpass import getpass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TTYUI(UIBase.UIBase):
 | 
					class TTYUI(UIBase):
 | 
				
			||||||
 | 
					    def __init__(self, verbose = 0):
 | 
				
			||||||
 | 
					        self.verbose = 0
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    def _msg(s, msg):
 | 
					    def _msg(s, msg):
 | 
				
			||||||
        print msg
 | 
					        print msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def getpass(s, accountname, host, port, user):
 | 
					    def getpass(s, accountname, host, port, user):
 | 
				
			||||||
        return getpass("%s: Password required for %s on %s" %
 | 
					        return getpass("%s: Enter password for %s on %s: " %
 | 
				
			||||||
                       (accountname, user, host))
 | 
					                       (accountname, user, host))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def syncingmessages(s, sr, sf, dr, df):
 | 
				
			||||||
 | 
					        if s.verbose:
 | 
				
			||||||
 | 
					            UIBase.syncingmessages(s, sr, sf, dr, df)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def loadmessagelist(s, repos, folder):
 | 
				
			||||||
 | 
					        if s.verbose:
 | 
				
			||||||
 | 
					            UIBase.syncingmessages(s, repos, folder)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    def messagelistloaded(s, repos, folder, count):
 | 
				
			||||||
 | 
					        if s.verbose:
 | 
				
			||||||
 | 
					            UIBase.messagelistloaded(s, repos, folder, count)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,7 @@
 | 
				
			|||||||
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
					#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from imapsync import repository
 | 
					from imapsync import repository
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UIBase:
 | 
					class UIBase:
 | 
				
			||||||
    ################################################## UTILS
 | 
					    ################################################## UTILS
 | 
				
			||||||
@@ -28,7 +29,9 @@ class UIBase:
 | 
				
			|||||||
        s._msg("WARNING: " + msg)
 | 
					        s._msg("WARNING: " + msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def getnicename(s, object):
 | 
					    def getnicename(s, object):
 | 
				
			||||||
        return str(object.__class__).split('.')[-1]
 | 
					        prelimname = str(object.__class__).split('.')[-1]
 | 
				
			||||||
 | 
					        # Strip off extra stuff.
 | 
				
			||||||
 | 
					        return re.sub('(Folder|Repository)', '', prelimname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ################################################## INPUT
 | 
					    ################################################## INPUT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,7 +47,7 @@ class UIBase:
 | 
				
			|||||||
        This software comes with NO WARRANTY: see the file COPYING for details.""")
 | 
					        This software comes with NO WARRANTY: see the file COPYING for details.""")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def acct(s, accountname):
 | 
					    def acct(s, accountname):
 | 
				
			||||||
        s._msg("Processing account %s" % accountname)
 | 
					        s._msg("***** Processing account %s" % accountname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def syncfolders(s, srcrepos, destrepos):
 | 
					    def syncfolders(s, srcrepos, destrepos):
 | 
				
			||||||
        s._msg("Copying folder structure from %s to %s" % \
 | 
					        s._msg("Copying folder structure from %s to %s" % \
 | 
				
			||||||
@@ -53,8 +56,9 @@ class UIBase:
 | 
				
			|||||||
    ############################## Folder syncing
 | 
					    ############################## Folder syncing
 | 
				
			||||||
    def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
 | 
					    def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
 | 
				
			||||||
        """Called when a folder sync operation is started."""
 | 
					        """Called when a folder sync operation is started."""
 | 
				
			||||||
        s._msg("Syncing %s[%s] -> %s[%s]" % (srcrepos, srcfolder,
 | 
					        s._msg("Syncing %s: %s -> %s" % (srcfolder.getname(),
 | 
				
			||||||
                                             destrepos, destfolder))
 | 
					                                         s.getnicename(srcrepos),
 | 
				
			||||||
 | 
					                                         s.getnicename(destrepos)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def validityproblem(s, folder):
 | 
					    def validityproblem(s, folder):
 | 
				
			||||||
        s.warn("UID validity problem for folder %s; skipping it" % \
 | 
					        s.warn("UID validity problem for folder %s; skipping it" % \
 | 
				
			||||||
@@ -62,19 +66,19 @@ class UIBase:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def loadmessagelist(s, repos, folder):
 | 
					    def loadmessagelist(s, repos, folder):
 | 
				
			||||||
        s._msg("Loading message list for %s[%s]" % (s.getnicename(repos),
 | 
					        s._msg("Loading message list for %s[%s]" % (s.getnicename(repos),
 | 
				
			||||||
                                                    s.getnicename(folder)))
 | 
					                                                    folder.getname()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def messagelistloaded(s, repos, folder, count):
 | 
					    def messagelistloaded(s, repos, folder, count):
 | 
				
			||||||
        s._msg("Message list for %s[%s] loaded: %d messages" % \
 | 
					        s._msg("Message list for %s[%s] loaded: %d messages" % \
 | 
				
			||||||
               (s.getnicename(repos), s.getnicename(folder), count))
 | 
					               (s.getnicename(repos), folder.getname(), count))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ############################## Message syncing
 | 
					    ############################## Message syncing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def syncingmessages(s, sr, sf, dr, df):
 | 
					    def syncingmessages(s, sr, sf, dr, df):
 | 
				
			||||||
        s._msg("Syncing messages %s[%s] -> %s[%s]" % (s.getnicename(sr),
 | 
					        s._msg("Syncing messages %s[%s] -> %s[%s]" % (s.getnicename(sr),
 | 
				
			||||||
                                                      s.getnicename(sf),
 | 
					                                                      sf.getname(),
 | 
				
			||||||
                                                      s.getnicename(dr),
 | 
					                                                      s.getnicename(dr),
 | 
				
			||||||
                                                      s.getnicename(df)))
 | 
					                                                      df.getname()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def copyingmessage(s, uid, src, destlist):
 | 
					    def copyingmessage(s, uid, src, destlist):
 | 
				
			||||||
        ds = ["%s[%s]" % (s.getnicename(x), x.getname()) for x in destlist].join(', ')
 | 
					        ds = ["%s[%s]" % (s.getnicename(x), x.getname()) for x in destlist].join(', ')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user