|
From: <ale...@se...> - 2009-08-26 15:29:29
|
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.
***********************************************************************
|