|
From: Michael F. <fuz...@vo...> - 2009-08-26 20:09:31
|
Hello Alex,
I'm afraid empty values like that aren't valid syntax in ConfigObj
config files - yes empty quotes ("") can be used to represent empty
values in a config file.
All the best,
Michael
ale...@se... wrote:
> I've been hoping to use configobj to read database field parameters into a
> script using configobj. Preserving the order of keys and in built list
> handling make it a very nice fit.
>
> I've come up against a parsing error, when a list contains an empty value
> represented by 2 adjacent commas (i.e. ,,)
>
> PythonWin 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
> (Intel)] on win32.import
> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
> further copyright information.
>
>>>> import os
>>>> os.chdir('h:/src/localview')
>>>> import configobj
>>>> configobj.ConfigObj('tmp.ini')
>>>>
> ConfigObj({'Fields': {'Name': ['TEXT', '0', '0', '100', 'NULLABLE',
> 'NON_REQUIRED']}})
>
>>>> configobj.ConfigObj('tmp2.ini')
>>>>
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> File "configobj.py", line 1219, in __init__
> self._load(infile, configspec)
> File "configobj.py", line 1302, in _load
> raise error
> ParseError: Parse error in value at line 2.
>
>>>> for line in open('tmp.ini'): print repr(line)
>>>>
> ...
> '[Fields]\n'
> 'Name = TEXT,0,0,100,NULLABLE,NON_REQUIRED,\n'
> '\n'
>
>>>> for line in open('tmp2.ini'): print repr(line)
>>>>
> ...
> '[Fields]\n'
> 'Name = TEXT,0,0,100,,NULLABLE,NON_REQUIRED,\n'
> '\n'
>
>
> Should this be submitted as a bug, or should I be putting quotes around all
> empty values?
>
> Regards, Alex
> --
> Alex Willmer <ale...@se...>
> Application Support Analyst, Property & GIS Application Support Team
> Service Birmingham, Units 2 & 3, B1 Building, Summer Hill Rd, Birmingham,
> B1 3RB
> Tel +44 (0)121 3033653 Mob +44 (0)7833 059297
>
>
> ***********************************************************************
> The information contained within this e-mail (and any attachment) sent by Service Birmingham Ltd. is confidential and may be legally privileged. It is intended only for the named recipient or entity to whom it is addressed. If you are not the intended recipient, please notify the sender and delete the e-mail immediately. Unauthorised access, use, disclosure, storage or copying is not permitted and may be unlawful. Any e-mail including its content may be monitored and used by Service Birmingham Ltd. for reasons of security and for monitoring internal compliance with Security Policy. E-mail blocking software will also be used. Any views or opinions expressed are solely those of the originator and do not necessarily represent those of Service Birmingham Ltd.
>
> Although Service Birmingham Ltd. has made every reasonable effort to ensure that this message and any attachments contain no viruses and have not been intercepted or amended, it can not make any assurances to this effect.
>
> Service Birmingham Ltd, Registered in England & Wales under Company No: 05660977
> Registered Office: Units 2&3 B1, 50 Summer Hill Road, Birmingham, B1 3RB.
> ***********************************************************************
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|