VirtualMailManager/ext/postconf.py
branchv0.7.x
changeset 643 df1e3b67882a
parent 608 0ed93eb8b364
child 653 cf07e4468934
equal deleted inserted replaced
642:4cd9d0a9f42f 643:df1e3b67882a
    79 
    79 
    80     def _check_parameter(self, parameter):
    80     def _check_parameter(self, parameter):
    81         """Check that the `parameter` looks like a configuration parameter.
    81         """Check that the `parameter` looks like a configuration parameter.
    82         If not, a VMMError will be raised."""
    82         If not, a VMMError will be raised."""
    83         if not self.__class__._parameter_re.match(parameter):
    83         if not self.__class__._parameter_re.match(parameter):
    84             raise VMMError(_(u"The value '%s' does not look like a valid "
    84             raise VMMError(_("The value '%s' does not look like a valid "
    85                              u"Postfix configuration parameter name.") %
    85                              "Postfix configuration parameter name.") %
    86                            parameter, VMM_ERROR)
    86                            parameter, VMM_ERROR)
    87 
    87 
    88     def _expand_vars(self):
    88     def _expand_vars(self):
    89         """Expand the $variables in self._val to their values."""
    89         """Expand the $variables in self._val to their values."""
    90         while True:
    90         while True:
    97             pvars = pvars.pop()
    97             pvars = pvars.pop()
    98             self._val = self._val.replace(pvars, self._read(pvars[1:]))
    98             self._val = self._val.replace(pvars, self._read(pvars[1:]))
    99 
    99 
   100     def _expand_multi_vars(self, old_new):
   100     def _expand_multi_vars(self, old_new):
   101         """Replace all $vars in self._val with their values."""
   101         """Replace all $vars in self._val with their values."""
   102         for old, new in old_new.iteritems():
   102         for old, new in old_new.items():
   103             self._val = self._val.replace('$' + old, new)
   103             self._val = self._val.replace('$' + old, new)
   104 
   104 
   105     def _read(self, parameter):
   105     def _read(self, parameter):
   106         """Ask postconf for the value of a single configuration parameter."""
   106         """Ask postconf for the value of a single configuration parameter."""
   107         stdout, stderr = Popen([self._bin, '-h', parameter], stdout=PIPE,
   107         stdout, stderr = Popen([self._bin, '-h', parameter], stdout=PIPE,