]> git.rmz.io Git - dotfiles.git/blobdiff - offlineimap/utils.py
offlineimap: sync labels and switch to daemon mode
[dotfiles.git] / offlineimap / utils.py
diff --git a/offlineimap/utils.py b/offlineimap/utils.py
new file mode 100644 (file)
index 0000000..81fbbf7
--- /dev/null
@@ -0,0 +1,42 @@
+import re
+
+mapping = { 'INBOX':                   'inbox'
+          , '[Google Mail]/All Mail':  'archive'
+          , '[Google Mail]/Drafts':    'drafts'
+          , '[Google Mail]/Important': 'important'
+          , '[Google Mail]/Sent Mail': 'sent'
+          , '[Google Mail]/Spam':      'spam'
+          , '[Google Mail]/Starred':   'flagged'
+          , '[Google Mail]/Bin':       'bin'
+ }
+
+r_mapping = { val: key for key, val in mapping.items() }
+
+def transremote(foldername):
+    return mapping.get(foldername, foldername)
+
+def translocal(foldername):
+    return r_mapping.get(foldername, foldername)
+
+top = [ 'inbox'
+      , 'flagged'
+      , 'chakra'
+      , 'unimaas'
+      , 'clementine'
+      , 'youtube'
+      , 'hotmail'
+      ]
+
+bot = [ 'archive'
+      , 'drafts'
+      , 'spam'
+      , 'bin'
+      ]
+
+def sort_key(d):
+    folder = d['foldername']
+    if folder in top:
+        return top.index(folder)
+    elif folder in bot:
+        return 21 + bot.index(folder)
+    return 20