Ignore:
Timestamp:
4 Jun 2011, 11:17:28 (13 years ago)
Author:
uli
Message:

Remove old converters and disable tests for them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/batching.py

    r6273 r6276  
    1515from zope.schema import getFields
    1616from waeup.sirp.interfaces import (
    17     IBatchProcessor, ISchemaTypeConverter, FatalCSVError, DuplicationError,
    18     IObjectConverter)
     17    IBatchProcessor, FatalCSVError, DuplicationError, IObjectConverter)
    1918
    2019class BatchProcessor(grok.GlobalUtility):
     
    122121            result[raw_header[num]] = field
    123122        return result
    124 
    125     def getFieldConverters(self, fieldnames):
    126         """Get converters for fieldnames.
    127         """
    128         result = dict()
    129         for key, field in getFields(self.iface).items():
    130             if key not in fieldnames:
    131                 continue
    132             converter = ISchemaTypeConverter(field)
    133             result[key] = converter
    134         return result
    135 
    136     def convertToTypes(self, row, converter_dict):
    137         """Convert values in given row to destination type.
    138         """
    139         if '--IGNORE--' in row.keys():
    140             del row['--IGNORE--']
    141         warnings = []
    142         for key, value in row.items():
    143             converter = converter_dict.get(key, None)
    144             if converter:
    145                 try:
    146                     row.update({key:converter_dict[key].fromString(value)})
    147                 except:
    148                     msg = "conversion error: field %s: %s %r" % (
    149                         key, sys.exc_info()[0], sys.exc_info()[1])
    150                     warnings.append(msg)
    151         return (row, warnings)
    152123
    153124    def stringFromErrs(self, errors, inv_errors):
     
    244215        self.checkHeaders(headerfields, mode)
    245216        mapping = self.getMapping(path, headerfields, mode)
    246         converters = self.getFieldConverters(headerfields)
    247217        reader = csv.DictReader(open(path, 'rb'))
    248218
Note: See TracChangeset for help on using the changeset viewer.