--- ZSQLExtend/importCDLIimglist.py 2007/12/31 09:47:12 1.2 +++ ZSQLExtend/importCDLIimglist.py 2009/01/21 11:12:36 1.3 @@ -11,7 +11,7 @@ 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.1 ROC 21.1.2009" # mapping img_type to SQL field names imgTypeMap = { @@ -53,12 +53,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 +68,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 +120,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))