55import argparse
66import base64
77import calendar
8- import codecs
98import json
109import logging
1110import os
@@ -2304,7 +2303,7 @@ def gist_backup_is_current(repository, repo_cwd, repo_dir):
23042303 if not updated_at :
23052304 return False
23062305 try :
2307- with codecs . open (os .path .join (repo_cwd , "gist.json" ), encoding = "utf-8" ) as f :
2306+ with open (os .path .join (repo_cwd , "gist.json" ), encoding = "utf-8" , newline = " " ) as f :
23082307 stored = json .load (f )
23092308 except (OSError , ValueError ):
23102309 return False
@@ -2377,7 +2376,7 @@ def backup_repositories(args, output_directory, repositories):
23772376 # DMCA-blocked or empty gist), so make sure the directory exists
23782377 mkdir_p (repo_cwd )
23792378 output_file = "{0}/gist.json" .format (repo_cwd )
2380- with codecs . open (output_file , "w" , encoding = "utf-8" ) as f :
2379+ with open (output_file , "w" , encoding = "utf-8" , newline = " " ) as f :
23812380 json_dump (repository , f )
23822381
23832382 continue # don't try to back anything else for a gist; it doesn't exist
@@ -3021,7 +3020,7 @@ def backup_issues(args, repo_cwd, repository, repos_template):
30213020 args , issue_cwd , issues [number ], number , repository , item_type = "issue"
30223021 )
30233022
3024- with codecs . open (issue_file + ".temp" , "w" , encoding = "utf-8" ) as f :
3023+ with open (issue_file + ".temp" , "w" , encoding = "utf-8" , newline = " " ) as f :
30253024 json_dump (issue , f )
30263025 os .replace (issue_file + ".temp" , issue_file ) # Atomic write
30273026
@@ -3040,7 +3039,7 @@ def read_json_file_if_exists(path):
30403039 return None
30413040
30423041 try :
3043- with codecs . open (path , "r" , encoding = "utf-8" ) as f :
3042+ with open (path , "r" , encoding = "utf-8" , newline = " " ) as f :
30443043 return json .load (f )
30453044 except (OSError , UnicodeDecodeError , json .decoder .JSONDecodeError ) as e :
30463045 logger .debug ("Error reading existing JSON file {0}: {1}" .format (path , e ))
@@ -3230,7 +3229,7 @@ def pull_is_due_for_repository_checkpoint(pull):
32303229
32313230 restore_existing_pull_optional_data (pull , existing_pull )
32323231
3233- with codecs . open (pull_file + ".temp" , "w" , encoding = "utf-8" ) as f :
3232+ with open (pull_file + ".temp" , "w" , encoding = "utf-8" , newline = " " ) as f :
32343233 json_dump (pull , f )
32353234 os .replace (pull_file + ".temp" , pull_file ) # Atomic write
32363235
@@ -3646,7 +3645,7 @@ def json_dump_if_changed(data, output_file_path):
36463645 # Check if file exists and compare content
36473646 if os .path .exists (output_file_path ):
36483647 try :
3649- with codecs . open (output_file_path , "r" , encoding = "utf-8" ) as f :
3648+ with open (output_file_path , "r" , encoding = "utf-8" , newline = " " ) as f :
36503649 existing_content = f .read ()
36513650 if existing_content == new_content :
36523651 logger .debug (
@@ -3663,7 +3662,7 @@ def json_dump_if_changed(data, output_file_path):
36633662
36643663 # Write the file atomically using temp file + rename
36653664 temp_file = output_file_path + ".temp"
3666- with codecs . open (temp_file , "w" , encoding = "utf-8" ) as f :
3665+ with open (temp_file , "w" , encoding = "utf-8" , newline = " " ) as f :
36673666 f .write (new_content )
36683667 os .replace (temp_file , output_file_path ) # Atomic write
36693668 return True
0 commit comments