Diff for /MPIWGWeb/Attic/updatePersonalWWW.py between versions 1.1.2.1 and 1.1.2.10

version 1.1.2.1, 2007/04/18 10:03:13 version 1.1.2.10, 2011/05/18 12:36:06
Line 6  except: Line 6  except:
     psyco = 1      psyco = 1
           
 import logging  import logging
   from MPIWGHelper import unicodify, utf8ify
   
 from xml import sax  from xml import sax
 from amara import saxtools  from amara import saxtools
   
   # namespace for FileMaker8
 fm_ns = 'http://www.filemaker.com/fmpxmlresult'  fm_ns = 'http://www.filemaker.com/fmpxmlresult'
   
   # list of fields that are taken from XML and checked against DB as conflicts
 #checkFields=['key','first_name','last_name','title','home_inst','current_work','e_mail2']  #checkFields=['key','first_name','last_name','title','home_inst','current_work','e_mail2']
 checkFields=['key','first_name','last_name','title','home_inst','e_mail2']  checkFields=['key','first_name','last_name','title','titles_new','home_inst','current_work']
   
   
 def sql_quote(v):  def sql_quote(v):
     # quote dictionary      # quote dictionary
Line 211  class xml_handler: Line 215  class xml_handler:
   
 def checkImport(dsn,resultSet):  def checkImport(dsn,resultSet):
     #now connect to the database      #now connect to the database
       logging.info("dsn: %s"%dsn)
     dbCon = psycopg.connect(dsn)      dbCon = psycopg.connect(dsn)
     db = dbCon.cursor()      db = dbCon.cursor()
           
Line 222  def checkImport(dsn,resultSet): Line 227  def checkImport(dsn,resultSet):
     keys=[]      keys=[]
     for x in results:      for x in results:
         if x[0]:          if x[0]:
             keys.append(x[0].decode('utf-8'))              keys.append(unicodify(x[0]))
                           
       
     #first step detect new entries and conflicts      #first step detect new entries and conflicts
Line 284  def checkForConflicts(cursor,dataSet,key Line 289  def checkForConflicts(cursor,dataSet,key
     for checkField in checkFields:      for checkField in checkFields:
         dbValueR=sr[0][i]          dbValueR=sr[0][i]
         if dbValueR:          if dbValueR:
             dbValue=dbValueR.decode('utf-8')              dbValue=unicodify(dbValueR)
         else:          else:
             dbValue=""              dbValue=""
                           
           if checkField in dataSet:
         setValue=dataSet[checkField]          setValue=dataSet[checkField]
         logging.debug( "             %s %s %s %s"%(repr(key),checkField,repr(dbValue),repr(setValue)))          logging.debug( "             %s %s %s %s"%(repr(key),checkField,repr(dbValue),repr(setValue)))
         if dbValue.strip().rstrip()!=setValue.lstrip().rstrip():          if dbValue.strip().rstrip()!=setValue.lstrip().rstrip():
             ret.append((checkField,dbValue,setValue))              ret.append((checkField,dbValue,setValue))
             retValue=True              retValue=True
                   
           else:
               logging.warning("unknown field %s in data file!"%checkField)
               
         i+=1          i+=1
           
     return retValue,ret      return retValue,ret
Line 314  if __name__ == "__main__": Line 324  if __name__ == "__main__":
                         datefmt='%H:%M:%S')                          datefmt='%H:%M:%S')
           
     resultSet=importFMPXML(filename="/Users/dwinter/Desktop/personalwww.xml")      resultSet=importFMPXML(filename="/Users/dwinter/Desktop/personalwww.xml")
     news,conflicts=checkImport(dsn="dbname=personalwww", resultSet=resultSet)      news,conflicts=checkImport(dsn="dbname=personalwww host=xserve02a user=mysql password=e1nste1n", resultSet=resultSet)
           
           
     print "new"      print "new"

Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.10


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>