[PATCH 2/9] Re: Replace 2 regexes with a single one

Sebastian Spaeth Sebastian at SSpaeth.de
Wed Apr 27 08:54:34 BST 2011


On Tue, 26 Apr 2011 18:54:31 +0200, Nicolas Sebrecht <nicolas.s-dev at laposte.net> wrote:
> >      def getfolderfilename(self, foldername):
> > -        foldername = re.sub('/\.$', '/dot', foldername)
> > -        foldername = re.sub('^\.$', 'dot', foldername)
> > +        """Return the full path of the status file"""
> > +        # replace with 'dot' if final path name is '.'
> > +        foldername = re.sub('(^|\/)\.$','\\1dot', foldername)
> >          return os.path.join(self.directory, foldername)
> 
> Why are dots a problem only at the _end_ of the foldername?

The code and the behavior had already been there and it had puzzled me
too (especially as it was without any comment). That's why I added one
code comment as to what the regexp does, but it might be worthwhile to
add even more explanation to it:

Because we would be trying to create a file called
"/mailbox/foldername/." and in unix filesystems, "." in a directory
already has a very special meaning and is not possible filename, so it
is being replaced with a literal "dot". IMAP mailboxes on the other hand
can often have just a "." as a name.

Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20110427/34fbcb64/attachment-0001.sig>


More information about the OfflineIMAP-project mailing list