######################################################################### # # # # # 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. # # # # You should have received a copy of the GNU General Public License # # along with this program; if not, write to the Free Software # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # # 02111-1307 USA # # # # # ######################################################################### import os, tempfile from libprs500.ebooks.rtf2xml import copy class ListNumbers: """ RTF puts list numbers outside of the paragraph. The public method in this class put the list numbers inside the paragraphs. """ def __init__(self, in_file, bug_handler, copy = None, run_level = 1, ): """ Required: 'file' 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 = in_file self.__bug_handler = bug_handler self.__copy = copy self.__write_to = tempfile.mktemp() def __initiate_values(self): """ initiate values for fix_list_numbers. Required: Nothing Return: Nothing """ self.__state = "default" self.__list_chunk = '' self.__previous_line = '' self.__list_text_ob_count = '' self.__state_dict={ 'default' : self.__default_func, 'after_ob' : self.__after_ob_func, 'list_text' : self.__list_text_func, 'after_list_text' : self.__after_list_text_func } def __after_ob_func(self, line): """ Handle the line immediately after an open bracket. Required: self, line Returns: Nothing """ if self.__token_info == 'cw%s\n' % self.__list_type) 'mi