Skip to content

example_realtime_status

Usage

from gtfs_django.utils.realtime import example_realtime_status

Documentation

def example_realtime_status(
    url: str,
    timeout: float = 10.0,
    headers: dict[str, str] | None = None,
    include_alerts: bool = False,
) -> dict[str, str]:

Returns a placeholder status for a GTFS Realtime endpoint.

This function exists only to validate documentation generation.

Parameters:

Name Type Description Default
url str

The endpoint to check.

required
timeout float

Request timeout in seconds.

10.0
headers dict[str, str] | None

Optional request headers.

None
include_alerts bool

Whether to include service alerts.

False

Returns:

Type Description
dict[str, str]

dict[str, str]: A placeholder status payload.

Raises:

Type Description
NotImplementedError

Always raised because this is a documentation stub.

Important

This function is intentionally non-functional and should be replaced with a real implementation when needed.

Examples:

>>> example_realtime_status("https://example.com/gtfs-realtime")
{'status': 'not_implemented'}
>>> example_realtime_status(
...     "https://example.com/gtfs-realtime",
...     timeout=2.5,
...     headers={"Authorization": "Bearer demo"},
...     include_alerts=True,
... )
{'status': 'not_implemented'}
Source code in utils/realtime.py
def example_realtime_status(
    url: str,
    timeout: float = 10.0,
    headers: dict[str, str] | None = None,
    include_alerts: bool = False,
) -> dict[str, str]:
    """Returns a placeholder status for a GTFS Realtime endpoint.

    This function exists only to validate documentation generation.

    Args:
        url (str): The endpoint to check.
        timeout (float): Request timeout in seconds.
        headers (dict[str, str] | None): Optional request headers.
        include_alerts (bool): Whether to include service alerts.

    Returns:
        dict[str, str]: A placeholder status payload.

    Raises:
        NotImplementedError: Always raised because this is a documentation stub.

    warning: Important
        This function is intentionally non-functional and should be replaced
        with a real implementation when needed.

    Examples:
        >>> example_realtime_status("https://example.com/gtfs-realtime")
        {'status': 'not_implemented'}
        >>> example_realtime_status(
        ...     "https://example.com/gtfs-realtime",
        ...     timeout=2.5,
        ...     headers={"Authorization": "Bearer demo"},
        ...     include_alerts=True,
        ... )
        {'status': 'not_implemented'}
    """
    raise NotImplementedError("Example stub for documentation tests.")

Clase de ejemplo

Client for fetching GTFS Realtime status.

Attributes:

Name Type Description
base_url str

Base URL for the realtime endpoint.

timeout float

Request timeout in seconds.

headers dict[str, str] | None

Optional request headers.

Parameters:

Name Type Description Default
base_url str

Base URL for the realtime endpoint.

required
timeout float

Request timeout in seconds.

10.0
headers dict[str, str] | None

Optional request headers.

None
Source code in gtfs/classes.py
class RealtimeClient:
    """Client for fetching GTFS Realtime status.

    Attributes:
        base_url (str): Base URL for the realtime endpoint.
        timeout (float): Request timeout in seconds.
        headers (dict[str, str] | None): Optional request headers.

    Args:
        base_url (str): Base URL for the realtime endpoint.
        timeout (float, optional): Request timeout in seconds.
        headers (dict[str, str] | None, optional): Optional request headers.
    """

    def __init__(
        self,
        base_url: str,
        timeout: float = 10.0,
        headers: dict[str, str] | None = None,
    ) -> None:
        self.base_url = base_url
        self.timeout = timeout
        self.headers = headers

    def get_status(self, include_alerts: bool = False) -> dict[str, str]:
        """Return a placeholder status payload.

        Args:
            include_alerts (bool, optional): Whether to include service alerts.

        Returns:
            dict[str, str]: A placeholder status payload.

        Raises:
            NotImplementedError: Always raised because this is a stub.

        Examples:
            >>> client = RealtimeClient("https://example.com/gtfs-realtime")
            >>> client.get_status(include_alerts=True)
            {'status': 'not_implemented'}
        """
        raise NotImplementedError("Example stub for documentation tests.")

get_status(include_alerts=False)

Return a placeholder status payload.

Parameters:

Name Type Description Default
include_alerts bool

Whether to include service alerts.

False

Returns:

Type Description
dict[str, str]

dict[str, str]: A placeholder status payload.

Raises:

Type Description
NotImplementedError

Always raised because this is a stub.

Examples:

>>> client = RealtimeClient("https://example.com/gtfs-realtime")
>>> client.get_status(include_alerts=True)
{'status': 'not_implemented'}
Source code in gtfs/classes.py
def get_status(self, include_alerts: bool = False) -> dict[str, str]:
    """Return a placeholder status payload.

    Args:
        include_alerts (bool, optional): Whether to include service alerts.

    Returns:
        dict[str, str]: A placeholder status payload.

    Raises:
        NotImplementedError: Always raised because this is a stub.

    Examples:
        >>> client = RealtimeClient("https://example.com/gtfs-realtime")
        >>> client.get_status(include_alerts=True)
        {'status': 'not_implemented'}
    """
    raise NotImplementedError("Example stub for documentation tests.")