|
From: Robert Š. <smo...@gm...> - 2009-07-03 07:07:28
|
Hi,
response is unbelievable quick enough if compared to our R&D ;)
Here is the code to reproduce the problem:
>>>>>>>>>>>>>>>>>>
from configobj import ConfigObj, flatten_errors
from validate import Validator
#some defaults
_pidFile = '/var/run/xdr.pid'
_defaultLogFormat = '%(asctime)s - %(levelname)s - %(message)s'
#configspec is used to validate configuration file
_configspec = ('''
[general]
pid_file = string(min=1, max=100, default=%s)
[logging]
level= option('INFO','DEBUG','CRITICAL','ERROR', default='INFO')
log_format = string(min=1, max=100, default=%s)
''' % (_pidFile, _defaultLogFormat)).split('\n')
#dummy config file
configFile = ''
#main loop, if called as a program start main
if __name__ == '__main__':
validator = Validator()
config = ConfigObj(configFile,configspec=_configspec)
results = config.validate(validator)
<<<<<<<<<<<<<<<<
The problem is, config['log_format'] should be '%(asctime)s -
%(levelname)s - %(message)s'
and the values 'asctime' are interpolated when using logging facility,
but they are evaluated during validation. Perhaps I just need to
somehow properly escape?
Thanks,
Robert
On Thu, Jul 2, 2009 at 4:51 PM, Michael Foord<fuz...@vo...> wrote:
> Robert Šmol wrote:
>> Hi,
>> I have following for my config spec:
>>
>> _defaultLogFormat = '%(asctime)s - %(levelname)s - %(message)s'
>> _configspec = ('''
>> [general]
>> log_format = string(min=1, max=100, default=%s)
>> ''' % (_defaultLogFormat)).split('\n')
>>
>> When I execute I get the MissingInterpolationError
>> ...
>> ..
>> File "/var/lib/python-support/python2.5/configobj.py", line 368, in
>> recursive_interpolate
>> k, v, s = self._parse_match(match)
>> File "/var/lib/python-support/python2.5/configobj.py", line 454, in
>> _parse_match
>> value, section = self._fetch(key)
>> File "/var/lib/python-support/python2.5/configobj.py", line 424, in _fetch
>> raise MissingInterpolationOption(key)
>> configobj.MissingInterpolationOption: missing option "asctime" in interpolation.
>>
>> How do I get round this?
>>
>
> Sorry for the slow response I'm currently at EuroPython. Can you send me
> a config file and *full* code to reproduce this.
>
> Thanks
>
> Michael
>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Configobj-develop mailing list
>> Con...@li...
>> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>>
>
>
> --
> http://www.ironpythoninaction.com/
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
|