Skip to content
Open
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
6 changes: 5 additions & 1 deletion imod/formats/prj/prj.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
_wrap_error_message(e, "species entry", lines)


def _parse_block(lines: _LineIterator, content: Dict[str, Any]) -> None:

Check failure on line 443 in imod/formats/prj/prj.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=Deltares_imod-python&issues=AZ7VHOHA6YURyNVdLwjA&open=AZ7VHOHA6YURyNVdLwjA&pullRequest=1868
"""
Mutates content dict.
"""
Expand All @@ -451,6 +451,8 @@
while key is None and not lines.finished:
n, key, active = _parse_blockheader(lines)

if key is None:
return
try:
if key in KEYS:
if n != 1:
Expand Down Expand Up @@ -482,7 +484,9 @@
)

except Exception as e:
raise type(e)(f"{e}\nError occurred for keyword: {key}")
raise type(e)(
f"{e}\nError occurred for keyword: {key} in line {lines.count + 1}"
)

if blockcontent is not None and active is not None:
blockcontent["active"] = active
Expand Down
3 changes: 3 additions & 0 deletions imod/tests/test_formats/test_prj.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
1,2, 000, 100000.0, 1.0, -999.9900 ,"{basepath}/first.gen"
1,2, 000, 100000.0, 1.0, -999.9900 ,"{basepath}/second.gen"



0001,(PCG),1, Precondition Conjugate-Gradient,[]
MXITER= 500
ITER1= 25
Expand All @@ -118,6 +120,7 @@
"benzene",1
"chloride",2


"""
)

Expand Down
Loading