Help in correct set reverse nametrans

Nicolas Sebrecht nicolas.s-dev at laposte.net
Thu Feb 4 23:29:58 UTC 2016


On Thu, Feb 04, 2016 at 09:33:15PM +0000, Marcelo wrote:
> Marcelo Laia <marcelolaia <at> gmail.com> writes:
> 
> > Please, could you help me to do a reverse nametrans to my nametrans
> > below?
> > 
> > [Repository Gmail-Remote]
> > type = Gmail
> > (snip)
> > nametrans = lambda folder: re.sub('.*Rascunhos$', 'Rascunhos', 
> >     re.sub('.*E-mails enviados$', 'Enviados', 
> >     re.sub('.*Com estrela$', 'Importante', 
> >     re.sub('.*Lixeira$', 'Lixeira',
> >     re.sub('INBOX','Inbox', folder)))))
> > 
> > # Don't synchronize these folders
> > folderfilter = lambda foldername: foldername not in ['.*Spam$',
> > '.*spam$', '.*Lixeira$', 'Sent Mail', 'Trash']
> 
> Someone could help me? I read a lot off in the web and in the
> http://offlineimap.org/doc/nametrans.html#reverse-nametrans and I am totally
> idiots to do that.

First, you might have miss this

  http://offlineimap.org/doc/nametrans.html#createfolders

which stands that sometimes you might not have to setup reverse
nametrans at all.


Next, we can't help much without more details. Providing the output of

  offlineimap --info

is a good start. Keep in mind that reverse nametrans must be a 1 to 1
translation mapping (in both direction). IOW, it must be a bijection
https://en.wikipedia.org/wiki/Bijection to take the mathematic term.

Example:

With this nametrans:

  '.*Rascunhos$' -> 'Rascunhos'

Having the reverse nametrans

  'Rascunhos$' -> 'x_Rascunhos'

is correct if remote has:

  x_Rascunhos
  Rascunhos_y (won't match initial nametrans)
  x_Rascunhos_y (won't match initial nametrans)

but wrong if there are

  x_Rascunhos
  y_Rascunhos

or

  x_Rascunhos
  Rascunhos


Also, while reverse nametrans depends on what you have today, it depends
on what you could have in the future and what you expect to have. It's
hard if not impossible to write reverse nametrans for others.

So, the best is to tell what you don't understand to write your own
rules. However, if you give the output of --info you might ask if the
rules you wrote are correct for the CURRENT folders. Answering to this
kind of question is more or less easy.

-- 
Nicolas Sebrecht



More information about the OfflineIMAP-project mailing list