Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
To install, simply ``python3 -m pip install .`` in the repository root.
"""

from setuptools import setup
# © 2024 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
# U.S. Government retains certain rights in this software.

setup(
name="staged-script",
version="1.0.0",
description=(
"A base class to inherit from when building scripts that are "
"subdivided into a series of stages."
),
packages=["staged_script"],
scripts=[],
python_requires=">=3.10",
tests_require=["pytest==7.1.1"],
install_requires=["rich==12.5.1"],
)
# SPDX-License-Identifier: BSD-3-Clause

import setuptools

if __name__ == "__main__":
setuptools.setup()
7 changes: 7 additions & 0 deletions staged_script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
and functions.
"""

# © 2024 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
# U.S. Government retains certain rights in this software.

# SPDX-License-Identifier: BSD-3-Clause

from .staged_script import (
StagedScript,
HelpFormatter,
Expand All @@ -20,3 +26,4 @@
"StageDuration",
"lazy_property",
]
__version__ = "1.0.0"
25 changes: 16 additions & 9 deletions staged_script/staged_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
your own staged scripts, along with some helpers.
"""

# © 2024 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
# U.S. Government retains certain rights in this software.

# SPDX-License-Identifier: BSD-3-Clause

import functools
import re
import shlex
Expand Down Expand Up @@ -699,7 +705,7 @@ def _end_stage_test(self) -> None:
stage_duration = datetime.now(tz=timezone.utc) - self.stage_start_time
self.durations.append(
StageDuration(self.current_stage, stage_duration)
) # yapf: disable
)
self.console.log(
f"`{self.current_stage}` stage duration: {stage_duration!s}"
)
Expand Down Expand Up @@ -862,9 +868,11 @@ def pretty_print_command(self, command: str, indent: int = 4) -> str:
args = shlex.split(command)
lines = [args.pop(0)]
while args:
if (not self._current_arg_is_long_flag(args)
or self._next_arg_is_flag(args)
or len(args) == 1): # yapf: disable
if (
not self._current_arg_is_long_flag(args)
or self._next_arg_is_flag(args)
or len(args) == 1
):
lines.append(args.pop(0))
else:
lines.append(
Expand All @@ -887,9 +895,9 @@ def print_dry_run_message(self, message: str, *, indent: int = 0) -> None:
self.console.log(
Padding(
Panel(f"DRY-RUN MODE: {message}", style="yellow"),
(0, 0, 0, indent)
(0, 0, 0, indent),
)
) # yapf: disable
)

def print_heading(self, message: str, *, color: str = "cyan") -> None:
"""
Expand All @@ -904,9 +912,8 @@ def print_heading(self, message: str, *, color: str = "cyan") -> None:
self.console.log(Panel(f"[bold]{message}", style=color))

def print_script_execution_summary(
self,
extra_sections: dict[str, str] | None = None
) -> None: # yapf: disable
self, extra_sections: dict[str, str] | None = None
) -> None:
"""
Print a summary of everything that was done by the script.

Expand Down
13 changes: 13 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Create the ``test`` package.

This ``__init__.py`` file creates the ``test`` package, such that tests
can relative-import from modules in the sibling ``staged_script``
directory.
"""

# © 2024 National Technology & Engineering Solutions of Sandia, LLC
# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
# U.S. Government retains certain rights in this software.

# SPDX-License-Identifier: BSD-3-Clause
Loading