@@ -963,7 +963,7 @@ def valid_date(date_text):
963963 return False
964964
965965
966- def generate_file_trees (instance , force = False ):
966+ def generate_file_trees (instance ):
967967 """ Generate file trees. Force if we want to remove depedency on the machine.
968968 """
969969
@@ -982,29 +982,45 @@ def generate_file_trees(instance, force=False):
982982 gft = True
983983
984984 # generate file trees
985- if gft or force :
986- instance .logger .info ('Generating file trees...' )
987- instance .all_observation_data = get_ghost_observational_tree (instance )
988- if instance .nonghost_root is not None :
989- nonghost_observation_data = get_nonghost_observational_tree (instance )
985+ ghost_filetree_path = join (PROVIDENTIA_ROOT , 'settings/internal/ghost_filetree_{}.json' .format (instance .ghost_version ))
986+ nonghost_filetree_path = join (PROVIDENTIA_ROOT , 'settings/internal/nonghost_filetree.json' )
987+
988+ # generate file trees for ghost
989+ if gft or (not os .path .exists (ghost_filetree_path )):
990+ if not os .path .exists (ghost_filetree_path ):
991+ instance .logger .info (f'Generating file tree { ghost_filetree_path } ...' )
992+ else :
993+ instance .logger .info (f'Updating file tree { ghost_filetree_path } ...' )
994+ instance .all_observation_data = get_ghost_observational_tree (instance )
990995 # load file trees
991996 else :
997+ instance .logger .info (f'Loading file tree { ghost_filetree_path } ...' )
992998 try :
993999 instance .all_observation_data = json .load (open (join (PROVIDENTIA_ROOT , 'settings/internal/ghost_filetree_{}.json' .format (instance .ghost_version ))))
9941000 except FileNotFoundError as file_error :
9951001 error = "Error: Trying to load 'settings/internal/ghost_filetree_{}.json' but file does not exist. Run with the flag '--gft' to generate this file." .format (instance .ghost_version )
9961002 instance .logger .error (error )
9971003 sys .exit (1 )
998- if instance .nonghost_root is not None :
1004+
1005+ if instance .nonghost_root is not None :
1006+ # generate file trees for nonghost
1007+ if gft or (not os .path .exists (nonghost_filetree_path )):
1008+ if not os .path .exists (nonghost_filetree_path ):
1009+ instance .logger .info (f'Generating file tree { nonghost_filetree_path } ...' )
1010+ else :
1011+ instance .logger .info (f'Updating file tree { nonghost_filetree_path } ...' )
1012+ nonghost_observation_data = get_nonghost_observational_tree (instance )
1013+ # load file trees
1014+ else :
1015+ instance .logger .info (f'Loading file tree { nonghost_filetree_path } ...' )
9991016 try :
10001017 nonghost_observation_data = json .load (open (join (PROVIDENTIA_ROOT , 'settings/internal/nonghost_filetree.json' )))
10011018 except FileNotFoundError as file_error :
10021019 error = "Error: Trying to load 'settings/internal/nonghost_filetree.json' but file does not exist. Run with the flag '--gft' to generate this file."
10031020 instance .logger .error (error )
10041021 sys .exit (1 )
10051022
1006- # merge GHOST and non-GHOST filetrees
1007- if instance .nonghost_root is not None :
1023+ # merge GHOST and non-GHOST filetrees
10081024 instance .all_observation_data = {** instance .all_observation_data , ** nonghost_observation_data }
10091025
10101026
0 commit comments