/offlineimap/head: changeset 236

Now the containing repository is stored within a folder. This will be
necessary for moves.
This commit is contained in:
jgoerzen 2002-08-20 21:54:02 +01:00
parent e1657f962e
commit cbcf797944
8 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,9 @@
offlineimap (3.3.0) unstable; urgency=low
* Placeholder
-- John Goerzen <jgoerzen@complete.org> Tue, 20 Aug 2002 10:46:56 -0500
offlineimap (3.2.6) unstable; urgency=low offlineimap (3.2.6) unstable; urgency=low
* Changed indentation in debian/control. Closes: #156327. * Changed indentation in debian/control. Closes: #156327.

View File

@ -50,6 +50,10 @@ class BaseFolder:
def getvisiblename(self): def getvisiblename(self):
return self.name return self.name
def getrepository(self):
"""Returns the repository object that this folder is within."""
return self.repository
def getroot(self): def getroot(self):
"""Returns the root of the folder, in a folder-specific fashion.""" """Returns the root of the folder, in a folder-specific fashion."""
return self.root return self.root

View File

@ -25,7 +25,7 @@ from copy import copy
import __main__ import __main__
class IMAPFolder(BaseFolder): class IMAPFolder(BaseFolder):
def __init__(self, imapserver, name, visiblename, accountname): def __init__(self, imapserver, name, visiblename, accountname, repository):
self.name = imaputil.dequote(name) self.name = imaputil.dequote(name)
self.root = None # imapserver.root self.root = None # imapserver.root
self.sep = imapserver.delim self.sep = imapserver.delim
@ -33,6 +33,7 @@ class IMAPFolder(BaseFolder):
self.messagelist = None self.messagelist = None
self.visiblename = visiblename self.visiblename = visiblename
self.accountname = accountname self.accountname = accountname
self.repository = repository
def suggeststhreads(self): def suggeststhreads(self):
return 1 return 1

View File

@ -22,12 +22,13 @@ import os
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1" magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
class LocalStatusFolder(BaseFolder): class LocalStatusFolder(BaseFolder):
def __init__(self, root, name): def __init__(self, root, name, repository):
self.name = name self.name = name
self.root = root self.root = root
self.sep = '.' self.sep = '.'
self.filename = os.path.join(root, name) self.filename = os.path.join(root, name)
self.messagelist = None self.messagelist = None
self.repository = repository
def storesmessages(self): def storesmessages(self):
return 0 return 0

View File

@ -39,12 +39,13 @@ def gettimeseq():
return timeseq return timeseq
class MaildirFolder(BaseFolder): class MaildirFolder(BaseFolder):
def __init__(self, root, name, sep): def __init__(self, root, name, sep, repository):
self.name = name self.name = name
self.root = root self.root = root
self.sep = sep self.sep = sep
self.uidfilename = os.path.join(self.getfullname(), "offlineimap.uidvalidity") self.uidfilename = os.path.join(self.getfullname(), "offlineimap.uidvalidity")
self.messagelist = None self.messagelist = None
self.repository = repository
def getfullname(self): def getfullname(self):
return os.path.join(self.getroot(), self.getname()) return os.path.join(self.getroot(), self.getname())

View File

@ -48,7 +48,7 @@ class IMAPRepository(BaseRepository):
def getfolder(self, foldername): def getfolder(self, foldername):
return folder.IMAP.IMAPFolder(self.imapserver, foldername, return folder.IMAP.IMAPFolder(self.imapserver, foldername,
self.nametrans(foldername), self.nametrans(foldername),
accountname) accountname, self)
def getfolders(self): def getfolders(self):
if self.folders != None: if self.folders != None:
@ -69,11 +69,11 @@ class IMAPRepository(BaseRepository):
continue continue
retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername, retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername,
self.nametrans(foldername), self.nametrans(foldername),
self.accountname)) self.accountname, self))
for foldername in self.folderincludes: for foldername in self.folderincludes:
retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername, retval.append(folder.IMAP.IMAPFolder(self.imapserver, foldername,
self.nametrans(foldername), self.nametrans(foldername),
self.accountname)) self.accountname, self))
retval.sort(lambda x, y: self.foldersort(x.getvisiblename(), y.getvisiblename())) retval.sort(lambda x, y: self.foldersort(x.getvisiblename(), y.getvisiblename()))
self.folders = retval self.folders = retval
return retval return retval

View File

@ -42,11 +42,12 @@ class LocalStatusRepository(BaseRepository):
retval = [] retval = []
for folder in os.listdir(self.directory): for folder in os.listdir(self.directory):
retval.append(folder.LocalStatus.LocalStatusFolder(self.directory, retval.append(folder.LocalStatus.LocalStatusFolder(self.directory,
folder)) folder, self))
return retval return retval
def getfolder(self, foldername): def getfolder(self, foldername):
return folder.LocalStatus.LocalStatusFolder(self.directory, foldername) return folder.LocalStatus.LocalStatusFolder(self.directory, foldername,
self)

View File

@ -87,7 +87,7 @@ class MaildirRepository(BaseRepository):
def getfolder(self, foldername): def getfolder(self, foldername):
return folder.Maildir.MaildirFolder(self.root, foldername, return folder.Maildir.MaildirFolder(self.root, foldername,
self.getsep()) self.getsep(), self)
def _getfolders_scandir(self, root, extension = None): def _getfolders_scandir(self, root, extension = None):
self.debug("_GETFOLDERS_SCANDIR STARTING. root = %s, extension = %s" \ self.debug("_GETFOLDERS_SCANDIR STARTING. root = %s, extension = %s" \
@ -131,7 +131,7 @@ class MaildirRepository(BaseRepository):
self.debug(" foldername = %s" % foldername) self.debug(" foldername = %s" % foldername)
retval.append(folder.Maildir.MaildirFolder(self.root, foldername, retval.append(folder.Maildir.MaildirFolder(self.root, foldername,
self.getsep())) self.getsep(), self))
if self.getsep() == '/': if self.getsep() == '/':
# Check sub-directories for folders. # Check sub-directories for folders.
retval.extend(self._getfolders_scandir(root, foldername)) retval.extend(self._getfolders_scandir(root, foldername))