From: alexander s. <a1...@us...> - 2007-02-11 09:21:31
|
Update of /cvsroot/dbfpy/dbfpy/dbfpy In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv17311 Modified Files: header.py Log Message: added .ignoreErrors Index: header.py =================================================================== RCS file: /cvsroot/dbfpy/dbfpy/dbfpy/header.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** header.py 10 Feb 2007 19:45:15 -0000 1.4 --- header.py 11 Feb 2007 09:21:28 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- """ """History (most recent first): + 11-feb-2007 [als] added .ignoreErrors 10-feb-2007 [als] added __getitem__: return field definitions by field name or field number (zero-based) *************** *** 49,58 **** __slots__ = ("signature", "fields", "lastUpdate", "recordLength", ! "recordCount", "headerLength", "changed") ## instance construction and initialization methods ! def __init__(self, fields=None, headerLength=0, recordLength=0, recordCount=0, ! signature=0x03, lastUpdate=None ): """Initialize instance. --- 50,59 ---- __slots__ = ("signature", "fields", "lastUpdate", "recordLength", ! "recordCount", "headerLength", "changed", "_ignore_errors") ## instance construction and initialization methods ! def __init__(self, fields=None, headerLength=0, recordLength=0, ! recordCount=0, signature=0x03, lastUpdate=None, ignoreErrors=False, ): """Initialize instance. *************** *** 76,79 **** --- 77,82 ---- a sequence (assuming (yyyy, mm, dd, ...)) or an object having callable ``ticks`` field. + ignoreErrors: + error processing mode for DBF fields (boolean) """ *************** *** 87,90 **** --- 90,94 ---- self.headerLength = headerLength self.recordCount = recordCount + self.ignoreErrors = ignoreErrors # XXX: I'm not sure this is safe to # initialize `self.changed` in this way *************** *** 126,129 **** --- 130,148 ---- day = property(lambda self: self.lastUpdate.day) + def ignoreErrors(self, value): + """Update `ignoreErrors` flag on self and all fields""" + self._ignore_errors = value = bool(value) + for _field in self.fields: + _field.ignoreErrors = value + ignoreErrors = property( + lambda self: self._ignore_errors, + ignoreErrors, + doc="""Error processing mode for DBF field value conversion + + if set, failing field value conversion will return + ``INVALID_VALUE`` instead of raising conversion error. + + """) + ## object representation *************** *** 167,171 **** (_name, _type, _len, _dec) = (tuple(_def) + (None,) * 4)[:4] _cls = fields.lookupFor(_type) ! _obj = _cls(_name, _len, _dec) _recordLength += _obj.length _defs.append(_obj) --- 186,191 ---- (_name, _type, _len, _dec) = (tuple(_def) + (None,) * 4)[:4] _cls = fields.lookupFor(_type) ! _obj = _cls(_name, _len, _dec, ! ignoreErrors=self._ignore_errors) _recordLength += _obj.length _defs.append(_obj) |