f90nml
f90nml copied to clipboard
end commas when patching
When patching a existing namelist with trailing commas, the commas are not preserved.
I tried a similar technique to #79 and it did not work
patch = {
'data': {
'a': 1,
'b'': 2
},
'_end_comma': True
}
f90nml.patch('input_file.inp', patch, 'output_file.out')
I've also tried patching with a Namelist object, which also does not work.
nml = f90nml.namelist.Namelist()
nml.end_comma = True
nml['data'] = {'a': 1, 'b': 2}
parser = f90nml.Parser()
parser.read('input_file.inp', patch, 'output_file.out')
Is there something perhaps I'm missing or is this feature not available yet?
Thanks!
I'm pretty sure it's just never been implemented. It would not be too difficult to add it, though. I'll have a look tonight.
Sweet. Thank you!
I've just realized that this is not a simple change. This is because patch
is not creating a new data output. Rather, it's catching the input stream, modifying the values, and then streaming that data to the output.
To do this correctly, we'd also have to know that we're at the end of a record, which may not be possible since the current patch
may have already written its output.
This is a limitation of patch
that I was hoping to address with more aggressive lookahead and a new parser, but that project has been stalled for a long time.
I'll have a bit deeper look and see if this one is easy enough to catch, but just a heads up that it may not be simple, if even possible.
Thanks for the update. Appreciate you looking into this. Would be awesome if this could be implemented but I understand if the amount of work involved to get there isn't worth it.
No worries, I will keep the issue open as a feature request.