diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index 92740e805ce5d9b21e70d4980bbea2335b27013b..52caf64aaff34047faeb09d2baeb34c009dbe581 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -72,7 +72,9 @@ class HTCFile(HTCContents, HTCDefaults): self.htc_inputfiles.append(filename) htc_lines = [] with open(filename, encoding='cp1252') as fid: - lines = fid.readlines() + lines = list(fid.readlines()) + if lines[0].encode().startswith(b'\xc3\xaf\xc2\xbb\xc2\xbf'): + lines[0] = lines[0][3:] for l in lines: if l.lower().lstrip().startswith('continue_in_file'): filename = l.lstrip().split(";")[0][len("continue_in_file"):].strip() diff --git a/wetb/hawc2/tests/test_htc_file.py b/wetb/hawc2/tests/test_htc_file.py index 71fbb4d276d38b939895e7164e2825b1c768d8e0..4c5fd8060eb19cb3991e557a650ca0885f717d54 100644 --- a/wetb/hawc2/tests/test_htc_file.py +++ b/wetb/hawc2/tests/test_htc_file.py @@ -241,6 +241,11 @@ class TestHtcFile(unittest.TestCase): def test_ansi(self): htcfile = HTCFile(self.testfilepath + "./ansi.htc") + def test_file_with_BOM(self): + htcfile = HTCFile(self.testfilepath + 'DLC15_wsp11_wdir000_s0000_phi000_Free_v2_visual.htc') + self.assertEqual(str(htcfile)[0], ";") + +