|
From: Jim C. <jac...@ma...> - 2014-04-28 20:07:33
|
As best I can remember, strings in configobj files don't require quoting, so your foo.cfg is in fact valid. (i.e. FOOBAR = 1 gives you a valid string, "1"). I can't address your crash, I'm using configobj 4.7.2 and it doesn't happen in my setup. -Jim C. > Date: Sun, 27 Apr 2014 21:22:12 -0700 > From: Mario Aranha <ma...@se...> > Subject: [Configobj-develop] configobj 5.0.4 on Linux > To: con...@li... > Message-ID: <535...@se...> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > I'm trying to use 'configobj' but not having much success: > (1) It appears that validate() ALWAYS returns True, even if my config > file does not conform to spec. > (2) If I repeat one of the sub-sections in the "many" section I get: > Traceback (most recent call last): > File "./config.py", line 7, in <module> > config = ConfigObj(infile="foo.cfg", configspec="foo.spec") > File "/home/glarms/python/site-packages/configobj.py", line 1229, in > __init__ > self._load(infile, configspec) > File "/home/glarms/python/site-packages/configobj.py", line 1318, in > _load > raise error > configobj.ConfigObjError: Parsing failed with several errors. > First error at line 14. > > Attached is my (simple) example program, config and spec files. > Any help would be much appreciated. > > :::::::::::::: > config.py > :::::::::::::: > #!/usr/bin/python > > import os, sys > from configobj import ConfigObj, ConfigObjError, flatten_errors > from validate import Validator, ValidateError > > config = ConfigObj(infile="foo.cfg", configspec="foo.spec") > vtor = Validator() > results = config.validate(vtor, preserve_errors=True) > print "results=", results > :::::::::::::: > foo.cfg > :::::::::::::: > # > # example config file > # > > # global options > [DEFAULT] > FOOBAR = 1 > JUNK = 0 > > # baseline options > [CHANNELS] > [[SRB1-BRIB]] > instance = 0 > [[OHLN-BRIB]] > instance = 0 > > :::::::::::::: > foo.spec > :::::::::::::: > # > # config spec file for G-larnS > # > [DEFAULT] > FOOBAR = string > JUNK = integer > > [CHANNELS] > [[__many__]] > instance = integer(default=0) > off = boolean(default=False) > > -- > Mario Aranha University of California, Berkeley > ma...@se... Berkeley Seismological Laboratory > Office: 510-643-3898 215 McCone Hall # 4760 > Fax: 510-643-5811 Berkeley, CA 94720-4760 > > > > > ------------------------------ > > Message: 6 > Date: Mon, 28 Apr 2014 17:03:04 +0200 > From: Werner <wer...@gm...> > Subject: [Configobj-develop] pip install on Py 3.4 > To: con...@li... > Message-ID: <535...@gm...> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hi, > > I am just trying out configobj and validate and I get this error when > trying to install validate on Py 3.4 I get the following error. > > configobj installed fine, is validate not yet Py3 compatible? > > Werner > > C:\Python34\Scripts\pip3.4 run on 04/28/14 16:50:00 > Downloading/unpacking validate > Getting page https://pypi.python.org/simple/validate/ > URLs to search for versions for validate: > * https://pypi.python.org/simple/validate/ > Analyzing links from page https://pypi.python.org/simple/validate/ > Found link > https://pypi.python.org/packages/source/v/validate/validate-1.0.0.tar.gz#md5=bc6418183b86dd68e8179b9c0d0ebc33 > (from https://pypi.python.org/simple/validate/), version: 1.0.0 > Found link > https://pypi.python.org/packages/source/v/validate/validate-1.0.1.tar.gz#md5=344d67d133de0e1d824f0f6d74dba97a > (from https://pypi.python.org/simple/validate/), version: 1.0.1 > Skipping link http://www.voidspace.org.uk/python/configobj.html > (from https://pypi.python.org/simple/validate/); unknown archive format: > .html > Skipping link http://www.voidspace.org.uk/python/validate.html > (from https://pypi.python.org/simple/validate/); unknown archive format: > .html > Using version 1.0.1 (newest of versions: 1.0.1, 1.0.0) > Downloading validate-1.0.1.tar.gz > Downloading from URL > https://pypi.python.org/packages/source/v/validate/validate-1.0.1.tar.gz#md5=344d67d133de0e1d824f0f6d74dba97a > (from https://pypi.python.org/simple/validate/) > Running setup.py > (path:C:\Users\wbruhin\AppData\Local\Temp\pip_build_wbruhin\validate\setup.py) > egg_info for package validate > Traceback (most recent call last): > File "<string>", line 17, in <module> > File > "C:\Users\wbruhin\AppData\Local\Temp\pip_build_wbruhin\validate\setup.py", > line 13, in <module> > from configobj import __version__ as VERSION > File > "C:\Users\wbruhin\AppData\Local\Temp\pip_build_wbruhin\validate\configobj.py", > line 1632 > except Exception, e: > ^ > SyntaxError: invalid syntax > Complete output from command python setup.py egg_info: > Traceback (most recent call last): > > File "<string>", line 17, in <module> > > File > "C:\Users\wbruhin\AppData\Local\Temp\pip_build_wbruhin\validate\setup.py", > line 13, in <module> > > from configobj import __version__ as VERSION > > File > "C:\Users\wbruhin\AppData\Local\Temp\pip_build_wbruhin\validate\configobj.py", > line 1632 > > except Exception, e: > > ^ > > SyntaxError: invalid syntax > > > > > > ------------------------------ > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform > available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > > ------------------------------ > > _______________________________________________ > Configobj-develop mailing list > Con...@li... > https://lists.sourceforge.net/lists/listinfo/configobj-develop > > > End of Configobj-develop Digest, Vol 64, Issue 1 > ************************************************ |