def open_new_file(self): """Create a new bookfile saving the old one if it is dirty.""" if self.bookfile is not None and self.bookfile.is_dirty(): if self.ask_save_entry() == QtWidgets.QMessageBox.Cancel: return if self.ask_save_file() == QtWidgets.QMessageBox.Cancel: return self.bookfile = bf.BookFile() self.set_max_entry_number(0) self.new_entry()
def main(): '''Create a ?_books.tex file of \bkentry lines. This file will be included in some catalogue.tex file.''' args = get_args() BookF = bf.BookFile() # expect args.input to be a comma separated list later on BookF.set_filename(args.input) BookF.read_file() add_commands() for entry in BookF: print_short_entry(entry)
def main(): '''The main function to update prices in many files.''' # get command line args = getargs() if args.verbose: pprint(args) # open xml file to bookfile # for each entry # for ajbfile in args.ajbfiles[0]: print('working on:', ajbfile) bookfile = bf.BookFile() bookfile.set_filename(ajbfile) bookfile.read_file_xml() for count, entry in enumerate(bookfile): fix_price(count, entry) bookfile.write_file_xml()
def main(): '''Do all the work here ''' args = get_args() if args.verbose: pprint(args) with open(args.output, 'w') as filep: bookf = bf.BookFile() bookf.read_file(args.input) # sort bookfile sort_bookfile(bookf, args.sort) print_header(bookf, outf=filep) for count, ent in enumerate(bookf): print_entry(count + 1, ent, outf=filep) print_closing(bookf) filep.close()
return self.dirty def set_header_text(self, textstr): '''Set the text to edit.''' self.headerEntry.setPlainText(textstr) self.clear_dirty() def get_header_text(self): '''Get the text we have edited.''' return self.headerEntry.toPlainText() # # Test functions # if __name__ == '__main__': import aabooks.ajbbook.bookfile as Bookfile import sys APP = QtWidgets.QApplication(sys.argv) EX = HeaderWindow() BF = Bookfile.BookFile() EX.set_bookfile(BF) EX.set_filename('New File') EX.set_header_text(BF.get_header()) EX.show() APP.exec_() print('The Header is:\n') print(BF.get_header())
#! /usr/bin/env python3 from aabooks.ajbbook import bookfile as bf bf1 = bf.BookFile() bf1.set_filename('./hjs01_books.xml') bf1.read_file_xml() bf2 = bf.BookFile() bf2.set_filename('./hjs02_books.xml') bf2.read_file_xml() bf3 = bf.BookFile() bf3.set_filename('./hjs03_books.xml') bf3.read_file_xml() bf4 = bf.BookFile() bf4.set_filename('./hjs04_books.xml') bf4.read_file_xml() bfall = bf1 + bf2 + bf3 + bf4 bfall.set_filename('./hjs_all.xml') bfall.write_file_xml()