Update of /cvsroot/dbfpy/dbfpy/dbfpy
In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv25748
Modified Files:
fields.py
Log Message:
DbfNumericFieldDef decoding looks for decimal point
in the value to select float or integer return type
Index: fields.py
===================================================================
RCS file: /cvsroot/dbfpy/dbfpy/dbfpy/fields.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** fields.py 13 Mar 2008 06:09:52 -0000 1.11
--- fields.py 16 Sep 2008 06:04:19 -0000 1.12
***************
*** 5,8 ****
--- 5,10 ----
"""
"""History (most recent first):
+ 16-sep-2008 [als] DbfNumericFieldDef decoding looks for decimal point
+ in the value to select float or integer return type
13-mar-2008 [als] check field name length in constructor
11-feb-2007 [als] handle value conversion errors
***************
*** 233,245 ****
"""
value = value.strip()
! if self.decimalCount > 0:
! # a float (has decimal digits)
! if value:
! return float(value)
! return 0.0
else:
- # an integer
- if value:
- return int(value)
return 0
--- 235,245 ----
"""
value = value.strip()
! if "." in value:
! # a float (has decimal separator)
! return float(value)
! elif value and value.strip():
! # must be an integer
! return int(value)
else:
return 0
|