Skip to content

Commit

Permalink
Facilitate argparse documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Aug 13, 2023
1 parent 9c32976 commit 08d906a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
12 changes: 10 additions & 2 deletions interfaces/cython/cantera/cti2yaml.py
Expand Up @@ -1720,8 +1720,10 @@ def convert(filename=None, output_name=None, text=None, encoding="latin-1"):
return len(_species), len(_reactions), surfaces, output_name


def main():
"""Parse command line arguments and pass them to `convert`."""
def create_argparser():
"""
Create argparse parser
"""
parser = argparse.ArgumentParser(
description=(
"Convert legacy CTI input files to YAML format, where the first contiguous "
Expand All @@ -1743,6 +1745,12 @@ def main():
"--no-validate", action="store_true", default=False,
help="Skip validation step.")

return parser


def main():
"""Parse command line arguments and pass them to `convert`."""
parser = create_argparser()
if len(sys.argv) not in [2, 3, 4, 5]:
if len(sys.argv) > 5:
print(
Expand Down
13 changes: 11 additions & 2 deletions interfaces/cython/cantera/ctml2yaml.py
Expand Up @@ -2652,8 +2652,10 @@ def convert(
emitter.dump(output_reactions, output_file)


def main():
"""Parse command line arguments and pass them to `convert`."""
def create_argparser():
"""
Create argparse parser
"""
parser = argparse.ArgumentParser(
description="Convert legacy CTML input files to YAML format",
epilog=(
Expand All @@ -2664,6 +2666,13 @@ def main():
)
parser.add_argument("input", help="The input CTML filename. Must be specified.")
parser.add_argument("output", nargs="?", help="The output YAML filename. Optional.")

return parser


def main():
"""Parse command line arguments and pass them to `convert`."""
parser = create_argparser()
if len(sys.argv) not in [2, 3]:
if len(sys.argv) > 3:
print(
Expand Down
16 changes: 11 additions & 5 deletions interfaces/cython/cantera/yaml2ck.py
Expand Up @@ -717,13 +717,10 @@ def convert(
return output_files


def main():
def create_argparser():
"""
Parse command line arguments and pass them to `convert`
.. versionadded:: 3.0
Create argparse parser
"""

parser = argparse.ArgumentParser(
description="Convert Cantera YAML input files to Chemkin-format mechanisms",
)
Expand Down Expand Up @@ -795,7 +792,16 @@ def main():
default=True,
help="Check that the mechanism can be loaded back into Cantera.",
)
return parser


def main():
"""
Parse command line arguments and pass them to `convert`
.. versionadded:: 3.0
"""
parser = create_argparser()
args = parser.parse_args()

output_paths = convert(
Expand Down

0 comments on commit 08d906a

Please sign in to comment.