]> git.phdru.name Git - bookmarks_db.git/commitdiff
Chore: Explicitly open text files in text mode
authorOleg Broytman <phd@phdru.name>
Mon, 13 Nov 2023 14:39:17 +0000 (17:39 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 13 Nov 2023 19:02:26 +0000 (22:02 +0300)
Robots/bkmk_rforking.py
Storage/bkmk_stflad.py
bkmk2db.py
check_dups.py
db2bkmk.py
parse_html/bkmk_parse_html.py
set-title-list.py
sort_db.py

index 136440c28ecc7cdc834e1563087aa154df9de220..117bf31913fba0b866217980ed58d85a04d56b97 100644 (file)
@@ -24,7 +24,7 @@ from bkmk_objects import Robot
 
 # 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
index a15d60554a9ace8abd5d371338daaf2aad805ba8..7a29b83cd1c76b5f03faefa2decb0897a06d6efb 100644 (file)
@@ -25,7 +25,7 @@ class storage_flad(Walker):
     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)
@@ -61,7 +61,7 @@ Charset: %s
         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()
 
@@ -83,7 +83,7 @@ Charset: %s
         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()
 
index 5a96d7f1f7926496cb8fbe5bcd34a8b5002207b2..629668d4cbc99fe7dd8690376bfa6b0875b22d4c 100755 (executable)
@@ -76,7 +76,7 @@ def run():
         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
index 25c2936da800999cf5e84b9a1e2b0e6c4ec83bd6..df79df86cbe1aecea85ef89601b097c06b8c4225 100755 (executable)
@@ -52,7 +52,7 @@ def run():
         sys.exit(1)
 
     if log_filename:
-        log_file = open(log_filename, 'w')
+        log_file = open(log_filename, 'wt')
 
     from storage import storage
     storage = storage()
index 4e50101c6176318b377475c5704544d3595b31f0..7d1d9aa19f1c46fdebd47e45f859ab7a7c7e2ba7 100755 (executable)
@@ -97,7 +97,7 @@ def run():
 
         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()
 
index ddfad27bf378daabc202e23ea5807005d92fb671..85aeb88e4b63bef832f7f67871cb32e54e57a3de 100644 (file)
@@ -226,7 +226,7 @@ def parse_html(html_text, charset=None, log=None):
 
 
 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:
index 4644a81a7786eef016dc5ebf1364d10d727a8bb5..be0684c15acad921c9f7e04dca9afe3d1fce4109 100755 (executable)
@@ -42,7 +42,7 @@ def run():
     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:
index bcd3a8ed6aa50387ec3766ed75dc0e7af7c62c5b..4dd117e51219cbf818d3c9ce4db004b676e07cf2 100755 (executable)
@@ -99,7 +99,7 @@ def run():
         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)