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
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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
10
11
12
13
14
15
16
17
18
19
20
21
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)