# schema_salad.fetcher

Resource fetching.

## Classes

`Fetcher` | Fetch resources from URIs.
`MemoryCachingFetcher` | Fetcher that caches resources in memory after retrieval.
`DefaultFetcher` | The default Fetcher implementation.

## Module Contents

class schema_salad.fetcher.Fetcher

  Bases: `abc.ABC`

  Fetch resources from URIs.

  abstractmethod fetch_text(url, content_types=None)

    Retrieve the given resource as a string.

    Parameters:

      - url (str)

      - content_types (list[str] | None)

    Return type:

      str

  abstractmethod check_exists(url)

    Check if the given resource exists.

    Parameters:

      url (str)

    Return type:

      bool

  abstractmethod urljoin(base_url, url)

    Construct a full (“absolute”) URL by combining a “base URL” with another URL.

    Parameters:

      - base_url (str)

      - url (str)

    Return type:

      str

  schemes = ['file', 'http', 'https', 'mailto']
  supported_schemes()

    Return the list of supported URI schemes.

    Return type:

      list[str]

class schema_salad.fetcher.MemoryCachingFetcher(cache)

  Bases: `Fetcher`

  Fetcher that caches resources in memory after retrieval.

  Parameters:

    cache (schema_salad.utils.CacheType)

  cache

class schema_salad.fetcher.DefaultFetcher(cache, session)

  Bases: `MemoryCachingFetcher`

  The default Fetcher implementation.

  Parameters:

    - cache (schema_salad.utils.CacheType)

    - session (requests.sessions.Session | None)

  session: Final
  fetch_text(url, content_types=None)

    Retrieve the given resource as a string.

    Parameters:

      - url (str)

      - content_types (list[str] | None)

    Return type:

      str

  check_exists(url)

    Check if the given resource exists.

    Parameters:

      url (str)

    Return type:

      bool

  urljoin(base_url, url)

    Construct a full (“absolute”) URL by combining a “base URL” with another URL.

    Parameters:

      - base_url (str)

      - url (str)

    Return type:

      str