Facilitate argparse documentation

This commit is contained in:
Ingmar Schoegl 2023-08-11 06:13:16 -05:00 committed by Ray Speth
parent 9c32976165
commit 08d906aed2
3 changed files with 32 additions and 9 deletions

View File

@ -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 "
@ -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(

View File

@ -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=(
@ -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(

View File

@ -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",
)
@ -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(