From b2187360ecec9ddab30e79c48a26f340d1a12911 Mon Sep 17 00:00:00 2001 From: Sengian Date: Fri, 7 Jan 2011 07:36:20 +0100 Subject: [PATCH] various lttle modification in rtf2xml --- src/calibre/ebooks/rtf2xml/ParseRtf.py | 3 +- src/calibre/ebooks/rtf2xml/hex_2_utf8.py | 98 +++++++++++--------- src/calibre/ebooks/rtf2xml/process_tokens.py | 4 +- 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/calibre/ebooks/rtf2xml/ParseRtf.py b/src/calibre/ebooks/rtf2xml/ParseRtf.py index 05a4847ce5..901188a000 100755 --- a/src/calibre/ebooks/rtf2xml/ParseRtf.py +++ b/src/calibre/ebooks/rtf2xml/ParseRtf.py @@ -326,6 +326,7 @@ class ParseRtf: invalid_rtf_handler = InvalidRtfException, ) hex2utf_obj.convert_hex_2_utf8() + # raise RtfInvalidCodeException, 'stop' self.__bracket_match('hex_2_utf_preamble') fonts_obj = fonts.Fonts( in_file = self.__temp_file, @@ -381,7 +382,7 @@ class ParseRtf: msg += 'self.__run_level is "%s"\n' % self.__run_level raise RtfInvalidCodeException, msg if self.__run_level > 1: - sys.stderr.write('File could be older RTF...\n') + sys.stderr.write(_('File could be older RTF...\n')) if found_destination: if self.__run_level > 1: sys.stderr.write(_( diff --git a/src/calibre/ebooks/rtf2xml/hex_2_utf8.py b/src/calibre/ebooks/rtf2xml/hex_2_utf8.py index d67dce30d2..750d0c9180 100755 --- a/src/calibre/ebooks/rtf2xml/hex_2_utf8.py +++ b/src/calibre/ebooks/rtf2xml/hex_2_utf8.py @@ -54,10 +54,10 @@ class Hex2Utf8: 'convert_to_caps'--wether to convert caps to utf-8 Returns: nothing - """ + """ self.__file = in_file self.__copy = copy - if area_to_convert != 'preamble' and area_to_convert != 'body': + if area_to_convert not in ('preamble', 'body'): msg = ( 'Developer error! Wrong flag.\n' 'in module "hex_2_utf8.py\n' @@ -79,7 +79,8 @@ class Hex2Utf8: self.__write_to = tempfile.mktemp() self.__bug_handler = bug_handler self.__invalid_rtf_handler = invalid_rtf_handler - def update_values( self, + + def update_values(self, file, area_to_convert, char_file, @@ -132,6 +133,7 @@ class Hex2Utf8: # self.__convert_symbol = 0 # self.__convert_wingdings = 0 # self.__convert_zapf = 0 + def __initiate_values(self): """ Required: @@ -191,6 +193,7 @@ class Hex2Utf8: 'body' : self.__body_func, 'mi