nametrans confusion ...

Sebastian Spaeth Sebastian at SSpaeth.de
Thu Feb 16 15:23:50 GMT 2012


On Wed, 8 Feb 2012 14:18:05 +1100, Cameron Simpson <cs at zip.com.au> wrote:
> "OLD/2012/getmail". The remote folder may be "MD/OLD/2012/getmail" or
> "MD/OLD.2012.getmail" or even "MD.OLD.2012.getmail"

>   offlineimap -c myconfig.cfg -f MD/OLD/2012/getmail, -l a-logfile

> and it does not seem to be pulling messages from the remote
> OLD/2012/getmail folder. (It makes the local one, perhaps purely because
> it is named on the command line?)

If it does create the folder, it seems to get the mapping right.
 
> I'm using this config:
>     [general]
>     pythonfile = ~/offl.py

>     [Repository cameron at cskk.local:143]
>     nametrans = lambda foldername: there2here(foldername)
>     [Repository _Users_cameron_mail]
>     type = Maildir
>     sep = /
>     nametrans = lambda foldername: here2there(foldername)
> 
>   prepath = 'MD/'
>   def here2there(f):
>     rf = (prepath + f).replace('/', '.')
>     print >>sys.stderr, "here2there(%s) -> %s" % (f, rf)
>     return rf

your local nametrans essentially prefixes "MD/" to any path. There is no
need for separator munging, we do that ourselves. I'd probably use:
nametrans lambda f: "MD/" + f
(but your solution looks good too)
 
>   def there2here(rf):
>     f = rf[len(prepath):] if rf.startswith(prepath) else rf
>     print >>sys.stderr, "there2here(%s) -> %s" % (rf, f)
>     return f

so your remote nametrans essentially strips away and mention of MD/, it
seems. (I would use a nametrans=lambda f: re.sub('^MD/','',f) here, but
yours seems to look good too)

> Amongst the stderr I see these referring to getmail:
> 
>   there2here(MD/OLD/2012/getmail) -> OLD/2012/getmail
>   there2here(MD/getmail) -> getmail
>   here2there(getmail) -> MD.getmail
>   here2there(OLD/2012/getmail) -> MD.OLD.2012.getmail
>   here2there(getmail) -> MD.getmail

Looks good. 

In a current version of OfflineImap, what does "--info" output? It
should show you a list of foldermappings and what is being filtered
out. (you can also use the -f option with it).

Now that I come to think about it, I see what might be an issue. The -f
option works on the untranslated remote folder name. And that is not
MD/OLD/2012/getmail but MD.OLD.2012.getmail I guess. Does that work?

Sebastian




More information about the OfflineIMAP-project mailing list