Open arporter opened 7 years ago
The script_options module contains four functions. This is get_fortran_code_group
, which adds the --mode
argument, and three more functions that basically all add a --task={show,none}
argument, only that set_read_options
does not add none
as choice, which leaves show
as only choice!?
Why are there these three functions doing the same thing? Would it be an option to only have one method configuring the parser?
They actually don't do the same thing. They all add a different help message to the parser:
Question is: Should these different messages stay? I don't see great benefit coming from them, so I would unify them to make the code cleaner. If the user should have the choice which ruleset to use (F2003 or not), this should be a simple option as well.
In fact this module is not used by the main fparser code base - it is only used by the scripts in the scripts
directory:
polo fparser$ grep script_options *.py
polo fparser$ grep script_options scripts/*.py
scripts/f2003.py:from fparser.script_options import set_f2003_options
scripts/parse.py:from fparser.script_options import set_parse_options
scripts/read.py:from fparser.script_options import set_read_options
I'd therefore be tempted to get rid of this module and move each of the respective routines into the appropriate script file. We're not getting any re-use of them as they are and it would make their purpose more obvious.
I actually ported all stuff to argparse, but somehow screwed up the github Pull Request process by commiting stuff in between into my fork. Need to fix that.
However, moving the parser configuration into the scripts itself shouldn't be a problem at all. And it would clearly simplify the code structure. When I figured out how to clean up my fork, I'll create a pull request for it.
In
script_options.py
fparser uses theoptparse
module for command-line argument processing. This module has now been deprecated in favour ofargparse
.