Skip to content

Commit

Permalink
Merge pull request #162 from sandialabs/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
ci: pre-commit auto-update
  • Loading branch information
jmgate authored Jan 14, 2025
2 parents 2048756 + 105318d commit 4ece3b6
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ ci:
repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.1
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.1
rev: v8.23.0
hooks:
- id: gitleaks

Expand Down
3 changes: 1 addition & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

project = "shell-logger"
copyright = ( # noqa: A001
"2024, National Technology & Engineering Solutions of Sandia, LLC "
"(NTESS)"
"2024, National Technology & Engineering Solutions of Sandia, LLC (NTESS)"
)
author = "Josh Braun, David Collins, Jason M. Gates"
version = "2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ shell-logger
shell
abstract_method
stats_collector
trace
trace_collector
html_utilities

|Code lines|
Expand Down
4 changes: 2 additions & 2 deletions doc/source/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ nan
NaN
encodable
unproxied
STrace
LTrace
STraceCollector
LTraceCollector
16 changes: 0 additions & 16 deletions doc/source/trace.rst

This file was deleted.

16 changes: 16 additions & 0 deletions doc/source/trace_collector.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
TraceCollector
==============

.. autoclass:: shell_logger.trace_collector.TraceCollector

.. automethod:: shell_logger.trace_collector::trace_collector

STraceCollector
---------------

.. autoclass:: shell_logger.trace_collector.STraceCollector

LTraceCollector
---------------

.. autoclass:: shell_logger.trace_collector.LTraceCollector
4 changes: 2 additions & 2 deletions shell_logger/shell_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from .shell import Shell
from .stats_collector import stats_collectors
from .trace import trace_collector
from .trace_collector import trace_collector


class ShellLogger:
Expand Down Expand Up @@ -606,7 +606,7 @@ def _run(self, command: str, **kwargs) -> SimpleNamespace:
Parameters:
command: The command to execute.
**kwargs: Additional arguments to be passed on to the
:class:`StatsCollector` s, :class:`Trace` s,
:class:`StatsCollector` s, :class:`TraceCollector` s,
:func:`shell.run`, etc.
Returns:
Expand Down
41 changes: 22 additions & 19 deletions shell_logger/trace.py → shell_logger/trace_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@
from .abstract_method import AbstractMethod


def trace_collector(**kwargs) -> Trace:
def trace_collector(**kwargs) -> TraceCollector:
"""
Generate trace collectors.
A factory method that returns any subclass of :class:`Trace` that
has the ``@Trace.subclass`` decorator applied to it.
A factory method that returns any subclass of
:class:`TraceCollector` that has the ``@TraceCollector.subclass``
decorator applied to it.
Parameters:
**kwargs: Any supported arguments of the :class:`Trace`
subclass.
**kwargs: Any supported arguments of the
:class:`TraceCollector` subclass.
Returns:
A single instance of a :class:`Trace` subclass.
A single instance of a :class:`TraceCollector` subclass.
"""
trace_name = kwargs["trace"]
collectors = [c for c in Trace.subclasses if c.trace_name == trace_name]
collectors = [
c for c in TraceCollector.subclasses if c.trace_name == trace_name
]
if len(collectors) == 1:
collector = collectors[0]
return collector(**kwargs)
Expand All @@ -40,7 +43,7 @@ def trace_collector(**kwargs) -> Trace:
raise RuntimeError(message)


class Trace:
class TraceCollector:
"""
Trace a command run in the underlying shell.
Expand All @@ -57,16 +60,16 @@ def subclass(trace_subclass: type):
Mark a class as being a supported trace collector.
This is a class decorator that adds to a list of supported
:class:`Trace` classes for the :func:`trace_collector` factory
method.
:class:`TraceCollector` classes for the :func:`trace_collector`
factory method.
"""
if issubclass(trace_subclass, Trace):
Trace.subclasses.append(trace_subclass)
if issubclass(trace_subclass, TraceCollector):
TraceCollector.subclasses.append(trace_subclass)
return trace_subclass

def __init__(self, **kwargs):
"""
Initialize the :class:`Trace` object.
Initialize the :class:`TraceCollector` object.
Set up the output file where the trace information will be
written.
Expand Down Expand Up @@ -104,8 +107,8 @@ def command(self, command: str):
return f"{self.trace_args} -- {command}"


@Trace.subclass
class STrace(Trace):
@TraceCollector.subclass
class STraceCollector(TraceCollector):
"""
Run ``strace`` on commands.
Expand All @@ -116,7 +119,7 @@ class STrace(Trace):
trace_name = "strace"

def __init__(self, **kwargs) -> None:
"""Initialize the :class:`STrace` instance."""
"""Initialize the :class:`STraceCollector` instance."""
super().__init__(**kwargs)
self.summary = bool(kwargs.get("summary"))
self.expression = kwargs.get("expression")
Expand All @@ -132,8 +135,8 @@ def trace_args(self) -> str:
return args


@Trace.subclass
class LTrace(Trace):
@TraceCollector.subclass
class LTraceCollector(TraceCollector):
"""
Run ``ltrace`` on commands.
Expand All @@ -144,7 +147,7 @@ class LTrace(Trace):
trace_name = "ltrace"

def __init__(self, **kwargs):
"""Initialize the :class:`LTrace` instance."""
"""Initialize the :class:`LTraceCollector` instance."""
super().__init__(**kwargs)
self.summary = bool(kwargs.get("summary"))
self.expression = kwargs.get("expression")
Expand Down

0 comments on commit 4ece3b6

Please sign in to comment.