Can't set indentation when patching
The indentation option can currently only be set when constructing a Namelist object. However, for the case when you want to patch a file, then there's no way to set the indent option to be used for the ouput patch file.
I'm confused about this comment, because f90nml.patch is for replacing name-value strings inside an existing file, meaning that it should not actually change or modify the whitespace or any indentation. Sometimes the substitution can look a bit odd, but that would not be addressed by the indentation of Namelist.
Can you show me what you're trying to do, and why you want to use patch and need to change the in
With patch you can also add new keys, and for those it uses the default indentation.
Right, thanks, that makes sense. Hopefully not too difficult to implement.
I've added a patch which adds this feature. It should be added at the top (namelists) level:
patch = {
'a_grp': {
'x': 1,
'y': 2,
}
'_indent': '\t'
}
Hopefully this should work for you.
I experimented a bit with also permitting it at the group level, but it wasn't clear how to fallback to the namelist level if unset. (Note: #81 would presumably address this, but not yet sure if it's worth implementing this idea.)
Looks good! What happens if I include _indent in a version of f90nml that doesn't support this feature yet? Is it silently ignored?
I haven't checked, but fairly sure it will create an empty group named _delete, which may or may not be ignored by the Fortran runtime.
In any case, I probably ought to do another pypi update soon, though it would be good to at least have a crack at the current outstanding issues around patching :).
Actually, it seems it won't have any effect in older versions, since (as mentioned in #80) new content is simply ignored by patch.