update i3 and vimrc
[dotfiles.git] / .mutt / offlineimap.py
index 9a6446a..02e4e2b 100644 (file)
@@ -1,14 +1,18 @@
-#!/bin/env python
-# -*- coding: utf-8 -*-
-
 import subprocess
+import datetime
+import re
 
 
 def mailpasswd():
-    args = '/usr/bin/gpg --use-agent --quiet --batch --decrypt ' +\
-        '/home/marlub/.mutt/passwd.gpg'
-    try:
-        result = subprocess.check_output(args, shell='/bin/bash').strip()
-        return result
-    except:
-        return ""
+    return subprocess.check_output('pass mail/mart@martlubbers.net',
+                                   shell='/bin/bash').strip()
+
+
+def folderfilter(x):
+    match = re.match('archive\.(\d\d\d\d).(\d\d)', x)
+    if match:
+        return abs(datetime.date.today() -
+                   datetime.date(int(match.group(1)), int(match.group(2)), 1)
+                   ).days <= 31*2
+    else:
+        return not x.startswith('archive')