# This is to catch 'close failed: [Errno 9] Bad file descriptor' message
# from os.close() in Subprocess.die() and errors from the subprocess.
-sys.stderr = open("err.log", 'a')
+sys.stderr = open("err.log", 'at')
check_subp = None
subp_pipe = None
def root_folder(self, f):
header = f.header.replace(".", ".\n")
header = header.replace("<", "\n<", 3)[1:]
- header_file = open("header", 'w')
+ header_file = open("header", 'wt')
header_file.write(header + "\n")
header_file.write('<H1>%s</H1>\n\n' % f.name)
if f.comment: header_file.write('<DD>%s\n' % f.comment)
self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1))
def store(self, root_folder):
- self.outfile = open(self.filename, 'w')
+ self.outfile = open(self.filename, 'wt')
root_folder.walk_depth(self)
self.outfile.close()
self.folder_stack = [root_folder]
self.current_folder = root_folder
- header_file = open("header", 'r')
+ header_file = open("header", 'rt')
header = header_file.read()
header_file.close()
else:
dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct
- infile = open(filename, 'r')
+ infile = open(filename, 'rt')
parser = BkmkParser()
line_no = 0
sys.exit(1)
if log_filename:
- log_file = open(log_filename, 'w')
+ log_file = open(log_filename, 'wt')
from storage import storage
storage = storage()
root_folder.walk_depth(Transl(transl_d))
- outfile = open(output_filename, 'w', encoding='utf-8')
+ outfile = open(output_filename, 'wt', encoding='utf-8')
root_folder.walk_depth(writer(outfile, prune))
outfile.close()
def parse_filename(filename, charset=None, log=None):
- fp = open(filename, 'r')
+ fp = open(filename, 'rt')
try:
parser = parse_html(fp.read(), charset=charset, log=log)
finally:
URL = None
title = None
- title_list_file = open(args[0], 'r')
+ title_list_file = open(args[0], 'rt')
for line in title_list_file:
line = line[:-1] # strip trailing newline
if URL is None:
sys.stdout.write("Writing %s: " % output_filename)
sys.stdout.flush()
- outfile = open(output_filename, 'w', encoding='utf-8')
+ outfile = open(output_filename, 'wt', encoding='utf-8')
writer = writer(outfile)
writer.root_folder(root_folder)
walk_linear(linear, writer)