--- ZSQLExtend/importCDLIimglist.py 2007/12/31 09:47:12 1.2 +++ ZSQLExtend/importCDLIimglist.py 2009/09/28 14:43:46 1.4 @@ -11,12 +11,13 @@ from importASCII import ASCII_handler from importASCII import importASCII from importASCII import SimpleSearch -version_string = "V0.2 ROC 29.12.2007" +version_string = "V0.2.2 ROC 28.9.2009" # mapping img_type to SQL field names imgTypeMap = { 'p':'img_p', 'd':'img_d', + 's':'img_s', 'e':'img_e', 'ed':'img_ed', 'l':'img_l', @@ -53,12 +54,10 @@ def handle_line(self, line): self.rowcnt += 1 # process collected row data update=False + # synchronize by id_field id_val = self.xml_data[self.xml_id] - if id_val in self.dbIDs: - self.dbIDs[id_val] += 1 - update=True - + # get img_type img_type_val = self.xml_data[self.xml_img_type] @@ -70,6 +69,11 @@ def handle_line(self, line): self.logger.debug("END ROW") return + # is the entry new? + if id_val in self.dbIDs: + self.dbIDs[id_val] += 1 + update=True + if update: # update existing row (by id_field) if id_val in self.img_data: @@ -117,7 +121,12 @@ def parse(self, filename): elif self.dbIDs[id] > 0: # assemble query - args = [ self.img_data[id].get(f,None) for f in imgTypes ] + imgd = self.img_data.get(id, None) + if imgd is None: + self.logger.error("No data for id %s while marked for update!"%id) + continue + + args = [ imgd.get(f,None) for f in imgTypes ] args.append(id) # update #self.logger.debug("UPDATE: %s with %s"%(self.updQuery,args))