Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mikeio/pfs/_pfsdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ def _parse_line(self, line: str, level: int = 0) -> tuple[str, int]:
def _parse_param(self, value: str) -> str:
if len(value) == 0:
return "[]"
if value[0] == "|" and value[-1] == "|":
if value.count("|") == 2:
return self._parse_token(value)
if "MULTIPOLYGON" in value:
return value
if "," in value:
Expand Down
9 changes: 7 additions & 2 deletions tests/test_pfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def test_pfssection_insert_pfssection(d1) -> None:

for j in range(10):
dj = dict(val=j, lst=[0.3, 0.7])
key = f"FILE_{j+1}"
key = f"FILE_{j + 1}"
sct[key] = mikeio.PfsSection(dj)

assert sct.FILE_6.val == 5
Expand All @@ -226,7 +226,7 @@ def test_pfssection_find_replace(d1) -> None:

for j in range(10):
dj = dict(val=j, lst=[0.3, 0.7])
key = f"FILE_{j+1}"
key = f"FILE_{j + 1}"
sct[key] = mikeio.PfsSection(dj)

assert sct.FILE_6.lst == [0.3, 0.7]
Expand Down Expand Up @@ -1250,3 +1250,8 @@ def test_ignores_comments_in_quotes() -> None:
"""
pfs = mikeio.PfsDocument.from_text(text)
assert pfs.SymbologyModule.SymbologyTreeView == "//"


def test_filenames_may_contain_comma() -> None:
pfs = mikeio.read_pfs("tests/testdata/pfs/tidal.21t")
assert pfs.m21_tideph.Setup.File_1.mesh_file == "|.\\b,athy.mesh|"
26 changes: 26 additions & 0 deletions tests/testdata/pfs/tidal.21t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[m21_tideph]
CLSID = 'TidePredictionHeights.dll'
TypeName = 'm21_tideph'
CREATEDTIME = '2018-01-25T08:27:01'
MODIFIEDTIME = '2018-01-25T08:28:25'
NOTES = ''
[Setup]
Name = 'Esbjerg1989Global_Area'
Prediction_type = 1
constituent_file_name = |..\..\..\..\..\..\..\..\Program Files (x86)\DHI\MIKE Zero\2024\Application Data\Tide_Constituents\global_tide_constituents_height_0.25deg.dfs2|
start_date = 1989, 1, 1
end_date = 1990, 1, 4
timestep = 1.0
number_of_files = 1
[File_1]
format = 3
mesh_file = |.\b,athy.mesh|
file_name = |.\Esbjerg1989PredictedGlobal.dfsu|
description = 'Predicted tide level'
EndSect // File_1

logfilelocation = |.\|
EndSect // Setup

EndSect // m21_tideph