VirtualMailManager/ext/Postconf.py
changeset 87 f9090d1a0730
parent 86 e43e4e7e9ec0
child 89 752d3b57ebb6
equal deleted inserted replaced
86:e43e4e7e9ec0 87:f9090d1a0730
     1 # -*- coding: UTF-8 -*-
     1 # -*- coding: UTF-8 -*-
     2 # Copyright 2007-2008 VEB IT
     2 # Copyright 2008 VEB IT
     3 # See COPYING for distribution information.
     3 # See COPYING for distribution information.
     4 # $Id$
     4 # $Id$
     5 
     5 
     6 """A small - r/o - wrapper class for Postfix' postconf."""
     6 """A small - r/o - wrapper class for Postfix' postconf."""
     7 
     7 
    28         Keyword arguments:
    28         Keyword arguments:
    29         postconf_bin -- absolute path to Postfix' postconf binary (str)
    29         postconf_bin -- absolute path to Postfix' postconf binary (str)
    30         """
    30         """
    31         self.__bin = postconf_bin
    31         self.__bin = postconf_bin
    32         self.__val = ''
    32         self.__val = ''
    33         re.compile(RE_PC_PARAMS)
    33         self.__varFinder = re.compile(RE_PC_VARIABLES)
    34         re.compile(RE_PC_VARIABLES)
       
    35 
    34 
    36     def read(self, parameter, expand_vars=True):
    35     def read(self, parameter, expand_vars=True):
    37         """Returns the parameters value.
    36         """Returns the parameters value.
    38 
    37 
    39         If expand_vars is True (default), all variables in the value will be 
    38         If expand_vars is True (default), all variables in the value will be 
    54             self.__expandVars()
    53             self.__expandVars()
    55         return self.__val
    54         return self.__val
    56 
    55 
    57     def __expandVars(self):
    56     def __expandVars(self):
    58         while True:
    57         while True:
    59             pvars = set(re.findall(RE_PC_VARIABLES, self.__val))
    58             pvars = set(self.__varFinder.findall(self.__val))
    60             pvars_len = len(pvars)
    59             pvars_len = len(pvars)
    61             if pvars_len < 1:
    60             if pvars_len < 1:
    62                 break
    61                 break
    63             if pvars_len > 1:
    62             if pvars_len > 1:
    64                 self.__expandMultiVars(self.__readMulti(pvars))
    63                 self.__expandMultiVars(self.__readMulti(pvars))