Skip to content

API documentation

Custom package exceptions.

ServiceFileNotFound

Bases: FileNotFoundError

When a service file can't be found.

Source code in pgserviceparser/exceptions.py
class ServiceFileNotFound(FileNotFoundError):
    """When a service file can't be found."""

    def __init__(
        self,
        pg_service_filepath: Path,
    ):
        """Initialization.

        Args:
            pg_service_filepath: path to the examined pg service file
        """
        self.message = f"Service '{pg_service_filepath}' has not been found."

        super().__init__(self.message)

__init__(pg_service_filepath)

Initialization.

Parameters:

Name Type Description Default
pg_service_filepath Path

path to the examined pg service file

required
Source code in pgserviceparser/exceptions.py
def __init__(
    self,
    pg_service_filepath: Path,
):
    """Initialization.

    Args:
        pg_service_filepath: path to the examined pg service file
    """
    self.message = f"Service '{pg_service_filepath}' has not been found."

    super().__init__(self.message)

ServiceNotFound

Bases: KeyError

When a service name is not found in service file sections.

Source code in pgserviceparser/exceptions.py
class ServiceNotFound(KeyError):
    """When a service name is not found in service file sections."""

    def __init__(
        self,
        service_name: str,
        existing_service_names: list[str],
        pg_service_filepath: Path,
    ):
        """Initialization.

        Args:
            service_name: unfound service name
            existing_service_names: avaibale service names
            pg_service_filepath: path to the examined pg service file
        """
        self.message = (
            f"Service '{service_name}' has not been found in PG service file "
            f"({pg_service_filepath}). Available names: {', '.join(existing_service_names)}"
        )

        super().__init__(self.message)

__init__(service_name, existing_service_names, pg_service_filepath)

Initialization.

Parameters:

Name Type Description Default
service_name str

unfound service name

required
existing_service_names list[str]

avaibale service names

required
pg_service_filepath Path

path to the examined pg service file

required
Source code in pgserviceparser/exceptions.py
def __init__(
    self,
    service_name: str,
    existing_service_names: list[str],
    pg_service_filepath: Path,
):
    """Initialization.

    Args:
        service_name: unfound service name
        existing_service_names: avaibale service names
        pg_service_filepath: path to the examined pg service file
    """
    self.message = (
        f"Service '{service_name}' has not been found in PG service file "
        f"({pg_service_filepath}). Available names: {', '.join(existing_service_names)}"
    )

    super().__init__(self.message)