Logos and Images

BrandLogoResource

BrandLogoResource()

A logo resource, a file with optional alternative text

Attributes

Name Description
alt Alterative text for the image, used for accessibility.
path The path to the logo resource. This can be a local file or a URL.

BrandLightDark

BrandLightDark()

A Light/Dark Variant

Holds variants for light and dark settings. Generally speaking light settings have white or light backgrounds and dark foreground colors (black text on a white page) and dark settings use black or dark background with light foreground colors (white text on a black page).

Attributes

Name Description
dark Value in dark mode.
light Value in light mode.

FileLocation

FileLocation()

The base class for a file location, either a local or an online file.

Local files are handled by brand_yml.file.FileLocationLocal and are always considered relative to the source _brand.yml file.

Online files are handled by brand_yml.file.FileLocationUrl and are a URL starting with https:// or http://. Absolute paths for local or network files are supported via FileLocationUrl when using the file:// prefix.

FileLocationLocal

FileLocationLocal()

A local file location.

When used in a brand_yml.Brand instance, this class carries both the relative path to the file, relative to the source _brand.yml, and the absolute path of the file on disk.

Methods

Name Description
absolute Absolute path of the file location, relative to the root directory.
exists Check that the file exists at its absolute path.
relative Relative path of the file location.
set_root_dir Update the root directory of this file location.
validate_exists Validate that the file exists at its absolute path.

absolute

FileLocationLocal.absolute()

Absolute path of the file location, relative to the root directory.

Returns the absolute path to the file, relative to the root directory, which is most typically the directory containing the _brand.yml file.

exists

FileLocationLocal.exists()

Check that the file exists at its absolute path.

relative

FileLocationLocal.relative()

Relative path of the file location.

Returns the relative path to the file as it would appear in the source _brand.yml file.

set_root_dir

FileLocationLocal.set_root_dir(root_dir)

Update the root directory of this file location.

In general, the root directory is the parent directory containing the source brand_yml file. If you relocate the file, this method can be used to update the new local file location.

validate_exists

FileLocationLocal.validate_exists()

Validate that the file exists at its absolute path.

Raises

Name Type Description
FileNotFoundError Raises a FileNotFoundError if the file does not exist at its absolute path location.

FileLocationUrl

FileLocationUrl()

A hosted, online file location, i.e. a URL.

A URL to a single file, typically an online file path starting with http:// or https://. This class can also be used for the absolute path of local or networked files, which should start with file:// (otherwise local files are handled by brand_yml.file.FileLocationLocal).

file.FileLocationLocalOrUrlType

file.FileLocationLocalOrUrlType

A type representing a file location that may be a local path or URL.