Skip to content

Commit

Permalink
Provide index support for namelist cogroup patches
Browse files Browse the repository at this point in the history
If a group was a Cogroup, then patch() would apply the patch to all
cogroups.  This change introduces a `_index` argument which specifies
the specific cougroup which should be patched.
  • Loading branch information
marshallward committed Aug 23, 2023
1 parent d65e593 commit 5b85248
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion f90nml/namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,12 @@ def patch(self, nml_patch):
for sec in nml_patch:
if sec not in self:
self[sec] = Namelist()
self[sec].update(nml_patch[sec])

if '_index' in nml_patch[sec]:
index = int(nml_patch[sec].pop('_index'))
self[sec][index].update(nml_patch[sec])
else:
self[sec].update(nml_patch[sec])

def groups(self):
"""Return an iterator that spans values with group and variable names.
Expand Down

0 comments on commit 5b85248

Please sign in to comment.