diff --git a/src/calibre/ebooks/rtf2xml/add_brackets.py b/src/calibre/ebooks/rtf2xml/add_brackets.py index d4919d4cd7..7f1b8faa6f 100755 --- a/src/calibre/ebooks/rtf2xml/add_brackets.py +++ b/src/calibre/ebooks/rtf2xml/add_brackets.py @@ -11,10 +11,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy, check_brackets -# note to self. This is the first module in which I use tempfile. A good idea? +from calibre.ptempfile import better_mktemp class AddBrackets: """ @@ -39,7 +39,7 @@ class AddBrackets: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/body_styles.py b/src/calibre/ebooks/rtf2xml/body_styles.py index 20f23222cb..82d4851bdf 100755 --- a/src/calibre/ebooks/rtf2xml/body_styles.py +++ b/src/calibre/ebooks/rtf2xml/body_styles.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + """ Simply write the list of strings after style table """ @@ -42,7 +44,7 @@ class BodyStyles: self.__copy = copy self.__list_of_styles = list_of_styles self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() # self.__write_to = 'table_info.data' def insert_info(self): """ diff --git a/src/calibre/ebooks/rtf2xml/colors.py b/src/calibre/ebooks/rtf2xml/colors.py index fffdd63830..acb50b1223 100755 --- a/src/calibre/ebooks/rtf2xml/colors.py +++ b/src/calibre/ebooks/rtf2xml/colors.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class Colors: """ @@ -38,7 +39,7 @@ class Colors: self.__copy = copy self.__bug_handler = bug_handler self.__line = 0 - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/combine_borders.py b/src/calibre/ebooks/rtf2xml/combine_borders.py index 68da83fb02..3ab67dabb9 100755 --- a/src/calibre/ebooks/rtf2xml/combine_borders.py +++ b/src/calibre/ebooks/rtf2xml/combine_borders.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class CombineBorders: """Combine borders in RTF tokens to make later processing easier""" @@ -25,7 +26,7 @@ class CombineBorders: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__state = 'default' self.__bord_pos = 'default' self.__bord_att = [] diff --git a/src/calibre/ebooks/rtf2xml/convert_to_tags.py b/src/calibre/ebooks/rtf2xml/convert_to_tags.py index 1abc672f85..e1fedcfdff 100755 --- a/src/calibre/ebooks/rtf2xml/convert_to_tags.py +++ b/src/calibre/ebooks/rtf2xml/convert_to_tags.py @@ -1,6 +1,7 @@ -import os, tempfile, sys +import os, sys from calibre.ebooks.rtf2xml import copy, check_encoding +from calibre.ptempfile import better_mktemp public_dtd = 'rtf2xml1.0.dtd' @@ -38,7 +39,7 @@ class ConvertToTags: self.__encoding = 'mac_roman' self.__indent = indent self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__convert_utf = False def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/delete_info.py b/src/calibre/ebooks/rtf2xml/delete_info.py index 74e6b2aba3..05dcf98db9 100755 --- a/src/calibre/ebooks/rtf2xml/delete_info.py +++ b/src/calibre/ebooks/rtf2xml/delete_info.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class DeleteInfo: """Delete unecessary destination groups""" @@ -25,7 +26,7 @@ class DeleteInfo: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level self.__initiate_allow() self.__bracket_count= 0 diff --git a/src/calibre/ebooks/rtf2xml/fields_large.py b/src/calibre/ebooks/rtf2xml/fields_large.py index d70944598f..77b302d11f 100755 --- a/src/calibre/ebooks/rtf2xml/fields_large.py +++ b/src/calibre/ebooks/rtf2xml/fields_large.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import field_strings, copy +from calibre.ptempfile import better_mktemp + class FieldsLarge: """ ========================= @@ -99,7 +101,7 @@ Examples self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Initiate all values. diff --git a/src/calibre/ebooks/rtf2xml/fields_small.py b/src/calibre/ebooks/rtf2xml/fields_small.py index f254ce8f7b..e033493475 100755 --- a/src/calibre/ebooks/rtf2xml/fields_small.py +++ b/src/calibre/ebooks/rtf2xml/fields_small.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import field_strings, copy +from calibre.ptempfile import better_mktemp class FieldsSmall: """ @@ -50,7 +51,7 @@ file. self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/fonts.py b/src/calibre/ebooks/rtf2xml/fonts.py index a7a7481865..68589cfbe3 100755 --- a/src/calibre/ebooks/rtf2xml/fonts.py +++ b/src/calibre/ebooks/rtf2xml/fonts.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class Fonts: """ @@ -40,7 +41,7 @@ class Fonts: self.__bug_handler = bug_handler self.__copy = copy self.__default_font_num = default_font_num - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/footnote.py b/src/calibre/ebooks/rtf2xml/footnote.py index c64637a1f1..ac1bc0549e 100755 --- a/src/calibre/ebooks/rtf2xml/footnote.py +++ b/src/calibre/ebooks/rtf2xml/footnote.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class Footnote: """ @@ -30,7 +31,7 @@ class Footnote: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__found_a_footnote = 0 def __first_line_func(self, line): @@ -114,7 +115,7 @@ class Footnote: bottom of the main file. """ self.__initiate_sep_values() - self.__footnote_holder = tempfile.mktemp() + self.__footnote_holder = better_mktemp() with open(self.__file) as read_obj: with open(self.__write_to, 'w') as self.__write_obj: with open(self.__footnote_holder, 'w') as self.__write_to_foot_obj: @@ -243,7 +244,7 @@ class Footnote: """ if not self.__found_a_footnote: return - self.__write_to2 = tempfile.mktemp() + self.__write_to2 = better_mktemp() self.__state = 'body' self.__get_footnotes() self.__join_from_temp() diff --git a/src/calibre/ebooks/rtf2xml/group_borders.py b/src/calibre/ebooks/rtf2xml/group_borders.py index d6bdcdf508..3672fbbbd3 100755 --- a/src/calibre/ebooks/rtf2xml/group_borders.py +++ b/src/calibre/ebooks/rtf2xml/group_borders.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class GroupBorders: """ Form lists. @@ -40,7 +42,7 @@ class GroupBorders: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__wrap = wrap def __initiate_values(self): """ diff --git a/src/calibre/ebooks/rtf2xml/group_styles.py b/src/calibre/ebooks/rtf2xml/group_styles.py index 29b6b59ba7..58bbeeff11 100755 --- a/src/calibre/ebooks/rtf2xml/group_styles.py +++ b/src/calibre/ebooks/rtf2xml/group_styles.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class GroupStyles: """ Form lists. @@ -40,7 +42,7 @@ class GroupStyles: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__wrap = wrap def __initiate_values(self): """ diff --git a/src/calibre/ebooks/rtf2xml/header.py b/src/calibre/ebooks/rtf2xml/header.py index 1f928b63b9..e9fefef99d 100755 --- a/src/calibre/ebooks/rtf2xml/header.py +++ b/src/calibre/ebooks/rtf2xml/header.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class Header: """ Two public methods are available. The first separates all of the headers @@ -28,7 +30,7 @@ class Header: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__found_a_header = 0 def __in_header_func(self, line): """ @@ -110,7 +112,7 @@ class Header: self.__initiate_sep_values() read_obj = open(self.__file) self.__write_obj = open(self.__write_to, 'w') - self.__header_holder = tempfile.mktemp() + self.__header_holder = better_mktemp() self.__write_to_head_obj = open(self.__header_holder, 'w') line_to_read = 1 while line_to_read: @@ -246,7 +248,7 @@ class Header: """ if not self.__found_a_header: return - self.__write_to2 = tempfile.mktemp() + self.__write_to2 = better_mktemp() self.__state = 'body' self.__get_headers() self.__join_from_temp() diff --git a/src/calibre/ebooks/rtf2xml/headings_to_sections.py b/src/calibre/ebooks/rtf2xml/headings_to_sections.py index 132e3b6125..dd820df191 100755 --- a/src/calibre/ebooks/rtf2xml/headings_to_sections.py +++ b/src/calibre/ebooks/rtf2xml/headings_to_sections.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import os, tempfile, re +import os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class HeadingsToSections: """ """ @@ -34,7 +36,7 @@ class HeadingsToSections: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Required: diff --git a/src/calibre/ebooks/rtf2xml/hex_2_utf8.py b/src/calibre/ebooks/rtf2xml/hex_2_utf8.py index 423a1b3ee0..1084812e6b 100755 --- a/src/calibre/ebooks/rtf2xml/hex_2_utf8.py +++ b/src/calibre/ebooks/rtf2xml/hex_2_utf8.py @@ -10,10 +10,11 @@ # # # # ######################################################################### -import sys, os, tempfile, cStringIO +import sys, os, cStringIO from calibre.ebooks.rtf2xml import get_char_map, copy from calibre.ebooks.rtf2xml.char_set import char_set +from calibre.ptempfile import better_mktemp class Hex2Utf8: """ @@ -73,7 +74,7 @@ class Hex2Utf8: self.__convert_wingdings = 0 self.__convert_zapf = 0 self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__bug_handler = bug_handler self.__invalid_rtf_handler = invalid_rtf_handler diff --git a/src/calibre/ebooks/rtf2xml/info.py b/src/calibre/ebooks/rtf2xml/info.py index 8eabe25c18..f5c011c7e4 100755 --- a/src/calibre/ebooks/rtf2xml/info.py +++ b/src/calibre/ebooks/rtf2xml/info.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp class Info: """ @@ -38,7 +39,7 @@ class Info: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ diff --git a/src/calibre/ebooks/rtf2xml/inline.py b/src/calibre/ebooks/rtf2xml/inline.py index 2d73db9071..a649465d33 100755 --- a/src/calibre/ebooks/rtf2xml/inline.py +++ b/src/calibre/ebooks/rtf2xml/inline.py @@ -1,6 +1,7 @@ -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp """ States. @@ -37,7 +38,7 @@ class Inline: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ @@ -418,4 +419,4 @@ class Inline: if self.__copy: copy_obj.copy_file(self.__write_to, "inline.data") copy_obj.rename(self.__write_to, self.__file) - os.remove(self.__write_to) \ No newline at end of file + os.remove(self.__write_to) diff --git a/src/calibre/ebooks/rtf2xml/line_endings.py b/src/calibre/ebooks/rtf2xml/line_endings.py index bf17b73954..65223c8e31 100755 --- a/src/calibre/ebooks/rtf2xml/line_endings.py +++ b/src/calibre/ebooks/rtf2xml/line_endings.py @@ -10,10 +10,11 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy from calibre.utils.cleantext import clean_ascii_chars +from calibre.ptempfile import better_mktemp class FixLineEndings: """Fix line endings""" @@ -28,7 +29,7 @@ class FixLineEndings: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__replace_illegals = replace_illegals def fix_endings(self): diff --git a/src/calibre/ebooks/rtf2xml/list_numbers.py b/src/calibre/ebooks/rtf2xml/list_numbers.py index d39e170a26..3693080a0d 100755 --- a/src/calibre/ebooks/rtf2xml/list_numbers.py +++ b/src/calibre/ebooks/rtf2xml/list_numbers.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class ListNumbers: """ RTF puts list numbers outside of the paragraph. The public method @@ -36,7 +38,7 @@ class ListNumbers: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ initiate values for fix_list_numbers. diff --git a/src/calibre/ebooks/rtf2xml/make_lists.py b/src/calibre/ebooks/rtf2xml/make_lists.py index 5e24cdd21f..0f0d0f8797 100755 --- a/src/calibre/ebooks/rtf2xml/make_lists.py +++ b/src/calibre/ebooks/rtf2xml/make_lists.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile, re +import sys, os, re from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class MakeLists: """ Form lists. @@ -45,7 +47,7 @@ class MakeLists: self.__no_headings_as_list = no_headings_as_list self.__headings_to_sections = headings_to_sections self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__list_of_lists = list_of_lists self.__write_list_info = write_list_info def __initiate_values(self): diff --git a/src/calibre/ebooks/rtf2xml/paragraph_def.py b/src/calibre/ebooks/rtf2xml/paragraph_def.py index 4fc7c21e0e..9dff180aec 100755 --- a/src/calibre/ebooks/rtf2xml/paragraph_def.py +++ b/src/calibre/ebooks/rtf2xml/paragraph_def.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy, border_parse +from calibre.ptempfile import better_mktemp + class ParagraphDef: """ ================= @@ -66,7 +68,7 @@ if another paragraph_def is found, the state changes to collect_tokens. self.__default_font = default_font self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Initiate all values. diff --git a/src/calibre/ebooks/rtf2xml/paragraphs.py b/src/calibre/ebooks/rtf2xml/paragraphs.py index e31aedd585..cab1a7ffa8 100755 --- a/src/calibre/ebooks/rtf2xml/paragraphs.py +++ b/src/calibre/ebooks/rtf2xml/paragraphs.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class Paragraphs: """ ================= @@ -57,7 +59,7 @@ section. (How about the end of a section or the end of a field-block?) self.__copy = copy self.__write_empty_para = write_empty_para self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Initiate all values. diff --git a/src/calibre/ebooks/rtf2xml/pict.py b/src/calibre/ebooks/rtf2xml/pict.py index 663f0c5b79..7bc3518454 100755 --- a/src/calibre/ebooks/rtf2xml/pict.py +++ b/src/calibre/ebooks/rtf2xml/pict.py @@ -10,9 +10,11 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class Pict: """Process graphic information""" @@ -28,7 +30,7 @@ class Pict: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__bracket_count = 0 self.__ob_count = 0 self.__cb_count = 0 diff --git a/src/calibre/ebooks/rtf2xml/preamble_div.py b/src/calibre/ebooks/rtf2xml/preamble_div.py index f75c1d9520..d67bd226f9 100755 --- a/src/calibre/ebooks/rtf2xml/preamble_div.py +++ b/src/calibre/ebooks/rtf2xml/preamble_div.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy, override_table, list_table +from calibre.ptempfile import better_mktemp + class PreambleDiv: """ Break the preamble into divisions. @@ -36,7 +38,7 @@ class PreambleDiv: self.__bug_handler = bug_handler self.__copy = copy self.__no_namespace = no_namespace - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): """ diff --git a/src/calibre/ebooks/rtf2xml/process_tokens.py b/src/calibre/ebooks/rtf2xml/process_tokens.py index 5e4017c000..8ebec05bd3 100755 --- a/src/calibre/ebooks/rtf2xml/process_tokens.py +++ b/src/calibre/ebooks/rtf2xml/process_tokens.py @@ -10,9 +10,10 @@ # # # # ######################################################################### -import os, re, tempfile +import os, re from calibre.ebooks.rtf2xml import copy, check_brackets +from calibre.ptempfile import better_mktemp class ProcessTokens: """ @@ -31,7 +32,7 @@ class ProcessTokens: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.initiate_token_dict() ##self.initiate_token_actions() self.compile_expressions() @@ -833,4 +834,4 @@ class ProcessTokens: msg = '\nInvalid RTF: document does not have matching brackets.\n' raise self.__exception_handler, msg else: - return self.__return_code \ No newline at end of file + return self.__return_code diff --git a/src/calibre/ebooks/rtf2xml/replace_illegals.py b/src/calibre/ebooks/rtf2xml/replace_illegals.py index 2cef6487ee..2c5615663a 100755 --- a/src/calibre/ebooks/rtf2xml/replace_illegals.py +++ b/src/calibre/ebooks/rtf2xml/replace_illegals.py @@ -10,10 +10,11 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy from calibre.utils.cleantext import clean_ascii_chars +from calibre.ptempfile import better_mktemp class ReplaceIllegals: """ @@ -27,7 +28,7 @@ class ReplaceIllegals: self.__file = in_file self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def replace_illegals(self): """ diff --git a/src/calibre/ebooks/rtf2xml/sections.py b/src/calibre/ebooks/rtf2xml/sections.py index a315729525..f1e3481ef7 100755 --- a/src/calibre/ebooks/rtf2xml/sections.py +++ b/src/calibre/ebooks/rtf2xml/sections.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + class Sections: """ ================= @@ -66,7 +68,7 @@ Instead, ingore all section information in a field-block. self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Initiate all values. diff --git a/src/calibre/ebooks/rtf2xml/styles.py b/src/calibre/ebooks/rtf2xml/styles.py index 7fcbfb24a3..f67395c68a 100755 --- a/src/calibre/ebooks/rtf2xml/styles.py +++ b/src/calibre/ebooks/rtf2xml/styles.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy, border_parse +from calibre.ptempfile import better_mktemp + class Styles: """ Change lines with style numbers to actual style names. @@ -35,7 +37,7 @@ class Styles: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() self.__run_level = run_level def __initiate_values(self): """ diff --git a/src/calibre/ebooks/rtf2xml/table.py b/src/calibre/ebooks/rtf2xml/table.py index d484cc2004..1d242ed26c 100755 --- a/src/calibre/ebooks/rtf2xml/table.py +++ b/src/calibre/ebooks/rtf2xml/table.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import sys, os, tempfile +import sys, os from calibre.ebooks.rtf2xml import copy, border_parse +from calibre.ptempfile import better_mktemp + """ States. 1. 'not_in_table' @@ -64,7 +66,7 @@ class Table: self.__bug_handler = bug_handler self.__copy = copy self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() def __initiate_values(self): """ Initiate all values. diff --git a/src/calibre/ebooks/rtf2xml/table_info.py b/src/calibre/ebooks/rtf2xml/table_info.py index 37c410f338..060d647875 100755 --- a/src/calibre/ebooks/rtf2xml/table_info.py +++ b/src/calibre/ebooks/rtf2xml/table_info.py @@ -10,8 +10,10 @@ # # # # ######################################################################### -import os, tempfile +import os from calibre.ebooks.rtf2xml import copy +from calibre.ptempfile import better_mktemp + # note to self. This is the first module in which I use tempfile. A good idea? """ """ @@ -42,7 +44,7 @@ class TableInfo: self.__copy = copy self.__table_data = table_data self.__run_level = run_level - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() # self.__write_to = 'table_info.data' def insert_info(self): """ diff --git a/src/calibre/ebooks/rtf2xml/tokenize.py b/src/calibre/ebooks/rtf2xml/tokenize.py index 97cc074d4d..82af5be667 100755 --- a/src/calibre/ebooks/rtf2xml/tokenize.py +++ b/src/calibre/ebooks/rtf2xml/tokenize.py @@ -10,10 +10,11 @@ # # # # ######################################################################### -import os, re, tempfile +import os, re from calibre.ebooks.rtf2xml import copy from calibre.utils.mreplace import MReplace +from calibre.ptempfile import better_mktemp class Tokenize: """Tokenize RTF into one line per field. Each line will contain information useful for the rest of the script""" @@ -27,7 +28,7 @@ class Tokenize: self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy - self.__write_to = tempfile.mktemp() + self.__write_to = better_mktemp() # self.__write_to = out_file self.__compile_expressions() #variables @@ -208,5 +209,5 @@ class Tokenize: # if __name__ == '__main__': # sys.exit(main()) - -# calibre-debug -e src/calibre/ebooks/rtf2xml/tokenize.py \ No newline at end of file + +# calibre-debug -e src/calibre/ebooks/rtf2xml/tokenize.py