def compile_code(): # Remove the existing mf6 directory if it exists if os.path.isdir(pth): shutil.rmtree(pth) # compile gridgen pymake.usgs_program_data().list_targets(current=True) replace_function = pymake.build_replace(target) pymake.build_program(target=target, fc=None, cc='g++', include_subdirs=True, download_dir=dstpth, replace_function=replace_function)
def compile_code(): # Remove the existing mf6 directory if it exists if os.path.isdir(mf6pth): shutil.rmtree(mf6pth) # compile MODFLOW 6 pymake.usgs_program_data().list_targets(current=True) replace_function = pymake.build_replace(target) pymake.build_program(target=target, include_subdirs=True, download_dir=dstpth, replace_function=replace_function)
def test_usgsprograms_export_json(): # export code.json and return json file path fpth = export_code_json() # test the json export with open(fpth, "r") as f: json_dict = json.load(f) json_keys = list(json_dict.keys()) current_keys = pymake.usgs_program_data.get_keys(current=True) msg = "the number of current keys is not equal to json keys" assert len(json_keys) == len(current_keys), msg prog_dict = pymake.usgs_program_data().get_program_dict() for key, value in json_dict.items(): temp_dict = prog_dict[key] # fill keys that are programmatically filled fill_keys = ("url_download_asset_date",) for fill_key in fill_keys: temp_dict[fill_key] = value[fill_key] msg = ( "json dictionary for {} key ".format(key) + "is not equal to the .usgs_prog_data dictionary" ) assert value == temp_dict, msg
def test_usgsprograms_export_json(): fpth = os.path.join(cpth, 'code.test.json') pymake.usgs_program_data.export_json(fpth=fpth, current=True) # check that the json file was made msg = 'did not make...{}'.format(fpth) assert os.path.isfile(fpth), msg # test the json export with open(fpth, 'r') as f: json_dict = json.load(f) json_keys = list(json_dict.keys()) current_keys = pymake.usgs_program_data.get_keys(current=True) msg = 'the number of current keys is not equal to json keys' assert len(json_keys) == len(current_keys), msg prog_dict = pymake.usgs_program_data().get_program_dict() for key, value in json_dict.items(): temp_dict = prog_dict[key] msg = 'json dictionary for {} key '.format(key) + \ 'is not equal to the .usgs_prog_data dictionary' assert value == temp_dict, msg return
def test_usgsprograms(): print("test_usgsprograms()") upd = pymake.usgs_program_data().get_program_dict() all_keys = list(upd.keys()) get_keys = pymake.usgs_program_data.get_keys() msg = "the keys from program_dict are not equal to .get_keys()" assert all_keys == get_keys, msg
def test_target_keys(): print("test_target_keys()") prog_dict = pymake.usgs_program_data().get_program_dict() targets = pymake.usgs_program_data.get_keys() for target in targets: target_dict = pymake.usgs_program_data.get_target(target) test_dict = prog_dict[target] msg = ("dictionary from {} ".format(target) + "does not match dictionary from .get_target()") assert target_dict == test_dict, msg
def test_usgsprograms(): upd = pymake.usgs_program_data().get_program_dict() all_keys = list(upd.keys()) get_keys = pymake.usgs_program_data.get_keys() msg = 'the keys from program_dict are not equal to .get_keys()' assert all_keys == get_keys, msg return
def test_target_keys(): prog_dict = pymake.usgs_program_data().get_program_dict() targets = pymake.usgs_program_data.get_keys() for target in targets: target_dict = pymake.usgs_program_data.get_target(target) test_dict = prog_dict[target] msg = 'dictionary from {} '.format(target) + \ 'does not match dictionary from .get_target()' assert target_dict == test_dict, msg return
target = "mt3dusgs" # get program dictionary prog_dict = pymake.usgs_program_data.get_target(target) # set up paths dstpth = os.path.join("temp") if not os.path.exists(dstpth): os.makedirs(dstpth) mtusgsver = prog_dict.version mtusgspth = os.path.join(dstpth, prog_dict.dirname) emtusgs = os.path.abspath(os.path.join(dstpth, target)) mfnwt_target = "mfnwt" temp_dict = pymake.usgs_program_data().get_target(mfnwt_target) emfnwt = os.path.abspath(os.path.join(dstpth, mfnwt_target)) mf6_target = "mf6" temp_dict = pymake.usgs_program_data().get_target(mf6_target) emf6 = os.path.abspath(os.path.join(dstpth, mf6_target)) if sys.platform.lower() == "win32": ext = ".exe" emtusgs += ext emfnwt += ext emf6 += ext # example path expth = os.path.join(mtusgspth, "data")
# define program data target = 'mt3dusgs' prog_dict = pymake.usgs_program_data.get_target(target) # set up paths dstpth = os.path.join('temp') if not os.path.exists(dstpth): os.makedirs(dstpth) mtusgsver = prog_dict.version mtusgspth = os.path.join(dstpth, prog_dict.dirname) emtusgs = os.path.abspath(os.path.join(dstpth, target)) mfnwt_target = 'mfnwt' temp_dict = pymake.usgs_program_data().get_target(mfnwt_target) mfnwtpth = os.path.join(dstpth, temp_dict.dirname) emfnwt = os.path.abspath(os.path.join(dstpth, mfnwt_target)) # example path expth = os.path.join(mtusgspth, 'data') # set up pths and exes pths = [mtusgspth, mfnwtpth] exes = [emtusgs, emfnwt] def get_example_dirs(): exclude_dirs = ['Keating', 'Keating_UZF'] exdirs = [ o for o in os.listdir(expth)
# define program data target = 'mt3dusgs' prog_dict = pymake.usgs_program_data.get_target(target) # set up paths dstpth = os.path.join('temp') if not os.path.exists(dstpth): os.makedirs(dstpth) mtusgsver = prog_dict.version mtusgspth = os.path.join(dstpth, prog_dict.dirname) emtusgs = os.path.abspath(os.path.join(dstpth, target)) mfnwt_target = 'mfnwt' temp_dict = pymake.usgs_program_data().get_target(mfnwt_target) mfnwtpth = os.path.join(dstpth, temp_dict.dirname) emfnwt = os.path.abspath(os.path.join(dstpth, mfnwt_target)) # example path expth = os.path.join(mtusgspth, 'data') # set up pths and exes pths = [mtusgspth, mfnwtpth] exes = [emtusgs, emfnwt] def get_example_dirs(): exclude_dirs = ['Keating', 'Keating_UZF'] exdirs = [o for o in os.listdir(expth) if os.path.isdir(os.path.join(expth, o)) and