diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index 317ed802022ffe2435ac06ae823202c2005e0746..5c619e7f7aa1fa3756ce019f33cc0e37f0a49777 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -105,10 +105,17 @@ class HTCFile(HTCContents, HTCDefaults, HTCExtensions): import numpy as np input_files = HTCFile(self.filename, 'unknown').input_files() rel_input_files = [f for f in input_files if not os.path.isabs(f)] - found = ([np.sum([os.path.isfile(os.path.join(os.path.dirname(self.filename), "../" * i, f)) + + def isfile_case_insensitive(f): + try: + unix_path_old(f) + return True + except IOError: + return False + found = ([np.sum([isfile_case_insensitive(os.path.join(os.path.dirname(self.filename), "../" * i, f)) for f in rel_input_files]) for i in range(4)]) # for f in self.input_files(): - # print (os.path.isfile(os.path.join(os.path.dirname(self.filename), "../",f)), f) + # print(os.path.isfile(os.path.join(os.path.dirname(self.filename), "../", f)), f) if max(found) > 0: relpath = "../" * np.argmax(found) return os.path.abspath(os.path.join(os.path.dirname(self.filename), relpath)) diff --git a/wetb/hawc2/tests/test_htc_file.py b/wetb/hawc2/tests/test_htc_file.py index cfb19aaa5cabcd32ec163e4149246c2bfe58c2f4..c43b58f396c5cce1dc2ab222eaf96834de811e55 100644 --- a/wetb/hawc2/tests/test_htc_file.py +++ b/wetb/hawc2/tests/test_htc_file.py @@ -300,6 +300,10 @@ end turb_export;""" htcfile.filename)).replace("\\", "/"), "../..") self.assertRaisesRegex(ValueError, "Modelpath cannot be autodetected", HTCFile, self.testfilepath + "test2.htc") + def test_htc_model_autodetect_upper_case_files(self): + htcfile = HTCFile(self.testfilepath + "../simulation_setup/DTU10MWRef6.0/htc/DTU_10MW_RWT.htc") + self.assertEqual(os.path.relpath(htcfile.modelpath, os.path.dirname(htcfile.filename)), "..") + def test_open_eq_save(self): HTCFile(self.testfilepath + "test3.htc", "../").save(self.testfilepath + "tmp.htc") htcfile = HTCFile(self.testfilepath + "tmp.htc", "../")