legacy-dotfiles/offlineimap/.offlineimap.py

52 lines
1.2 KiB
Python
Raw Normal View History

2012-11-16 12:14:19 +01:00
from offlineimap import imaputil
def lld_flagsimap2maildir(flagstring):
flagmap = {'\\seen': 'S',
'\\answered': 'R',
'\\flagged': 'F',
'\\deleted': 'T',
'\\draft': 'D',
'gnus-expire': 'E'}
retval = []
imapflaglist = [x.lower() for x in flagstring[1:-1].split()]
for imapflag in imapflaglist:
if imapflag in flagmap:
retval.append(flagmap[imapflag])
retval.sort()
return set(retval)
def lld_flagsmaildir2imap(list):
flagmap = {'S': '\\Seen',
'R': '\\Answered',
'F': '\\Flagged',
'T': '\\Deleted',
'D': '\\Draft',
'E': 'gnus-expire'}
retval = []
for mdflag in list:
if mdflag in flagmap:
retval.append(flagmap[mdflag])
retval.sort()
return '(' + ' '.join(retval) + ')'
imaputil.flagsmaildir2imap = lld_flagsmaildir2imap
imaputil.flagsimap2maildir = lld_flagsimap2maildir
2011-01-11 13:43:17 +01:00
def getuser(host):
import netrc
mynet = netrc.netrc()
return mynet.authenticators(host)[0]
2012-11-16 12:14:19 +01:00
2011-01-11 13:43:17 +01:00
def getpassword(host):
import netrc
mynet = netrc.netrc()
return mynet.authenticators(host)[2]