mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace use of onsecure tempfile in the bundled rtf2xml library. Fixes #885245 (Private bug)
This commit is contained in:
parent
0fc9a42975
commit
80a2c3c198
@ -11,10 +11,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy, check_brackets
|
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:
|
class AddBrackets:
|
||||||
"""
|
"""
|
||||||
@ -39,7 +39,7 @@ class AddBrackets:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Simply write the list of strings after style table
|
Simply write the list of strings after style table
|
||||||
"""
|
"""
|
||||||
@ -42,7 +44,7 @@ class BodyStyles:
|
|||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__list_of_styles = list_of_styles
|
self.__list_of_styles = list_of_styles
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
# self.__write_to = 'table_info.data'
|
# self.__write_to = 'table_info.data'
|
||||||
def insert_info(self):
|
def insert_info(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
"""
|
"""
|
||||||
@ -38,7 +39,7 @@ class Colors:
|
|||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__line = 0
|
self.__line = 0
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class CombineBorders:
|
class CombineBorders:
|
||||||
"""Combine borders in RTF tokens to make later processing easier"""
|
"""Combine borders in RTF tokens to make later processing easier"""
|
||||||
@ -25,7 +26,7 @@ class CombineBorders:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__state = 'default'
|
self.__state = 'default'
|
||||||
self.__bord_pos = 'default'
|
self.__bord_pos = 'default'
|
||||||
self.__bord_att = []
|
self.__bord_att = []
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os, tempfile, sys
|
import os, sys
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy, check_encoding
|
from calibre.ebooks.rtf2xml import copy, check_encoding
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
public_dtd = 'rtf2xml1.0.dtd'
|
public_dtd = 'rtf2xml1.0.dtd'
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ class ConvertToTags:
|
|||||||
self.__encoding = 'mac_roman'
|
self.__encoding = 'mac_roman'
|
||||||
self.__indent = indent
|
self.__indent = indent
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__convert_utf = False
|
self.__convert_utf = False
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class DeleteInfo:
|
class DeleteInfo:
|
||||||
"""Delete unecessary destination groups"""
|
"""Delete unecessary destination groups"""
|
||||||
@ -25,7 +26,7 @@ class DeleteInfo:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__initiate_allow()
|
self.__initiate_allow()
|
||||||
self.__bracket_count= 0
|
self.__bracket_count= 0
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import field_strings, copy
|
from calibre.ebooks.rtf2xml import field_strings, copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class FieldsLarge:
|
class FieldsLarge:
|
||||||
"""
|
"""
|
||||||
=========================
|
=========================
|
||||||
@ -99,7 +101,7 @@ Examples
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Initiate all values.
|
Initiate all values.
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import field_strings, copy
|
from calibre.ebooks.rtf2xml import field_strings, copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class FieldsSmall:
|
class FieldsSmall:
|
||||||
"""
|
"""
|
||||||
@ -50,7 +51,7 @@ file.
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Fonts:
|
class Fonts:
|
||||||
"""
|
"""
|
||||||
@ -40,7 +41,7 @@ class Fonts:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__default_font_num = default_font_num
|
self.__default_font_num = default_font_num
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Footnote:
|
class Footnote:
|
||||||
"""
|
"""
|
||||||
@ -30,7 +31,7 @@ class Footnote:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__found_a_footnote = 0
|
self.__found_a_footnote = 0
|
||||||
|
|
||||||
def __first_line_func(self, line):
|
def __first_line_func(self, line):
|
||||||
@ -114,7 +115,7 @@ class Footnote:
|
|||||||
bottom of the main file.
|
bottom of the main file.
|
||||||
"""
|
"""
|
||||||
self.__initiate_sep_values()
|
self.__initiate_sep_values()
|
||||||
self.__footnote_holder = tempfile.mktemp()
|
self.__footnote_holder = better_mktemp()
|
||||||
with open(self.__file) as read_obj:
|
with open(self.__file) as read_obj:
|
||||||
with open(self.__write_to, 'w') as self.__write_obj:
|
with open(self.__write_to, 'w') as self.__write_obj:
|
||||||
with open(self.__footnote_holder, 'w') as self.__write_to_foot_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:
|
if not self.__found_a_footnote:
|
||||||
return
|
return
|
||||||
self.__write_to2 = tempfile.mktemp()
|
self.__write_to2 = better_mktemp()
|
||||||
self.__state = 'body'
|
self.__state = 'body'
|
||||||
self.__get_footnotes()
|
self.__get_footnotes()
|
||||||
self.__join_from_temp()
|
self.__join_from_temp()
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class GroupBorders:
|
class GroupBorders:
|
||||||
"""
|
"""
|
||||||
Form lists.
|
Form lists.
|
||||||
@ -40,7 +42,7 @@ class GroupBorders:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__wrap = wrap
|
self.__wrap = wrap
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class GroupStyles:
|
class GroupStyles:
|
||||||
"""
|
"""
|
||||||
Form lists.
|
Form lists.
|
||||||
@ -40,7 +42,7 @@ class GroupStyles:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__wrap = wrap
|
self.__wrap = wrap
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Header:
|
class Header:
|
||||||
"""
|
"""
|
||||||
Two public methods are available. The first separates all of the headers
|
Two public methods are available. The first separates all of the headers
|
||||||
@ -28,7 +30,7 @@ class Header:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__found_a_header = 0
|
self.__found_a_header = 0
|
||||||
def __in_header_func(self, line):
|
def __in_header_func(self, line):
|
||||||
"""
|
"""
|
||||||
@ -110,7 +112,7 @@ class Header:
|
|||||||
self.__initiate_sep_values()
|
self.__initiate_sep_values()
|
||||||
read_obj = open(self.__file)
|
read_obj = open(self.__file)
|
||||||
self.__write_obj = open(self.__write_to, 'w')
|
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')
|
self.__write_to_head_obj = open(self.__header_holder, 'w')
|
||||||
line_to_read = 1
|
line_to_read = 1
|
||||||
while line_to_read:
|
while line_to_read:
|
||||||
@ -246,7 +248,7 @@ class Header:
|
|||||||
"""
|
"""
|
||||||
if not self.__found_a_header:
|
if not self.__found_a_header:
|
||||||
return
|
return
|
||||||
self.__write_to2 = tempfile.mktemp()
|
self.__write_to2 = better_mktemp()
|
||||||
self.__state = 'body'
|
self.__state = 'body'
|
||||||
self.__get_headers()
|
self.__get_headers()
|
||||||
self.__join_from_temp()
|
self.__join_from_temp()
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile, re
|
import os, re
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class HeadingsToSections:
|
class HeadingsToSections:
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
@ -34,7 +36,7 @@ class HeadingsToSections:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Required:
|
Required:
|
||||||
|
@ -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 import get_char_map, copy
|
||||||
from calibre.ebooks.rtf2xml.char_set import char_set
|
from calibre.ebooks.rtf2xml.char_set import char_set
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Hex2Utf8:
|
class Hex2Utf8:
|
||||||
"""
|
"""
|
||||||
@ -73,7 +74,7 @@ class Hex2Utf8:
|
|||||||
self.__convert_wingdings = 0
|
self.__convert_wingdings = 0
|
||||||
self.__convert_zapf = 0
|
self.__convert_zapf = 0
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__invalid_rtf_handler = invalid_rtf_handler
|
self.__invalid_rtf_handler = invalid_rtf_handler
|
||||||
|
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Info:
|
class Info:
|
||||||
"""
|
"""
|
||||||
@ -38,7 +39,7 @@ class Info:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import sys, os, tempfile
|
import sys, os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
"""
|
"""
|
||||||
States.
|
States.
|
||||||
@ -37,7 +38,7 @@ class Inline:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
|
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
from calibre.utils.cleantext import clean_ascii_chars
|
from calibre.utils.cleantext import clean_ascii_chars
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class FixLineEndings:
|
class FixLineEndings:
|
||||||
"""Fix line endings"""
|
"""Fix line endings"""
|
||||||
@ -28,7 +29,7 @@ class FixLineEndings:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__replace_illegals = replace_illegals
|
self.__replace_illegals = replace_illegals
|
||||||
|
|
||||||
def fix_endings(self):
|
def fix_endings(self):
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class ListNumbers:
|
class ListNumbers:
|
||||||
"""
|
"""
|
||||||
RTF puts list numbers outside of the paragraph. The public method
|
RTF puts list numbers outside of the paragraph. The public method
|
||||||
@ -36,7 +38,7 @@ class ListNumbers:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
initiate values for fix_list_numbers.
|
initiate values for fix_list_numbers.
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile, re
|
import sys, os, re
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class MakeLists:
|
class MakeLists:
|
||||||
"""
|
"""
|
||||||
Form lists.
|
Form lists.
|
||||||
@ -45,7 +47,7 @@ class MakeLists:
|
|||||||
self.__no_headings_as_list = no_headings_as_list
|
self.__no_headings_as_list = no_headings_as_list
|
||||||
self.__headings_to_sections = headings_to_sections
|
self.__headings_to_sections = headings_to_sections
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__list_of_lists = list_of_lists
|
self.__list_of_lists = list_of_lists
|
||||||
self.__write_list_info = write_list_info
|
self.__write_list_info = write_list_info
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy, border_parse
|
from calibre.ebooks.rtf2xml import copy, border_parse
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class ParagraphDef:
|
class ParagraphDef:
|
||||||
"""
|
"""
|
||||||
=================
|
=================
|
||||||
@ -66,7 +68,7 @@ if another paragraph_def is found, the state changes to collect_tokens.
|
|||||||
self.__default_font = default_font
|
self.__default_font = default_font
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Initiate all values.
|
Initiate all values.
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Paragraphs:
|
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.__copy = copy
|
||||||
self.__write_empty_para = write_empty_para
|
self.__write_empty_para = write_empty_para
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Initiate all values.
|
Initiate all values.
|
||||||
|
@ -10,9 +10,11 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
|
|
||||||
class Pict:
|
class Pict:
|
||||||
"""Process graphic information"""
|
"""Process graphic information"""
|
||||||
@ -28,7 +30,7 @@ class Pict:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__bracket_count = 0
|
self.__bracket_count = 0
|
||||||
self.__ob_count = 0
|
self.__ob_count = 0
|
||||||
self.__cb_count = 0
|
self.__cb_count = 0
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy, override_table, list_table
|
from calibre.ebooks.rtf2xml import copy, override_table, list_table
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class PreambleDiv:
|
class PreambleDiv:
|
||||||
"""
|
"""
|
||||||
Break the preamble into divisions.
|
Break the preamble into divisions.
|
||||||
@ -36,7 +38,7 @@ class PreambleDiv:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__no_namespace = no_namespace
|
self.__no_namespace = no_namespace
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, re, tempfile
|
import os, re
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy, check_brackets
|
from calibre.ebooks.rtf2xml import copy, check_brackets
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class ProcessTokens:
|
class ProcessTokens:
|
||||||
"""
|
"""
|
||||||
@ -31,7 +32,7 @@ class ProcessTokens:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.initiate_token_dict()
|
self.initiate_token_dict()
|
||||||
##self.initiate_token_actions()
|
##self.initiate_token_actions()
|
||||||
self.compile_expressions()
|
self.compile_expressions()
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
from calibre.utils.cleantext import clean_ascii_chars
|
from calibre.utils.cleantext import clean_ascii_chars
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class ReplaceIllegals:
|
class ReplaceIllegals:
|
||||||
"""
|
"""
|
||||||
@ -27,7 +28,7 @@ class ReplaceIllegals:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
|
|
||||||
def replace_illegals(self):
|
def replace_illegals(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Sections:
|
class Sections:
|
||||||
"""
|
"""
|
||||||
=================
|
=================
|
||||||
@ -66,7 +68,7 @@ Instead, ingore all section information in a field-block.
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Initiate all values.
|
Initiate all values.
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy, border_parse
|
from calibre.ebooks.rtf2xml import copy, border_parse
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Styles:
|
class Styles:
|
||||||
"""
|
"""
|
||||||
Change lines with style numbers to actual style names.
|
Change lines with style numbers to actual style names.
|
||||||
@ -35,7 +37,7 @@ class Styles:
|
|||||||
self.__file = in_file
|
self.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import sys, os, tempfile
|
import sys, os
|
||||||
from calibre.ebooks.rtf2xml import copy, border_parse
|
from calibre.ebooks.rtf2xml import copy, border_parse
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
"""
|
"""
|
||||||
States.
|
States.
|
||||||
1. 'not_in_table'
|
1. 'not_in_table'
|
||||||
@ -64,7 +66,7 @@ class Table:
|
|||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
def __initiate_values(self):
|
def __initiate_values(self):
|
||||||
"""
|
"""
|
||||||
Initiate all values.
|
Initiate all values.
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, tempfile
|
import os
|
||||||
from calibre.ebooks.rtf2xml import copy
|
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?
|
# 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.__copy = copy
|
||||||
self.__table_data = table_data
|
self.__table_data = table_data
|
||||||
self.__run_level = run_level
|
self.__run_level = run_level
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
# self.__write_to = 'table_info.data'
|
# self.__write_to = 'table_info.data'
|
||||||
def insert_info(self):
|
def insert_info(self):
|
||||||
"""
|
"""
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
# #
|
# #
|
||||||
# #
|
# #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
import os, re, tempfile
|
import os, re
|
||||||
|
|
||||||
from calibre.ebooks.rtf2xml import copy
|
from calibre.ebooks.rtf2xml import copy
|
||||||
from calibre.utils.mreplace import MReplace
|
from calibre.utils.mreplace import MReplace
|
||||||
|
from calibre.ptempfile import better_mktemp
|
||||||
|
|
||||||
class Tokenize:
|
class Tokenize:
|
||||||
"""Tokenize RTF into one line per field. Each line will contain information useful for the rest of the script"""
|
"""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.__file = in_file
|
||||||
self.__bug_handler = bug_handler
|
self.__bug_handler = bug_handler
|
||||||
self.__copy = copy
|
self.__copy = copy
|
||||||
self.__write_to = tempfile.mktemp()
|
self.__write_to = better_mktemp()
|
||||||
# self.__write_to = out_file
|
# self.__write_to = out_file
|
||||||
self.__compile_expressions()
|
self.__compile_expressions()
|
||||||
#variables
|
#variables
|
||||||
|
Loading…
x
Reference in New Issue
Block a user