/head: changeset 17
*** empty log message ***
This commit is contained in:
parent
0aa3ee1fb8
commit
b179602b31
@ -31,6 +31,10 @@ accounts = config.get("general", "accounts")
|
||||
accounts = accounts.replace(" ", "")
|
||||
accounts = accounts.split(",")
|
||||
|
||||
server = None
|
||||
remoterepos = None
|
||||
localrepos = None
|
||||
|
||||
for accountname in accounts:
|
||||
print "Processing account " + accountname
|
||||
accountmetadata = os.path.join(metadatadir, accountname)
|
||||
@ -59,4 +63,14 @@ for accountname in accounts:
|
||||
for remotefolder in remoterepos.getfolders():
|
||||
print "*** SYNCHRONIZING FOLDER %s" % remotefolder.getname()
|
||||
localfolder = localrepos.getfolder(remotefolder.getname())
|
||||
#if not localfolder.isuidvalidityok(remotefolder):
|
||||
# print 'UID validity is a problem for this folder; skipping.'
|
||||
# continue
|
||||
#print "Reading remote message list...",
|
||||
#remotefolder.cachemessagelist()
|
||||
#print len(remotefolder.getmessagelist().keys()), "messages."
|
||||
print "Reading local message list...",
|
||||
localfolder.cachemessagelist()
|
||||
print len(localfolder.getmessagelist().keys()), "messages."
|
||||
print "Synchronizing locally-made changes..."
|
||||
|
||||
|
@ -30,7 +30,10 @@ class BaseFolder:
|
||||
return self.sep
|
||||
|
||||
def getfullname(self):
|
||||
if self.getroot():
|
||||
return self.getroot() + self.getsep() + self.getname()
|
||||
else:
|
||||
return self.getname()
|
||||
|
||||
def isuidvalidityok(self, remotefolder):
|
||||
raise NotImplementedException
|
||||
|
@ -25,4 +25,26 @@ class IMAPFolder(BaseFolder):
|
||||
self.root = imapserver.root
|
||||
self.sep = imapserver.delim
|
||||
self.imapserver = imapserver
|
||||
self.imapobj = self.imapserver.makeconnection()
|
||||
self.messagelist = None
|
||||
|
||||
def getuidvalidity(self):
|
||||
x = self.imapobj.status(self.getfullname(), ('UIDVALIDITY'))[1][0]
|
||||
uidstring = imaputil.imapsplit(x)[1]
|
||||
return int(imaputil.flagsplit(x)[1])
|
||||
|
||||
def cachemessagelist(self):
|
||||
assert(self.imapobj.select(self.getfullname())[0] == 'OK')
|
||||
self.messagelist = {}
|
||||
response = self.imapobj.status(self.getfullname(), ('MESSAGES'))[1][0]
|
||||
result = imaputil.imapsplit(response)[1]
|
||||
maxmsgid = int(imaputil.flags2hash(result)['MESSAGES'])
|
||||
|
||||
# Now, get the flags and UIDs for these.
|
||||
response = self.imapobj.fetch('1:%d' % maxmsgid, '(FLAGS UID)')[1]
|
||||
for messagestr in response:
|
||||
# Discard the message number.
|
||||
messagestr = imaputil.imapsplit(messagestr)[1]
|
||||
options = imaputil.flags2hash(messagestr)
|
||||
|
||||
|
||||
|
@ -33,7 +33,18 @@ def dequote(string):
|
||||
def flagsplit(string):
|
||||
if string[0] != '(' or string[-1] != ')':
|
||||
raise ValueError, "Passed string '%s' is not a flag list" % string
|
||||
return string[1:-1].split(" ")
|
||||
return imapsplit(string[1:-1])
|
||||
|
||||
def options2hash(list):
|
||||
retval = {}
|
||||
counter = 0
|
||||
while (counter < len(list)):
|
||||
retval[list[counter]] = list[counter + 1]
|
||||
counter += 2
|
||||
return retval
|
||||
|
||||
def flags2hash(string):
|
||||
return options2hash(flagsplit(string))
|
||||
|
||||
def imapsplit(string):
|
||||
"""Takes a string from an IMAP conversation and returns a list containing
|
||||
@ -51,11 +62,11 @@ def imapsplit(string):
|
||||
if re.search('^\s', workstr):
|
||||
workstr = re.search('^\s(.*)$', workstr).group(1)
|
||||
elif workstr[0] == '(':
|
||||
parenlist = re.search('^(\([^)]*\))', workstr).group(1)
|
||||
parenlist = re.search('^(\(.*\))', workstr).group(1)
|
||||
workstr = workstr[len(parenlist):]
|
||||
retval.append(parenlist)
|
||||
elif workstr[0] == '"':
|
||||
quotelist = re.search('^("[^"]*")', workstr).group(1)
|
||||
quotelist = re.search('^("([^"]|\\")*")', workstr).group(1)
|
||||
workstr = workstr[len(quotelist):]
|
||||
retval.append(quotelist)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user