version 1.2, 2007/12/31 09:47:12
|
version 1.4, 2009/09/28 14:43:46
|
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.2 ROC 28.9.2009" |
|
|
# mapping img_type to SQL field names |
# mapping img_type to SQL field names |
imgTypeMap = { |
imgTypeMap = { |
'p':'img_p', |
'p':'img_p', |
'd':'img_d', |
'd':'img_d', |
|
's':'img_s', |
'e':'img_e', |
'e':'img_e', |
'ed':'img_ed', |
'ed':'img_ed', |
'l':'img_l', |
'l':'img_l', |
Line 53 def handle_line(self, line):
|
Line 54 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 69 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 121 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)) |