doc:appunti:linux:sa:offlineimap3_nametrans
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
doc:appunti:linux:sa:offlineimap3_nametrans [2024/03/22 10:28] – niccolo | doc:appunti:linux:sa:offlineimap3_nametrans [2024/03/22 11:15] – [offlineimap3 IMAP syncronization: nametrans] niccolo | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== offlineimap3 IMAP syncronization: | ====== offlineimap3 IMAP syncronization: | ||
+ | |||
+ | In this page we study a case of IMAP syncronization from a source IMAP server to a Maildir structure on local disk, using the **[[https:// | ||
+ | |||
+ | The main issue is the need to **map the source directory tree** into a tree compatible with the receiving Maildir hierarchy. Here are the issues: | ||
+ | |||
+ | The **source IMAP** server has the following characteristics: | ||
+ | |||
+ | * The directory separator is the "/" | ||
+ | * Some subfolders are stored into the INBOX, but others are stored at the top level. | ||
+ | * Some subfolders have names containing the " | ||
+ | |||
+ | The **destination Maildir** has the following characteristics: | ||
+ | |||
+ | * The directory separator is the " | ||
+ | * All the subfolders must be under the INBOX. | ||
+ | * The " | ||
+ | |||
+ | In this case we need a very special **nametrans** expression into the [[https:// | ||
+ | |||
+ | :!: **NOTICE**: The mapping of the top-level folders under the INBOX during the transfer from IMAP to Maildir prevents the reverse mapping from Maildir to IMAP, therefore only synchronization from IMAP to Maildir will be possible and not vice versa. | ||
+ | |||
+ | ===== Testing the nametrans option ===== | ||
+ | |||
+ | It is possibile to write a simple Python script to test the **nametrans** expression: | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | import re | ||
+ | |||
+ | # From IMAP to Maildir: | ||
+ | # Add a leading ' | ||
+ | # Remove the leading INBOX folder name. | ||
+ | # Move the top-level folders into the INOBOX. | ||
+ | # Replace the ' | ||
+ | nametrans = lambda foldername: re.sub( | ||
+ | r' | ||
+ | ' | ||
+ | r' | ||
+ | foldername.replace(' | ||
+ | ) | ||
+ | ) | ||
+ | |||
+ | dirs = [ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | |||
+ | for name in dirs: | ||
+ | print(' | ||
+ | </ | ||
+ | |||
+ | Running the script you can verify that directories from the source IMAP server will be mapped to the local Maildir: | ||
+ | |||
+ | < | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | </ | ||
+ | |||
+ | :!: **NOTICE**: The translated name of a sub-subfolder contains the original **directory separator** (.e.g. '' | ||
+ | |||
+ | ===== Web References ===== | ||
+ | |||
+ | * **[[https:// | ||
doc/appunti/linux/sa/offlineimap3_nametrans.txt · Last modified: 2024/03/22 11:23 by niccolo