betty.app.extension package

Submodules

Module contents

Provide Betty’s extension API.

class betty.app.extension.ConfigurableExtension(*args, configuration=None, **kwargs)[source]

Bases: Extension, Generic[ConfigurationT], Configurable[ConfigurationT]

Parameters:
*args

configuration=None

**kwargs

classmethod default_configuration()[source]
Return type:

typing.TypeVar(ConfigurationT, bound= betty.config.Configuration)

exception betty.app.extension.CyclicDependencyError(extension_types)[source]

Bases: ExtensionError, RuntimeError

Parameters:
extension_types

class betty.app.extension.Dependencies(dependent_type)[source]

Bases: AllRequirements

Parameters:
dependent_type

classmethod for_dependent(dependent_type)[source]
Parameters:
dependent_type

Return type:

typing.Self

summary()[source]
Return type:

betty.locale.Str

class betty.app.extension.Dependents(dependency, dependents)[source]

Bases: Requirement

Parameters:
dependency

dependents

classmethod for_dependency(dependency)[source]
Parameters:
dependency

Return type:

typing.Self

is_met()[source]
Return type:

bool

summary()[source]
Return type:

betty.locale.Str

class betty.app.extension.Extension(app, *args, **kwargs)[source]

Bases: object

Integrate optional functionality with the Betty app.

Parameters:
app

*args

**kwargs

property app : App
classmethod assets_directory_path()[source]

Return the path on disk where the extension’s assets are located.

This may be anywhere in your Python package.

Return type:

pathlib.Path | None

classmethod comes_after()[source]
Return type:

set[type[betty.app.extension.Extension]]

classmethod comes_before()[source]
Return type:

set[type[betty.app.extension.Extension]]

classmethod depends_on()[source]
Return type:

set[type[betty.app.extension.Extension]]

disable_requirement()[source]

Define the requirement for this extension to be disabled.

This defaults to the extension’s dependents.

Return type:

betty.app.extension.requirement.Requirement

classmethod enable_requirement()[source]

Define the requirement for this extension to be enabled.

This defaults to the extension’s dependencies.

Return type:

betty.app.extension.requirement.Requirement

classmethod name()[source]
Return type:

str

class betty.app.extension.ExtensionDispatcher(extensions)[source]

Bases: Dispatcher

Parameters:
extensions

dispatch(target_type)[source]
Parameters:
target_type

Return type:

typing.Callable[..., typing.Awaitable[typing.Sequence[typing.Any]]]

exception betty.app.extension.ExtensionError[source]

Bases: BaseException

exception betty.app.extension.ExtensionTypeError[source]

Bases: ExtensionError, ValueError

exception betty.app.extension.ExtensionTypeImportError(extension_type_name)[source]

Bases: ExtensionTypeError, ImportError

Raised when an alleged extension type cannot be imported.

Parameters:
extension_type_name

exception betty.app.extension.ExtensionTypeInvalidError(extension_type)[source]

Bases: ExtensionTypeError, ImportError

Raised for types that are not valid extension types.

Parameters:
extension_type

class betty.app.extension.Extensions[source]

Bases: object

flatten()[source]
Return type:

typing.Iterator[betty.app.extension.Extension]

class betty.app.extension.ListExtensions(extensions)[source]

Bases: Extensions

Parameters:
extensions

flatten()[source]
Return type:

typing.Iterator[betty.app.extension.Extension]

class betty.app.extension.Theme(app, *args, **kwargs)[source]

Bases: UserFacingExtension

Parameters:
app

*args

**kwargs

class betty.app.extension.UserFacingExtension(app, *args, **kwargs)[source]

Bases: Extension

Parameters:
app

*args

**kwargs

classmethod description()[source]
Return type:

betty.locale.Str

classmethod label()[source]
Return type:

betty.locale.Str

betty.app.extension.build_extension_type_graph(extension_types)[source]

Build a dependency graph of the given extension types.

Parameters:
extension_types

Return type:

dict[type[betty.app.extension.Extension], set[type[betty.app.extension.Extension]]]

betty.app.extension.discover_extension_types()[source]

Gather the available extension types.

Return type:

set[type[betty.app.extension.Extension]]

betty.app.extension.format_extension_type(extension_type)[source]

Format an extension type to a human-readable label.

Parameters:
extension_type

Return type:

betty.locale.Str

betty.app.extension.get_extension_type(extension_type_definition)[source]

Get the extension type for an extension, extension type, or extension type name.

Parameters:
extension_type_definition

Return type:

type[betty.app.extension.Extension]

betty.app.extension.get_extension_type_by_extension(extension)[source]

Get the extension type for an extension.

Parameters:
extension

Return type:

type[betty.app.extension.Extension]

betty.app.extension.get_extension_type_by_name(extension_type_name)[source]

Get the extension type for an extension type name.

Parameters:
extension_type_name

Return type:

type[betty.app.extension.Extension]

betty.app.extension.get_extension_type_by_type(extension_type)[source]

Get the extension type for an extension type.

Parameters:
extension_type

Return type:

type[betty.app.extension.Extension]