Skip to content

Conversation

@stegro
Copy link

@stegro stegro commented Mar 20, 2018

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

stegro added 19 commits July 4, 2017 14:16
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.
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.
@leifdenby
Copy link
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants