Skip to content

vendor

vendor #

copy_library — the browser libraries the standard components ship, copied into a page.

  1. Each library lives under capturegraph/ui/_vendor/<library>/ as package data beside its LICENSE, its version recorded in _vendor/VERSIONS.
  2. A render copies a whole library folder into the page's lib/ the first time a component asks for one of its files, so the page stays self-contained.

copy_library(library, destination) #

Copy every file of library under destination, unchanged files left alone.

copy_library("leaflet", page / "lib" / "leaflet")

Raises:

Type Description
FileNotFoundError

If no such library ships with the package.

Source code in capturegraph-lib/capturegraph/ui/vendor.py
def copy_library(library: str, destination: Path) -> None:
    """Copy every file of ``library`` under ``destination``, unchanged files left alone.

    ```python
    copy_library("leaflet", page / "lib" / "leaflet")
    ```

    Raises:
        FileNotFoundError: If no such library ships with the package.
    """
    _copy_tree(vendored(library), destination)

vendored(library) #

The shipped folder of library ("leaflet", "vega", …).

Raises:

Type Description
FileNotFoundError

If no such library ships with the package.

Source code in capturegraph-lib/capturegraph/ui/vendor.py
def vendored(library: str) -> Traversable:
    """The shipped folder of ``library`` (``"leaflet"``, ``"vega"``, …).

    Raises:
        FileNotFoundError: If no such library ships with the package.
    """
    folder = files("capturegraph.ui").joinpath("_vendor", library)
    if not folder.is_dir():
        raise FileNotFoundError(f"capturegraph.ui ships no library named {library!r}")
    return folder