version 1.2, 2007/12/31 09:47:12
|
version 1.3, 2009/01/21 11:12:36
|
Line 11 from importASCII import ASCII_handler
|
Line 11 from importASCII import ASCII_handler
|
from importASCII import importASCII |
from importASCII import importASCII |
from importASCII import SimpleSearch |
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 |
# mapping img_type to SQL field names |
imgTypeMap = { |
imgTypeMap = { |
Line 53 def handle_line(self, line):
|
Line 53 def handle_line(self, line):
|
self.rowcnt += 1 |
self.rowcnt += 1 |
# process collected row data |
# process collected row data |
update=False |
update=False |
|
|
# synchronize by id_field |
# synchronize by id_field |
id_val = self.xml_data[self.xml_id] |
id_val = self.xml_data[self.xml_id] |
if id_val in self.dbIDs: |
|
self.dbIDs[id_val] += 1 |
|
update=True |
|
|
|
# get img_type |
# get img_type |
img_type_val = self.xml_data[self.xml_img_type] |
img_type_val = self.xml_data[self.xml_img_type] |
Line 70 def handle_line(self, line):
|
Line 68 def handle_line(self, line):
|
self.logger.debug("END ROW") |
self.logger.debug("END ROW") |
return |
return |
|
|
|
# is the entry new? |
|
if id_val in self.dbIDs: |
|
self.dbIDs[id_val] += 1 |
|
update=True |
|
|
if update: |
if update: |
# update existing row (by id_field) |
# update existing row (by id_field) |
if id_val in self.img_data: |
if id_val in self.img_data: |
Line 117 def parse(self, filename):
|
Line 120 def parse(self, filename):
|
|
|
elif self.dbIDs[id] > 0: |
elif self.dbIDs[id] > 0: |
# assemble query |
# 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) |
args.append(id) |
# update |
# update |
#self.logger.debug("UPDATE: %s with %s"%(self.updQuery,args)) |
#self.logger.debug("UPDATE: %s with %s"%(self.updQuery,args)) |