<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I need to migrate a number of accounts in my deparment from Exchange
    to Maildir (Postifx).<br>
    <br>
    Since migration has to be done in stages, bidirectional
    synchronization is necessary.<br>
    <br>
    Mapping between folder names is complicated by the fact that Exhange
    folders may contain dots.<br>
    There are plenty of cases were it makes sense to use dots in
    folders, for instance company names (registry.it), group names (WG
    2.1), etc.<br>
    There is no pattern of use that would allow recognizing them.<br>
    Some programs like imapsync map them to '-', but this does not work
    in the other direction, since there is no way to distinguish other
    occurences of '-', when doing the reverse mapping.<br>
    <br>
    Since many accounts must be migrated, it is impossible to go through
    them and change the names by hand.<br>
    <br>
    I decided to adopt the solution to convert '.' to Unicode <span
      class="st">MIDDLE <em>DOT</em>' (U+00B7), which looks similar.<br>
      I wrote nametrans functions that encode the names in mUTF-7, as
      used by IMAP.<br>
    </span><br>
    <span class="st"><span class="st"><span class="st"><span class="st">I
            had to patch the code </span></span>for
        sync_folder_structure in class Base to avoid complains when
        doing the reverse translation, since after the middle dot is
        converted back to '.', it replaces '.' with '/ and raises an
        error about possible loops.<br>
        Here is the patch:<br>
        <br>
        *** Base.py 2013-07-17 15:06:15.000000000 +0200<br>
        --- Base.py~    2013-04-16 17:02:14.000000000 +0200<br>
        ***************<br>
        *** 216,225 ****<br>
                          # succeed in getting inexisting folders which
        I would<br>
                          # like to change. Take care!<br>
                          folder = self.getfolder(dst_name_t)<br>
                          newdst_name = folder.getvisiblename().replace(<br>
                              src_repo.getsep(), dst_repo.getsep())<br>
        !                 if dst_folder.name != newdst_name and \<br>
        !                         dst_folder.name.replace('&ALc-',
        '.') != newdst_name:<br>
                              raise OfflineImapError("INFINITE FOLDER
        CREATION DETECTED! "<br>
                                  "Folder '%s' (repository '%s') would
        be created as fold"<br>
                                  "er '%s' (repository '%s'). The latter
        becomes '%s' in "<br>
        --- 216,225 ----<br>
                          # succeed in getting inexisting folders which
        I would<br>
                          # like to change. Take care!<br>
                          folder = self.getfolder(dst_name_t)<br>
        +                 # apply reverse nametrans to see if we end up
        with the same name<br>
                          newdst_name = folder.getvisiblename().replace(<br>
                              src_repo.getsep(), dst_repo.getsep())<br>
        !                 if dst_folder.name != newdst_name:<br>
                              raise OfflineImapError("INFINITE FOLDER
        CREATION DETECTED! "<br>
                                  "Folder '%s' (repository '%s') would
        be created as fold"<br>
                                  "er '%s' (repository '%s'). The latter
        becomes '%s' in "<br>
      </span><br>
      The solution seems to work fine.<br>
      <br>
      Here is a test run:<br>
      <br>
      *** Processing account me<br>
      Establishing connection to ex.di.unipi.it:993<br>
      Establishing connection to imap.unipi.it:143<br>
      Creating folder aa&ALc-a[Maildir]<br>
      Creating folder aa.a[Maildir]<br>
      Skipping aa/a (not changed)<br>
      Syncing aa.a: IMAP -> MappedIMAP<br>
      Copy message 1 (1 of 1) Exchange:aa.a -> Maildir<br>
      *** Finished account 'me' in 0:03<br>
      <br>
      Comments and suggestions welcome.<br>
      <br>
      Giuseppe Attardi<br>
      Università di Pisa<br>
      <br>
    </span>
  </body>
</html>