Ignore:
Timestamp:
14 Jan 2010, 17:29:16 (15 years ago)
Author:
uli
Message:

Respect new converter API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-importers/src/waeup/utils/batching.py

    r4806 r4811  
    8686
    8787    def applyMapping(self, row, mapping):
     88        """Apply mapping to a row of CSV data.
     89        """
    8890        result = dict()
    8991        for key, replacement in mapping.items():
     
    9294       
    9395    def getMapping(self, path, headerfields):
     96        """Get a mapping from CSV file headerfields to actually used
     97           fieldnames.
     98        """
    9499        reader = csv.reader(open(path, 'rb'))
    95100        raw_header = reader.next()
     
    98103
    99104    def getFieldConverters(self, fieldnames):
     105        """Get converters for fieldnames.
     106        """
    100107        result = dict()
    101108        for key, field in getFields(self.iface).items():
     
    107114   
    108115    def convertToTypes(self, row, converter_dict):
     116        """Convert values in given row to destination type.
     117        """
    109118        if '--IGNORE--' in row.keys():
    110119            del row['--IGNORE--']
     
    112121            converter = converter_dict.get(key, None)
    113122            if converter:
    114                 row.update({key:converter_dict[key].convert(value)})
     123                row.update({key:converter_dict[key].fromString(value)})
    115124        return row
    116125
     
    119128
    120129    def parentsExist(self, row, site):
     130        """Tell whether the parent object for data in ``row`` exists.
     131        """
    121132        raise NotImplementedError('method not implemented')
    122133
    123134    def entryExists(self, row, site):
     135        """Tell whether there already exists an entry for ``row`` data.
     136        """
    124137        raise NotImplementedError('method not implemented')
    125138
    126139    def getParent(self, row, site):
     140        """Get the parent object for the entry in ``row``.
     141        """
    127142        raise NotImplementedError('method not implemented')
    128143   
    129144    def addEntry(self, obj, row, site):
     145        """Add the entry given given by ``row`` data.
     146        """
    130147        raise NotImplementedError('method not implemented')
    131148
    132149    def delEntry(self, row, site):
     150        """Delete entry given by ``row`` data.
     151        """
    133152        raise NotImplementedError('method not implemented')       
    134153
    135154    def updateEntry(self, obj, row, site):
     155        """Update entry given by ``row`` with data delivered therein.
     156        """
    136157        raise NotImplementedError('method not implemented')
    137158   
    138159    def doImport(self, path, headerfields, mode='create'):
     160        """Perform actual import.
     161        """
    139162        self.checkHeaders(headerfields, mode)
    140163        mapping = self.getMapping(path, headerfields)
Note: See TracChangeset for help on using the changeset viewer.