2017-04-14 11:11:33 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from subprocess import check_output
|
|
|
|
from re import sub
|
|
|
|
|
|
|
|
def get_pass(account):
|
|
|
|
data = check_output("/usr/bin/pass email/" + account, shell=True).splitlines()
|
|
|
|
password = data[0]
|
|
|
|
tmp = [x for x in data if x.startswith('address:')]
|
|
|
|
user = ""
|
|
|
|
if len(tmp) > 0:
|
|
|
|
user = tmp[0].split(":", 1)[1]
|
|
|
|
|
|
|
|
return {"password": password, "user": user}
|
|
|
|
|
|
|
|
def folder_filter(name):
|
2017-04-18 20:18:28 -07:00
|
|
|
return not (name in ['INBOX',
|
|
|
|
'[Gmail]/Spam',
|
2017-04-14 11:11:33 -07:00
|
|
|
'[Gmail]/Important',
|
2017-04-18 20:18:28 -07:00
|
|
|
'[Gmail]/Starred'] or
|
2017-04-14 11:11:33 -07:00
|
|
|
name.startswith('[Airmail]'))
|
|
|
|
|
|
|
|
def nametrans(name):
|
2017-04-18 20:18:28 -07:00
|
|
|
return sub('^(Starred|Sent Mail|Drafts|Trash|All Mail|Spam)$', '[Gmail]/\\1', name)
|
2017-04-14 11:11:33 -07:00
|
|
|
|
|
|
|
def nametrans_reverse(name):
|
2017-04-18 20:18:28 -07:00
|
|
|
return sub('^(\[Gmail\]/)', '', name)
|