Skip to content

Commit

Permalink
Normalize how extensions are shown in the docs and help
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe committed Jan 11, 2022
1 parent 7d7303f commit f0bc3b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions overreact/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def main(arguments=None):
)
parser.add_argument(
"path",
help="path to a source (`.k`) or compiled (.jk) model input file (if a source "
help="path to a source (`.k`) or compiled (`.jk`) model input file (if a source "
"input file is given, but there is a compiled file available, the compiled "
"file will be used; use --compile|-c to force recompilation of the "
"source input file instead)",
Expand Down Expand Up @@ -766,7 +766,7 @@ def main(arguments=None):
"--compile",
# TODO(schneiderfelipe): should we consider --compile|-c always as a
# do-nothing (no analysis)?
help="force recompile a source (`.k`) into a compiled (.jk) model input file",
help="force recompile a source (`.k`) into a compiled (`.jk`) model input file",
action="store_true",
)
parser.add_argument(
Expand Down
12 changes: 6 additions & 6 deletions overreact/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_model(path: Text, force_compile: bool = False):
----------
path : str
Path to the model or source input file.
If the final extension is not ``.jk`` or ``.k``, it is guessed.
If the final extension is not `.jk` or `.k`, it is guessed.
force_compile : bool
If True, a `.k` file will take precedence over any `.jk` file for reading. A
`.jk` file is thus either generated or overwritten. This is sometimes
Expand Down Expand Up @@ -96,22 +96,22 @@ def parse_model(path: Text, force_compile: bool = False):
"""
if not path.endswith((".k", ".jk")):
path = path + ".jk"
logger.warning(f"assuming .jk file in {path}")
logger.warning(f"assuming `.jk` file in {path}")
name, _ = os.path.splitext(path)

path_jk = name + ".jk"
if not force_compile and os.path.isfile(path_jk):
logger.info(f"parsing .jk file in {path_jk}")
logger.info(f"parsing `.jk` file in {path_jk}")
return _parse_model(path_jk)

path_k = name + ".k"
logger.info(f"parsing .k file in {path_k}")
logger.info(f"parsing `.k` file in {path_k}")
if not os.path.isfile(path_k):
raise FileNotFoundError(f"no .k file found in {path_k}")
raise FileNotFoundError(f"no `.k` file found in {path_k}")

model = _parse_source(path_k)
with open(path_jk, "w") as f:
logger.info(f"writing .jk file in {path_jk}")
logger.info(f"writing `.jk` file in {path_jk}")
f.write(_unparse_model(model))

return model
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@


def test_cli_compiles_source_file(monkeypatch):
"""Ensure the command-line interface can compile a source file (.k)."""
"""Ensure the command-line interface can compile a source file (`.k`)."""
params = ["overreact", "--compile", "data/ethane/B97-3c/model.k"]
monkeypatch.setattr("sys.argv", params)
cli.main()


def test_cli_describes_source_file(monkeypatch):
"""Ensure the command-line interface can describe a source file (.k)."""
"""Ensure the command-line interface can describe a source file (`.k`)."""
params = ["overreact", "data/ethane/B97-3c/model.k"]
monkeypatch.setattr("sys.argv", params)
cli.main()


def test_cli_describes_model_file(monkeypatch):
"""Ensure the command-line interface can describe a model file (.jk)."""
"""Ensure the command-line interface can describe a model file (`.jk`)."""
params = ["overreact", "data/ethane/B97-3c/model.jk"]
monkeypatch.setattr("sys.argv", params)
cli.main()
Expand Down

0 comments on commit f0bc3b9

Please sign in to comment.