Add remote{host,user,pass}eval config options (need documentation yet)
From Ben Kibbey hello, Attached is a patch to enable evaluation of account credentials with the remotehosteval, remoteusereval and remotepasseval configuration options. I needed this because rather than change all my other programs configuration settings when I change, say a password, I store them in a file. So I call a function in pythonfile which parses the credential file and returns the wanted info. Not really very well tested, but not complex either. Offlineimap is great, thanks.
This commit is contained in:
parent
d04e899368
commit
a6db99a21e
@ -85,10 +85,30 @@ class IMAPRepository(BaseRepository):
|
|||||||
return self.imapserver.delim
|
return self.imapserver.delim
|
||||||
|
|
||||||
def gethost(self):
|
def gethost(self):
|
||||||
return self.getconf('remotehost')
|
host = None
|
||||||
|
localeval = self.localeval
|
||||||
|
|
||||||
|
if self.config.has_option(self.getsection(), 'remotehosteval'):
|
||||||
|
host = self.getconf('remotehosteval')
|
||||||
|
if host != None:
|
||||||
|
return localeval.eval(host)
|
||||||
|
|
||||||
|
host = self.getconf('remotehost')
|
||||||
|
if host != None:
|
||||||
|
return host
|
||||||
|
|
||||||
def getuser(self):
|
def getuser(self):
|
||||||
return self.getconf('remoteuser')
|
user = None
|
||||||
|
localeval = self.localeval
|
||||||
|
|
||||||
|
if self.config.has_option(self.getsection(), 'remoteusereval'):
|
||||||
|
user = self.getconf('remoteusereval')
|
||||||
|
if user != None:
|
||||||
|
return localeval.eval(user)
|
||||||
|
|
||||||
|
user = self.getconf('remoteuser')
|
||||||
|
if user != None:
|
||||||
|
return user
|
||||||
|
|
||||||
def getport(self):
|
def getport(self):
|
||||||
return self.getconfint('remoteport', None)
|
return self.getconfint('remoteport', None)
|
||||||
@ -109,6 +129,14 @@ class IMAPRepository(BaseRepository):
|
|||||||
return self.getconfboolean('expunge', 1)
|
return self.getconfboolean('expunge', 1)
|
||||||
|
|
||||||
def getpassword(self):
|
def getpassword(self):
|
||||||
|
passwd = None
|
||||||
|
localeval = self.localeval
|
||||||
|
|
||||||
|
if self.config.has_option(self.getsection(), 'remotepasseval'):
|
||||||
|
passwd = self.getconf('remotepasseval')
|
||||||
|
if passwd != None:
|
||||||
|
return localeval.eval(passwd)
|
||||||
|
|
||||||
password = self.getconf('remotepass', None)
|
password = self.getconf('remotepass', None)
|
||||||
if password != None:
|
if password != None:
|
||||||
return password
|
return password
|
||||||
|
Loading…
Reference in New Issue
Block a user