|
From: Jeremy G. <jr...@gm...> - 2009-10-15 01:43:50
|
Michael
thanks for such a quick reply!
> I have a version 4.7 in the works that I am part way through with
> various improvements / bugfixes so I can make sure this issue is included.
cool
>> 2. how are missing sections reported by a Validator()?
> I'm not seeing that behavior, can you provide a minimal repro.
I think I have a repro but am not positive I am doing everything
right. its not ultra-minimal because I used two text files, doing so
because this is close to my actual arrangement. its the first thing I
tried and seems to reproduce the lack of error reported for a missing
section. at the very least, going through this will reveal more
precisely what I am confused about.
so one file is 'test.cfg' and contains 4 lines (3rd line is blank--its
where I would have a section named [b] but I deleted it from the text
file):
[a]
a1 = 2
b1 = dsa
the other file is 'test.spec' and also has 4 lines:
[a]
a1 = integer(default=2)
[b]
b1 = integer(default=1)
then interactively:
>>> import configobj
>>> configobj.__version__
'4.6.0'
>>> from configobj import ConfigObj, flatten_errors
>>> from validate import Validator
>>> sp = ConfigObj('test.spec')
>>> sp
ConfigObj({'a': {'a1': 'integer(default=2)'}, 'b': {'b1':
'integer(default=1)'}})
>>> cfg = ConfigObj('test.cfg', configspec=sp)
>>> cfg
ConfigObj({'a': {'a1': '2', 'b1': 'dsa'}})
>>> v = Validator()
>>> r = cfg.validate(v)
>>> r
True
>>> flatten_errors(cfg, r)
[]
>>> cfg['a']
{'a1': 2, 'b1': 'dsa'}
>>> cfg['b']
{'b1': 1}
it seems like:
- b1 ends up in cfg[a] and is is not getting flagged as invalid
- [b] is in sp / test.spec but is not flagged as missing in cfg /
test.cfg--which surprises me
- after validation there is now a section [b] in cfg but it contains
stuff from the spec, namely the default value b1 = 1. I'm surprised
that [b] shows up at all. the fact that is does could explain why I
get a "duplicate section error" if I add the section back into my cfg
file (in my code).
I also tried doing the above but with an explicit copy=False in the
validation step, but still get section [b] showing up in cfg
>>> r = cfg.validate(v, copy=False)
>>> r
True
>>> cfg['b']
{'b1': 1}
thanks for any clarification on what should be happening
>> 3. finally, does anyone know of an existing project I could look at
>> (and borrow from) that uses wxPython for a GUI for letting users
>> manipulate configobj data?
>
> I can't help with this one I'm afraid.
ah well. maybe someone else will know of a wx example?
of course, just having configobj is a huge help! thanks again,
--Jeremy
|