VirtualMailManager/ext/Postconf.py
changeset 89 752d3b57ebb6
parent 87 f9090d1a0730
child 102 485d3f7d6981
equal deleted inserted replaced
88:b3debcfea7bc 89:752d3b57ebb6
    45         parameter -- the name of a Postfix configuration parameter (str)
    45         parameter -- the name of a Postfix configuration parameter (str)
    46         expand_vars -- default True (bool)
    46         expand_vars -- default True (bool)
    47         """
    47         """
    48         if not re.match(RE_PC_PARAMS, parameter):
    48         if not re.match(RE_PC_PARAMS, parameter):
    49             raise VMMException(_(u'The value »%s« looks not like a valid\
    49             raise VMMException(_(u'The value »%s« looks not like a valid\
    50  postfix configuration parameter name.'), ERR.INVALID_AGUMENT)
    50  postfix configuration parameter name.') % parameter, ERR.INVALID_AGUMENT)
    51         self.__val = self.__read(parameter)
    51         self.__val = self.__read(parameter)
    52         if expand_vars:
    52         if expand_vars:
    53             self.__expandVars()
    53             self.__expandVars()
    54         return self.__val
    54         return self.__val
    55 
    55 
    60             if pvars_len < 1:
    60             if pvars_len < 1:
    61                 break
    61                 break
    62             if pvars_len > 1:
    62             if pvars_len > 1:
    63                 self.__expandMultiVars(self.__readMulti(pvars))
    63                 self.__expandMultiVars(self.__readMulti(pvars))
    64                 continue
    64                 continue
    65             for var in pvars:
    65             pvars = pvars.pop()
    66                 self.__val = self.__val.replace(var, self.__read(var[1:]))
    66             self.__val = self.__val.replace(pvars, self.__read(pvars[1:]))
    67 
    67 
    68     def __expandMultiVars(self, old_new):
    68     def __expandMultiVars(self, old_new):
    69         for old, new in old_new.items():
    69         for old, new in old_new.items():
    70             self.__val = self.__val.replace('$'+old, new)
    70             self.__val = self.__val.replace('$'+old, new)
    71 
    71