def appendFile(): global numberOfRecords global recordPtr tempFileName = tkFileDialog.askopenfilename(title="Insert XML File", filetypes=[ ("XML files", "*.xml"), ("Text files", "*.txt"), ("All Files", "*") ], initialdir="./") if len(tempFileName) == 0: # catch the cancel/ESCAPE key entered updateStatusBar("No file selected") elif tempFileName: (newFileName, recordPtr, numRecordsAppened) = Mx.append(tempFileName) listbox.delete(0, END) (status, recordPtr, numberOfRecords) = Mx.readFile(newFileName) for i in range(0, numberOfRecords): (title, author, pub, callnum) = Mx.marc2bib(recordPtr, i) string = str(i) + " " + author + " " + title + " " + pub listbox.insert(END, string) updateStatusBar( str(listbox.size() - numRecordsAppened) + " records appended from file " + tempFileName) else: updateStatusBar("There was an error selecting a file.")
def appendFile(): global numberOfRecords global recordPtr tempFileName = tkFileDialog.askopenfilename(title="Insert XML File", filetypes=[("XML files", "*.xml"), ("Text files", "*.txt"), ("All Files", "*")], initialdir="./") if len( tempFileName ) == 0: # catch the cancel/ESCAPE key entered updateStatusBar( "No file selected" ) elif tempFileName: ( newFileName, recordPtr, numRecordsAppened ) = Mx.append( tempFileName ) listbox.delete( 0, END ) ( status, recordPtr, numberOfRecords ) = Mx.readFile( newFileName ) for i in range( 0, numberOfRecords ): ( title, author, pub, callnum ) = Mx.marc2bib( recordPtr, i ) string = str( i ) + " " + author + " " + title + " " + pub listbox.insert( END, string ) updateStatusBar( str( listbox.size() - numRecordsAppened ) + " records appended from file " + tempFileName ) else: updateStatusBar( "There was an error selecting a file." )
def append(): #same as insert, but adds records to the end of the display status('Inserting more record files to the end') global recPtr global numRecs fileName = tkinter.filedialog.askopenfilename(title="Open XML File", filetypes=[("XML files", "*.xml")]) if len(fileName) != 0: beforeAppend = numRecs value, recPtr, numRecs = Mx.append(fileName, recPtr) if numRecs > 0: status( str(numRecs - beforeAppend) + ' records appended. ' + str(numRecs) + ' total records') else: status( 'Failed to append xml file' ) display.delete(0, END) for i in range(0, numRecs): (author, title, pubinfo, callnum) = Mx.marc2bib(recPtr,i) bibData = str(i+1) + '. ' + author + '. ' + title + '. ' + pubinfo display.insert(END, bibData)