Changeset 4224 for waeup/branches/ulif-rewrite/src
- Timestamp:
- 8 Jun 2009, 17:00:37 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-rewrite/src/waeup/datacenter.py
r4190 r4224 10 10 import grok 11 11 from datetime import datetime 12 from zope.component import getUtility 12 from zope.component import getUtility, getMultiAdapter 13 13 from zope.interface import Interface 14 from waeup.csvfile import getCSVFile 14 15 from waeup.interfaces import IWAeUPObject, IWAeUPCSVImporter, ICSVDataReceivers 15 16 from waeup.utils.helpers import copyFileSystemTree … … 51 52 result = [] 52 53 receivers = self.getReceivers() 54 files = self.getFiles() 53 55 for receiver in receivers: 54 try: 55 importer = IWAeUPCSVImporter(receiver) 56 result.append(importer) 57 except: 58 pass 56 for file in files: 57 wrapped_file = getCSVFile(file.context) 58 try: 59 importer = getMultiAdapter((wrapped_file, receiver), 60 IWAeUPCSVImporter) 61 result.append(importer) 62 except: 63 # No multi-adapter for this combination available... 64 pass 59 65 return result 60 66 … … 97 103 attr = getattr(obj, attr_name) 98 104 # This might fail... 99 IWAeUPCSVImporter(attr)105 #IWAeUPCSVImporter(attr) 100 106 result.append(attr) 101 107 except: … … 118 124 possible_importers = [] 119 125 for importer in importers: 120 try:121 # We could also try a complete parse...122 importer.checkHeader(filedescr.context)123 except:124 continue125 126 importer_context = ( 126 importer, self.getReceiverId(importer. context))127 importer, self.getReceiverId(importer.receiver)) 127 128 possible_importers.append(importer_context) 128 129 if len(possible_importers) == 0: … … 153 154 return 'z%s' % struct.unpack('>Q', oid)[0] 154 155 155 def doImport(self, csvfile, receiverid, clear=None):156 def doImport(self, path, receiverid, clear=None): 156 157 receivers = self.getReceiverIds() 157 158 if receiverid not in receivers.keys(): 158 159 raise ValueError('The requested data receiver cannot be found.') 159 160 receiver = receivers[receiverid] 160 importer = IWAeUPCSVImporter(receiver) 161 filewrapper = getCSVFile(path) 162 if filewrapper is None: 163 raise ValueError('Format of CSV file not supported.') 164 importer = getMultiAdapter((filewrapper, receiver), IWAeUPCSVImporter) 161 165 if clear is not None: 162 importer.doImport(c svfile, clear_old_data=clear)166 importer.doImport(clear_old_data=clear) 163 167 else: 164 importer.doImport( csvfile)168 importer.doImport() 165 169 return 166 170
Note: See TracChangeset for help on using the changeset viewer.