Open
Conversation
to be able to parse more complicated namelist files. Valid logical values in other formats than .false. and F are recognised now. The parser relies in parts on the ast.literal_eval() function. The result namelist.groups is not case-insensitive, i.e. the keys 'mode' and 'MODE' refer to the same item. Treatment of comments is much improved.
An optional argument to the constructor of the Namelist object allows to use an alternative format. Example: two 'species' namelists lead to keys 'species01' and 'species02'.
improve parsing: strings can be enclosed in double quotes, and the array_re pattern missed whitespaces in front of commas sometimes. Blanks at the right hand side are stripped from strings. Dumps will produce a scientific notation for floats by default. This can be changed with an optional argument to dump() . Properly check for string type. And document the attribute notation via the 'data' member.
Example: two 'SPECIES' namelists will be parsed into groups['species'][0] and groups['species'][1] They are also dumped correctly now.
If this folder is called 'namelist_python' and the parent directory is in the PYTHONPATH, then scripts can call import namelist_python
In these, strings are not quoted.
…sary tests pass now.
In some rare cases (I am not sure when), parsing an array yields a tuple, not a list. Then this line failed when dumping the data.
Owner
|
hi @stegro, thank you for your work here! Could you make separate pull requests for each feature/bug you are fixing? It looks like there are quite a few things you are changing here. I'll then go through each pull request and give feedback so that we can merge in your changes. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi guys,
I don't know if you noticed my fork.
Can you give me a short update of what you have implemented upstream, maybe?
cheers
Stefan