version 1.4, 2009/09/28 14:43:46
|
version 1.5, 2010/03/25 12:13:32
|
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.2 ROC 28.9.2009" |
version_string = "V0.2.3 ROC 25.3.2010" |
|
|
# mapping img_type to SQL field names |
# mapping img_type to SQL field names |
imgTypeMap = { |
imgTypeMap = { |
Line 26 imgTypeMap = {
|
Line 26 imgTypeMap = {
|
# list of fields in constant order (for SQL queries) |
# list of fields in constant order (for SQL queries) |
imgTypes = imgTypeMap.keys() |
imgTypes = imgTypeMap.keys() |
|
|
upd_fields = "fn,,img_type,id_text" |
upd_fields = "fn,,img_type,%s" |
id_field = "id_text" |
#id_field = "id_text" |
img_type_field = "img_type" |
img_type_field = "img_type" |
|
|
def setup(self): |
def setup(self): |
Line 35 def setup(self):
|
Line 35 def setup(self):
|
ASCII_handler._setup(self) |
ASCII_handler._setup(self) |
# create special updQuery for img_type fields |
# create special updQuery for img_type fields |
setStr=string.join(["%s = %%s"%imgTypeMap[f] for f in imgTypes], ', ') |
setStr=string.join(["%s = %%s"%imgTypeMap[f] for f in imgTypes], ', ') |
self.updQuery = "UPDATE %s SET %s WHERE id_text = %%s"%(self.table,setStr) |
self.updQuery = "UPDATE %s SET %s WHERE %s = %%s"%(self.table,setStr,self.id_field) |
# create special delQuery for img_type fields |
# create special delQuery for img_type fields |
delStr=string.join(["%s = null"%imgTypeMap[f] for f in imgTypes], ', ') |
delStr=string.join(["%s = null"%imgTypeMap[f] for f in imgTypes], ', ') |
self.delQuery = "UPDATE %s SET %s WHERE id_text = %%s"%(self.table,delStr) |
self.delQuery = "UPDATE %s SET %s WHERE %s = %%s"%(self.table,delStr,self.id_field) |
# text file field for img_type |
# text file field for img_type |
self.xml_img_type = self.sql_field_map[img_type_field] |
self.xml_img_type = self.sql_field_map[img_type_field] |
# dict of all img fields |
# dict of all img fields |
Line 173 if __name__ == "__main__":
|
Line 173 if __name__ == "__main__":
|
opars.add_option("-t", "--table", |
opars.add_option("-t", "--table", |
dest="table", |
dest="table", |
help="database table name") |
help="database table name") |
|
opars.add_option("--id-field", default="id_text", |
|
dest="id_field", |
|
help="name of id field for synchronisation", metavar="NAME") |
opars.add_option("--ascii-db", default=False, action="store_true", |
opars.add_option("--ascii-db", default=False, action="store_true", |
dest="ascii_db", |
dest="ascii_db", |
help="the SQL database stores ASCII instead of unicode") |
help="the SQL database stores ASCII instead of unicode") |
Line 206 if __name__ == "__main__":
|
Line 209 if __name__ == "__main__":
|
datefmt='%H:%M:%S') |
datefmt='%H:%M:%S') |
|
|
# fixed settings for CDLI imglist |
# fixed settings for CDLI imglist |
options.update_fields = upd_fields |
options.update_fields = upd_fields%options.id_field |
options.id_field = id_field |
#options.id_field = id_field |
options.update_mode = True |
options.update_mode = True |
|
|
importASCII(options) |
importASCII(options) |