@@ -479,9 +479,8 @@ def copy_common_source_files(start_dir=COMMON_DIR, clean_common=False):
479479 if file .endswith (".rst" ):
480480 # debug(" FILE: %s" % file)
481481 source_file_path = os .path .join (root , file )
482- source_file = open (source_file_path , 'r' , encoding = 'utf-8' )
483- source_content = source_file .read ()
484- source_file .close ()
482+ with open (source_file_path , 'r' , encoding = 'utf-8' ) as source_file :
483+ source_content = source_file .read ()
485484 targets = get_copy_targets (source_content )
486485 for wiki in targets :
487486 content = strip_content (source_content , wiki )
@@ -512,9 +511,8 @@ def copy_common_source_files(start_dir=COMMON_DIR, clean_common=False):
512511 shutil .copy2 (src , dst )
513512 elif file .endswith (".js" ):
514513 source_file_path = os .path .join (root , file )
515- source_file = open (source_file_path , 'r' , encoding = 'utf-8' )
516- source_content = source_file .read ()
517- source_file .close ()
514+ with open (source_file_path , 'r' , encoding = 'utf-8' ) as source_file :
515+ source_content = source_file .read ()
518516 targets = get_copy_targets (source_content )
519517 for wiki in targets :
520518 content = strip_content (source_content , wiki )
@@ -885,7 +883,8 @@ def create_features_pages(site):
885883 # fetch and load most-recently-built features.json
886884 remove_if_exists ("features.json.gz" )
887885 fetch_url ("https://firmware.ardupilot.org/features.json.gz" )
888- features_json = json .load (gzip .open ("features.json.gz" ))
886+ with gzip .open ("features.json.gz" ) as in_file :
887+ features_json = json .load (in_file )
889888 if features_json ["format-version" ] != "1.0.0" :
890889 progress ("bad format version" )
891890 return
0 commit comments