######################################################################### # # # # # copyright 2002 Paul Henry Tremblay # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # # # ######################################################################### import sys,os from ebook_converter.ebooks.rtf2xml import copy from . import open_for_read, open_for_write class Preamble: """ Fix the reamaing parts of the preamble. This module does very little. It makes sure that no text gets put in the revision of list table. In the future, when I understand how to interpret the revision table and list table, I will make these methods more functional. """ def __init__(self, file, bug_handler, platform, default_font, code_page, copy=None, temp_dir=None, ): """ Required: file--file to parse platform --Windows or Macintosh default_font -- the default font code_page --the code page (ansi1252, for example) Optional: 'copy'-- whether to make a copy of result for debugging 'temp_dir' --where to output temporary results (default is directory from which the script is run.) Returns: nothing """ self.__file=file self.__bug_handler = bug_handler self.__copy = copy self.__default_font = default_font self.__code_page = code_page self.__platform = platform if temp_dir: self.__write_to = os.path.join(temp_dir,"info_table_info.data") else: self.__write_to = "info_table_info.data" def __initiate_values(self): """ Initiate all values. """ self.__state = 'default' self.__text_string = '' self.__state_dict = { 'default' : self.__default_func, 'revision' : self.__revision_table_func, 'list_table' : self.__list_table_func, 'body' : self.__body_func, } self.__default_dict = { 'mi%s%s' '%s\n' % (self.__default_font, self.__code_page, self.__platform) ) def __found_list_table_func(self, line): self.__state = 'list_table' def __list_table_func(self, line): if self.__token_info == 'mi