Skip to content

base_interface

Contains abstract base interface classes and helpers.

To import...

from dynamite_nsm.cmd import base_interface

BaseInterface

An abstract interface used primarily in instance checks

__init__(self, interface_name=None, interface_description=None, defaults=None) special

Setup the interface

Parameters:

Name Type Description Default
interface_name Optional[str]

A descriptive name of the interface

None
interface_description Optional[str]

A description of what the utility does

None
defaults Optional[Dict]

Any arguments and their value you wish to default (E.G stdout=True)

None
Source code in dynamite_nsm/cmd/base_interface.py
def __init__(self, interface_name: Optional[str] = None, interface_description: Optional[str] = None,
             defaults: Optional[Dict] = None):
    """
    Setup the interface
    Args:
        interface_name: A descriptive name of the interface
        interface_description: A description of what the utility does
        defaults: Any arguments and their value you wish to default (E.G stdout=True)
    """
    self.interface_name = interface_name
    self.interface_description = interface_description
    self.defaults = defaults
    if not self.defaults:
        self.defaults = dict()

execute(self, args)

Interpret the parsed arguments and execute using the proper service.action class; can return any value.

Parameters:

Name Type Description Default
args Namespace

argparse.Namespace created by a method such as argparse.ArgumentParser().parse_args()

required

Returns: Can return any value; completely depends on the service.action being invoked

Source code in dynamite_nsm/cmd/base_interface.py
def execute(self, args: argparse.Namespace) -> Any:
    """Interpret the parsed arguments and execute using the proper `service.action` class; can return any value.
    Args:
        args: `argparse.Namespace` created by a method such as `argparse.ArgumentParser().parse_args()`

    Returns: Can return any value; completely depends on the `service.action` being invoked

    """
    raise NotImplementedError()

get_parser(self)

Returns: an ArgumentParser instance

Source code in dynamite_nsm/cmd/base_interface.py
def get_parser(self) -> argparse.ArgumentParser:
    """
    Returns: an `ArgumentParser` instance
    """
    raise NotImplementedError()