@@ -287,7 +287,7 @@ def sphinx_make(site, parallel, fast):
287287 continue
288288 if wiki == 'frontend' :
289289 continue
290- if site is not None and not site = = wiki :
290+ if site is not None and site ! = wiki :
291291 continue
292292 p = multiprocessing .Process (target = build_one , args = (wiki , fast ))
293293 p .start ()
@@ -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 , 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 , 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,14 +883,15 @@ 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
892891 features = features_json ["features" ]
893892
894893 # progress("features: (%s)" % str(features))
895- for wiki in WIKI_NAME_TO_VEHICLE_NAME . keys () :
894+ for wiki in WIKI_NAME_TO_VEHICLE_NAME :
896895 debug (wiki )
897896 if site is not None and site != wiki :
898897 continue
@@ -943,10 +942,7 @@ def create_features_page(features, build_options_by_define, vehicletype):
943942 # mismatch between build_options.py and features.json
944943 progress (f"feature { feature } ({ platform_key } ,{ vehicletype } ) not in build_options.py" )
945944 continue
946- if feature_in :
947- some_list = sorted_platform_features_in
948- else :
949- some_list = sorted_platform_features_not_in
945+ some_list = sorted_platform_features_in if feature_in else sorted_platform_features_not_in
950946 some_list .append ((build_options .category , feature ))
951947
952948 sorted_platform_features = (
@@ -965,10 +961,7 @@ def create_features_page(features, build_options_by_define, vehicletype):
965961 # for now, do not include features that are on the
966962 # board, just those that aren't, per Henry's request:
967963 rows .append (row )
968- if len (rows ) == 0 :
969- t = ""
970- else :
971- t = rst_table .tablify (rows , headings = column_headings )
964+ t = rst_table .tablify (rows , headings = column_headings ) if rows else ""
972965 underline = "-" * len (platform_key )
973966 all_tables += (f'''
974967.. _{ reference_for_board (platform_key )} :
0 commit comments