Source code for pystac.link

from __future__ import annotations

import os
from copy import copy
from html import escape
from typing import TYPE_CHECKING, Any, TypeVar

import pystac
from pystac.html.jinja_env import get_jinja_env
from pystac.utils import (
    HREF as HREF,
)
from pystac.utils import (
    is_absolute_href,
    make_absolute_href,
    make_posix_style,
    make_relative_href,
)

if TYPE_CHECKING:
    from pystac.catalog import Catalog
    from pystac.collection import Collection
    from pystac.extensions.ext import LinkExt
    from pystac.item import Item
    from pystac.stac_object import STACObject

    PathLike = os.PathLike[str]

else:
    PathLike = os.PathLike

L = TypeVar("L", bound="Link")

#: Hierarchical links provide structure to STAC catalogs.
HIERARCHICAL_LINKS = [
    pystac.RelType.ROOT,
    pystac.RelType.CHILD,
    pystac.RelType.PARENT,
    pystac.RelType.COLLECTION,
    pystac.RelType.ITEM,
    pystac.RelType.ITEMS,
]