[CMF-checkins] CVS: CMF/CMFCore - FSPropertiesObject.py:1.6
Tres Seaver
tseaver@zope.com
Wed, 14 Nov 2001 23:53:53 -0500
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv374/CMFCore
Modified Files:
FSPropertiesObject.py
Log Message:
- Made error message generated by FSPropertiesObject capture the
offending line and line #; also, added logic to allow blank
lines and comment lines beginning with '#' (tracker #338).
=== CMF/CMFCore/FSPropertiesObject.py 1.5 => 1.6 ===
fp = expandpath(self._filepath)
+
file = open(fp, 'rb')
- try: lines = file.readlines()
- finally: file.close()
+ try:
+ lines = file.readlines()
+ finally:
+ file.close()
+
map = []
+ lino=0
+
for line in lines:
- propname, proptv = split( line, ':' )
- #XXX multi-line properties?
- proptype, propvstr = split( proptv, '=' )
- propname = strip(propname)
- proptv = strip(proptv)
- propvstr = strip(propvstr)
- converter = get_converter( proptype, lambda x: x )
- propvalue = converter( strip( propvstr ) )
- # Should be safe since we're loading from
- # the filesystem.
- setattr(self, propname, propvalue)
- map.append({'id':propname,
- 'type':proptype,
- 'mode':'',
- 'default_value':propvalue,
- })
+
+ lino = lino + 1
+ line = strip( line )
+
+ if not line or line[0] == '#':
+ continue
+
+ try:
+ propname, proptv = split( line, ':' )
+ #XXX multi-line properties?
+ proptype, propvstr = split( proptv, '=' )
+ propname = strip(propname)
+ proptv = strip(proptv)
+ propvstr = strip(propvstr)
+ converter = get_converter( proptype, lambda x: x )
+ propvalue = converter( strip( propvstr ) )
+ # Should be safe since we're loading from
+ # the filesystem.
+ setattr(self, propname, propvalue)
+ map.append({'id':propname,
+ 'type':proptype,
+ 'mode':'',
+ 'default_value':propvalue,
+ })
+ except:
+ import pdb; pdb.set_trace()
+ raise ValueError, ( 'Error processing line %s of %s:\n%s'
+ % (lino,fp,line) )
self._properties = tuple(map)
if Globals.DevelopmentMode: