cowbird.handlers.handler_factory

Attributes

HandlerConfig

LOGGER

VALID_HANDLERS

Classes

SingletonMeta

A metaclass that creates a Singleton base class when called.

HandlerFactory

Create handler instance using handler name.

Functions

get_all_configs(…)

Loads all configuration files specified by the path (if a directory), a single configuration (if a file) or directly

get_config_path(→ str)

get_logger(→ logging.Logger)

Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when

get_settings(→ cowbird.typedefs.SettingsType)

Retrieve application settings from a supported container.

Module Contents

cowbird.handlers.handler_factory.get_all_configs(path_or_dict: str | cowbird.typedefs.ConfigDict, section: Literal['handlers'], allow_missing: bool = False) List[Dict[str, cowbird.typedefs.HandlerConfig]][source]
cowbird.handlers.handler_factory.get_all_configs(path_or_dict: str | cowbird.typedefs.ConfigDict, section: Literal['sync_permissions'], allow_missing: bool = False) List[cowbird.typedefs.SyncPointConfig]

Loads all configuration files specified by the path (if a directory), a single configuration (if a file) or directly returns the specified dictionary section (if a configuration dictionary).

Returns:

  • list of configurations loaded if input was a directory path

  • list of single configuration if input was a file path

  • list of single configuration if input was a JSON dict

  • empty list if none of the other cases where matched

Note

Order of file loading will be resolved by alphabetically sorted filename if specifying a directory path.

cowbird.handlers.handler_factory.HandlerConfig[source]
class cowbird.handlers.handler_factory.SingletonMeta[source]

Bases: type

A metaclass that creates a Singleton base class when called.

Create a class such that.

class A(object, metaclass=SingletonMeta):
    pass

class B(object, metaclass=SingletonMeta):
    pass

a1 = A()
a2 = A()
b1 = B()
b2 = B()
a1 is a2    # True
b1 is b2    # True
a1 is b1    # False
_instances: Dict[SingletonMetaType, SingletonMetaType]
__call__(*args: Any, **kwargs: Any) SingletonMetaType[source]

Call self as a function.

cowbird.handlers.handler_factory.get_config_path(container: cowbird.typedefs.AnySettingsContainer | None = None) str[source]
cowbird.handlers.handler_factory.get_logger(name: str, level: int | None = None, force_stdout: bool = None, message_format: str | None = None, datetime_format: str | None = None) logging.Logger[source]

Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is logging.NOTSET.

cowbird.handlers.handler_factory.get_settings(container: cowbird.typedefs.AnySettingsContainer | None, app: bool = False) cowbird.typedefs.SettingsType[source]

Retrieve application settings from a supported container.

Parameters:
  • container – supported container with a handle to application settings.

  • app – allow retrieving from current thread registry if no container was defined.

Returns:

found application settings dictionary.

Raises:

TypeError – when no application settings could be found or unsupported container.

cowbird.handlers.handler_factory.LOGGER[source]
cowbird.handlers.handler_factory.VALID_HANDLERS = ['Catalog', 'Geoserver', 'Magpie', 'Nginx', 'Thredds', 'FileSystem'][source]
class cowbird.handlers.handler_factory.HandlerFactory[source]

Create handler instance using handler name.

create_handler(name: Literal['Catalog']) cowbird.handlers.impl.catalog.Catalog[source]
create_handler(name: Literal['FileSystem']) cowbird.handlers.impl.filesystem.FileSystem
create_handler(name: Literal['Geoserver']) cowbird.handlers.impl.geoserver.Geoserver
create_handler(name: Literal['Magpie']) cowbird.handlers.impl.magpie.Magpie
create_handler(name: Literal['Nginx']) cowbird.handlers.impl.nginx.Nginx
create_handler(name: Literal['Thredds']) cowbird.handlers.impl.thredds.Thredds
create_handler(name: str) cowbird.handlers.handler.Handler | None

Instantiates a new Handler implementation using its name, overwriting an existing instance if required.

get_handler(name: Literal['Catalog']) cowbird.handlers.impl.catalog.Catalog[source]
get_handler(name: Literal['FileSystem']) cowbird.handlers.impl.filesystem.FileSystem
get_handler(name: Literal['Geoserver']) cowbird.handlers.impl.geoserver.Geoserver
get_handler(name: Literal['Magpie']) cowbird.handlers.impl.magpie.Magpie
get_handler(name: Literal['Nginx']) cowbird.handlers.impl.nginx.Nginx
get_handler(name: Literal['Thredds']) cowbird.handlers.impl.thredds.Thredds
get_handler(name: str) cowbird.handlers.handler.Handler | None

Instantiates a Handler implementation using its name if it doesn’t exist or else returns the existing one from cache.

get_active_handlers() List[cowbird.handlers.handler.Handler][source]

Return a sorted list by priority of Handler implementation activated in the config.