[PATCH] repository: Base: apply local->remote nametrans after sep-conversion

Andrej Rode mail at andrejro.de
Sat Dec 24 23:55:25 GMT 2016


This should merely be a RFC. Instead of commenting out the checks in
accounts.py I'd rather put in a check which represents the handling
(with nametrans). But first I'd like to check if this idea has any
chance of making it into the tree.

Another way of handling separators in remote foldernames would be to add
a second nametrans which will always be executed after the separator
translation and current handling of nametrans would not change.

Cheers,
Andrej

On 24/12/16 11:15, Andrej Rode wrote:
> Allow usage of nametrans to sync remote folders with local sep in their
> name.
> 
> Signed-off-by: Andrej Rode <mail at andrejro.de>
> ---
>  offlineimap/accounts.py        | 14 +++++++-------
>  offlineimap/repository/Base.py |  4 ++--
>  2 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
> index 327af8b..3e114e8 100644
> --- a/offlineimap/accounts.py
> +++ b/offlineimap/accounts.py
> @@ -361,13 +361,13 @@ class SyncableAccount(Account):
>                  # their names since this would cause troubles while
> converting
>                  # the name back (from local to remote).
>                  sep = localrepos.getsep()
> -                if (sep != os.path.sep and
> -                    sep != remoterepos.getsep() and
> -                    sep in remotefolder.getname()):
> -                    self.ui.warn('', "Ignoring folder '%s' due to
> unsupported "
> -                        "'%s' character serving as local separator."%
> -                        (remotefolder.getname(), localrepos.getsep()))
> -                    continue # Ignore unsupported folder name.
> +                # if (sep != os.path.sep and
> +                #     sep != remoterepos.getsep() and
> +                #     sep in remotefolder.getname()):
> +                #     self.ui.warn('', "Ignoring folder '%s' due to
> unsupported "
> +                #         "'%s' character serving as local separator."%
> +                #         (remotefolder.getname(), localrepos.getsep()))
> +                #     continue # Ignore unsupported folder name.
>                   localfolder = self.get_local_folder(remotefolder)
>                  if not localfolder.sync_this:
> diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py
> index 0c3d16f..a38c111 100644
> --- a/offlineimap/repository/Base.py
> +++ b/offlineimap/repository/Base.py
> @@ -219,8 +219,8 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
>                  break
>               # Apply reverse nametrans and fix serparator.
> -            remote_name = local_folder.getvisiblename().replace(
> -                local_repo.getsep(), remote_repo.getsep())
> +            remote_name =
> local_folder.getrepository().nametrans(local_folder.getname().replace(
> +                local_repo.getsep(), remote_repo.getsep()))
>              if local_folder.sync_this and not remote_name in
> remote_hash.keys():
>                  # Would the remote filter out the new folder name? In
> this case
>                  # don't create it.
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/offlineimap-project/attachments/20161224/34b080fd/attachment-0003.sig>


More information about the OfflineIMAP-project mailing list