aside.resources module

Manages the package resource files.

root: importlib_resources.abc.Traversable

The root traversable resource location.

See importlib_resources and importlib.resources for more information.

str_replace_swap(string: str, this: str, that: str)str[source]

Replace all this and that tokens in the string, swapping them.

find_resource(name: str, interpolated: bool, localized: bool)importlib_resources.abc.Traversable[source]

Find the resource location given the resource name.

See get_resource for more info.

load_resource(path: importlib_resources.abc.Traversable, do_interpolate: bool)str[source]

Load the resource contents given the traversable resource path.

See get_resource for more info.

get_resource(name: str, interpolated: bool = True, localized: bool = True)str[source]

Find and load the resource given its name.

This function also takes into account interpolatable and localized resource overrides.

  • Interpolatable resources are resource files which have an extra .int file extension. After loading an interpolatable resource, all strings of the form {{config.something}} and {{theme.other}} are interpolated with the values from the current aside.config.config and aside.theme.theme.

  • Localized resources are resources from the LOCALE-specific resource directory. The locale is determined by LC_MESSAGES. For example, the ru/icon.svg resource is the localized version of the icon.svg resource, corresponding to LC_MESSAGES="ru_RU.UTF-8".

Parameters
  • name – The name of the resource to load.

  • interpolated – Whether to search for interpolatable resources.

  • localized – Whether to search for localized resources.

Returns

The loaded resource contents.

get_svg(name: str)bytes[source]

Find and load an svg resource specified by name.

Parameters

name – The name of the svg resource without the file extension.

Returns

The contents of the resource, suitable to be loaded with loadFromData.