nitpick.style.fetchers.base module

Base class for fetchers that wrap inner fetchers with caching ability.

class nitpick.style.fetchers.base.StyleFetcher(session: CachedSession | None = None, protocols: tuple[str, ...] = (), domains: tuple[str, ...] = ())[source]

Bases: object

Base class of all fetchers, it encapsulates get/fetch from a specific source.

domains: tuple[str, ...] = ()
fetch(url: furl) str[source]

Fetch a style from a specific fetcher.

normalize(url: furl) furl[source]

Normalize a URL.

Produces a canonical URL, meant to be used to uniquely identify a style resource.

  • The base name has .toml appended if not already ending in that extension

  • Individual fetchers can further normalize the path and scheme.

preprocess_relative_url(url: str) str[source]

Preprocess a relative URL.

Only called for urls that lack a scheme (at the very least), being resolved against a base URL that matches this specific fetcher.

protocols: tuple[str, ...] = ()
requires_connection: ClassVar[bool] = False
session: CachedSession | None = None