Introduce CustomConfig method that applies set of transforms

It is a bit cleaner than making chains of calls like
{{{
value = os.path.expanduser(value)
value = os.path.abspath(value)
}}}
since we do see all transformations to be applied in a single
iterable and have no repeated code like in the above example.

Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
Eygene Ryabinkin
2014-11-02 11:14:42 +03:00
parent dbf683ed38
commit 8f3c22e227
3 changed files with 101 additions and 7 deletions

View File

@ -201,11 +201,11 @@ class IMAPRepository(BaseRepository):
def getsslcacertfile(self):
"""Return the absolute path of the CA certfile to use, if any"""
cacertfile = self.getconf('sslcacertfile', get_os_sslcertfile())
xforms = [os.path.expanduser, os.path.abspath]
cacertfile = self.getconf_xform('sslcacertfile', xforms,
get_os_sslcertfile())
if cacertfile is None:
return None
cacertfile = os.path.expanduser(cacertfile)
cacertfile = os.path.abspath(cacertfile)
if not os.path.isfile(cacertfile):
raise SyntaxWarning("CA certfile for repository '%s' could "
"not be found. No such file: '%s'" \

View File

@ -61,7 +61,8 @@ class MaildirRepository(BaseRepository):
os.utime(cur_dir, (cur_atime, os.path.getmtime(cur_dir)))
def getlocalroot(self):
return os.path.expanduser(self.getconf('localfolders'))
xforms = [os.path.expanduser]
return self.getconf_xform('localfolders', xforms)
def debug(self, msg):
self.ui.debug('maildir', msg)