Changeset 4811 for waeup/branches/ulif-importers/src
- Timestamp:
- 14 Jan 2010, 17:29:16 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-importers/src/waeup/utils/batching.py
r4806 r4811 86 86 87 87 def applyMapping(self, row, mapping): 88 """Apply mapping to a row of CSV data. 89 """ 88 90 result = dict() 89 91 for key, replacement in mapping.items(): … … 92 94 93 95 def getMapping(self, path, headerfields): 96 """Get a mapping from CSV file headerfields to actually used 97 fieldnames. 98 """ 94 99 reader = csv.reader(open(path, 'rb')) 95 100 raw_header = reader.next() … … 98 103 99 104 def getFieldConverters(self, fieldnames): 105 """Get converters for fieldnames. 106 """ 100 107 result = dict() 101 108 for key, field in getFields(self.iface).items(): … … 107 114 108 115 def convertToTypes(self, row, converter_dict): 116 """Convert values in given row to destination type. 117 """ 109 118 if '--IGNORE--' in row.keys(): 110 119 del row['--IGNORE--'] … … 112 121 converter = converter_dict.get(key, None) 113 122 if converter: 114 row.update({key:converter_dict[key]. convert(value)})123 row.update({key:converter_dict[key].fromString(value)}) 115 124 return row 116 125 … … 119 128 120 129 def parentsExist(self, row, site): 130 """Tell whether the parent object for data in ``row`` exists. 131 """ 121 132 raise NotImplementedError('method not implemented') 122 133 123 134 def entryExists(self, row, site): 135 """Tell whether there already exists an entry for ``row`` data. 136 """ 124 137 raise NotImplementedError('method not implemented') 125 138 126 139 def getParent(self, row, site): 140 """Get the parent object for the entry in ``row``. 141 """ 127 142 raise NotImplementedError('method not implemented') 128 143 129 144 def addEntry(self, obj, row, site): 145 """Add the entry given given by ``row`` data. 146 """ 130 147 raise NotImplementedError('method not implemented') 131 148 132 149 def delEntry(self, row, site): 150 """Delete entry given by ``row`` data. 151 """ 133 152 raise NotImplementedError('method not implemented') 134 153 135 154 def updateEntry(self, obj, row, site): 155 """Update entry given by ``row`` with data delivered therein. 156 """ 136 157 raise NotImplementedError('method not implemented') 137 158 138 159 def doImport(self, path, headerfields, mode='create'): 160 """Perform actual import. 161 """ 139 162 self.checkHeaders(headerfields, mode) 140 163 mapping = self.getMapping(path, headerfields)
Note: See TracChangeset for help on using the changeset viewer.