How to use the pypyr.errors.Error function in pypyr

To help you get started, we’ve selected a few pypyr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypyr / pypyr-cli / pypyr / errors.py View on Github external
return super(Exception, self).__str__()


class LoopMaxExhaustedError(Error):
    """Max attempts reached during looping."""


class PipelineDefinitionError(Error):
    """Pipeline definition incorrect. Likely a yaml error."""


class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
    """Could not load python module because it wasn't found."""


# -------------------------- Control of Flow Instructions ---------------------
class Stop(Error):
    """Control of flow. Stop all execution."""


class StopPipeline(Stop):
    """Control of flow. Stop current pipeline execution."""
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
error_type = type(error)
    if error_type.__module__ in ['__main__', 'builtins']:
        return error_type.__name__
    else:
        return f'{error_type.__module__}.{error_type.__name__}'


class Error(Exception):
    """Base class for all pypyr exceptions."""


class ContextError(Error):
    """Error in the pypyr context."""


class HandledError(Error):
    """Error that has already been saved to errors context collection"""


class KeyInContextHasNoValueError(ContextError):
    """pypyr context[key] doesn't have a value."""


class KeyNotInContextError(ContextError, KeyError):
    """Key not found in the pypyr context."""

    def __str__(self):
        """KeyError has custom error formatting, avoid this behaviour."""
        return super(Exception, self).__str__()


class LoopMaxExhaustedError(Error):
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
"""Key not found in the pypyr context."""

    def __str__(self):
        """KeyError has custom error formatting, avoid this behaviour."""
        return super(Exception, self).__str__()


class LoopMaxExhaustedError(Error):
    """Max attempts reached during looping."""


class PipelineDefinitionError(Error):
    """Pipeline definition incorrect. Likely a yaml error."""


class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
    """Could not load python module because it wasn't found."""


# -------------------------- Control of Flow Instructions ---------------------
class Stop(Error):
    """Control of flow. Stop all execution."""
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
Returns:
        str. Canonical error name.

    """
    error_type = type(error)
    if error_type.__module__ in ['__main__', 'builtins']:
        return error_type.__name__
    else:
        return f'{error_type.__module__}.{error_type.__name__}'


class Error(Exception):
    """Base class for all pypyr exceptions."""


class ContextError(Error):
    """Error in the pypyr context."""


class HandledError(Error):
    """Error that has already been saved to errors context collection"""


class KeyInContextHasNoValueError(ContextError):
    """pypyr context[key] doesn't have a value."""


class KeyNotInContextError(ContextError, KeyError):
    """Key not found in the pypyr context."""

    def __str__(self):
        """KeyError has custom error formatting, avoid this behaviour."""
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
"""Error that has already been saved to errors context collection"""


class KeyInContextHasNoValueError(ContextError):
    """pypyr context[key] doesn't have a value."""


class KeyNotInContextError(ContextError, KeyError):
    """Key not found in the pypyr context."""

    def __str__(self):
        """KeyError has custom error formatting, avoid this behaviour."""
        return super(Exception, self).__str__()


class LoopMaxExhaustedError(Error):
    """Max attempts reached during looping."""


class PipelineDefinitionError(Error):
    """Pipeline definition incorrect. Likely a yaml error."""


class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
    """Could not load python module because it wasn't found."""


# -------------------------- Control of Flow Instructions ---------------------
class Stop(Error):
    """Control of flow. Stop all execution."""


class StopPipeline(Stop):
    """Control of flow. Stop current pipeline execution."""


class StopStepGroup(Stop):
    """Control of flow. Stop current step - group execution."""


class ControlOfFlowInstruction(Error):
    """Control of flow instructions should inherit from this.

    Attributes:
        groups: list of str. List of step - groups to execute.
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
# -------------------------- Control of Flow Instructions ---------------------
class Stop(Error):
    """Control of flow. Stop all execution."""


class StopPipeline(Stop):
    """Control of flow. Stop current pipeline execution."""


class StopStepGroup(Stop):
    """Control of flow. Stop current step - group execution."""


class ControlOfFlowInstruction(Error):
    """Control of flow instructions should inherit from this.

    Attributes:
        groups: list of str. List of step - groups to execute.
        success_group: str. Step - group to execute on success condition.
        failure_group: str. Step - group to execute on failure condition.
    """

    def __init__(self, groups, success_group, failure_group):
        """Initialize the control of flow instruction.

        Args:
            groups: list of str. List of step - groups to execute.
            success_group: str. Step - group to execute on success condition.
            failure_group: str. Step - group to execute on failure condition.
        """
github pypyr / pypyr-cli / pypyr / utils / filesystem.py View on Github external
# derive the destination directory, ensure it's ready for writing
            basedir_out = None
            is_outfile_name_known = False
            if out_path:
                # outpath could be a file, or a dir
                pathlib_out = Path(out_path)
                # yep, Path() strips trailing /, hence check original string
                if isinstance(out_path, str) and out_path.endswith(os.sep):
                    # ensure dir - mimic posix mkdir -p
                    pathlib_out.mkdir(parents=True, exist_ok=True)
                    basedir_out = pathlib_out
                elif pathlib_out.is_dir():
                    basedir_out = pathlib_out
                else:
                    if len(in_paths) > 1:
                        raise Error(
                            f'{in_path} resolves to {len(in_paths)} files, '
                            'but you specified only a single file as out '
                            f'{out_path}. If the outpath is meant to be a '
                            'directory, put a / at the end.')

                    # at this point it must be a file (not dir) path
                    # make sure that the parent dir exists
                    basedir_out = pathlib_out.parent
                    basedir_out.parent.mkdir(parents=True, exist_ok=True)
                    is_outfile_name_known = True

            # loop through all the in files and write them to the out dir
            file_counter = 0
            is_edit = False
            for path in in_paths:
                actual_in = Path(path)
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
"""Max attempts reached during looping."""


class PipelineDefinitionError(Error):
    """Pipeline definition incorrect. Likely a yaml error."""


class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
    """Could not load python module because it wasn't found."""


# -------------------------- Control of Flow Instructions ---------------------
class Stop(Error):
    """Control of flow. Stop all execution."""


class StopPipeline(Stop):
    """Control of flow. Stop current pipeline execution."""


class StopStepGroup(Stop):
    """Control of flow. Stop current step - group execution."""
github pypyr / pypyr-cli / pypyr / errors.py View on Github external
"""pypyr context[key] doesn't have a value."""


class KeyNotInContextError(ContextError, KeyError):
    """Key not found in the pypyr context."""

    def __str__(self):
        """KeyError has custom error formatting, avoid this behaviour."""
        return super(Exception, self).__str__()


class LoopMaxExhaustedError(Error):
    """Max attempts reached during looping."""


class PipelineDefinitionError(Error):
    """Pipeline definition incorrect. Likely a yaml error."""


class PipelineNotFoundError(Error):
    """Pipeline not found in working dir or in pypyr install dir."""


class PlugInError(Error):
    """Pypyr plug - ins should sub - class this."""


class PyModuleNotFoundError(Error, ModuleNotFoundError):
    """Could not load python module because it wasn't found."""


# -------------------------- Control of Flow Instructions ---------------------