leaguemanager.dependency.loader

Module Contents

Classes

DynamicObjectLoader

Data

settings

API

leaguemanager.dependency.loader.settings

‘get_settings(…)’

class leaguemanager.dependency.loader.DynamicObjectLoader
app_dir: pathlib.Path

‘field(…)’

root_dir: pathlib.Path

‘field(…)’

service_dir: pathlib.Path

‘field(…)’

db_config_dir: pathlib.Path

‘field(…)’

local_only: bool

‘field(…)’

classmethod local_app(app_dir: pathlib.Path | None = None, root_dir: pathlib.Path | None = None, service_dir: pathlib.Path | None = None, db_config_dir: pathlib.Path | None = None, local_only: bool = False)

Creates a DynamicObjectLoader for a user’s application

Args: app_dir (Path | None, optional): The path to user’s application. Defaults to None. root_dir (Path | None, optional): The path to the root of the user’s application. Defaults to None. service_dir (Path | None, optional): The path to the user’s services directory. Defaults to None. db_config_dir (Path | None, optional): The path to the user’s database configuration directory. Defaults to None.

Returns: DynamicObjectLoader: A configured DynamicObjectLoader with defaults for user’s application

_is_sync_service(item: Any)

Checks if item is SQLAlchemySyncRepositoryService class or subclass.

_is_async_service(item: Any)

Checks if item is SQLAlchemyAsyncRepositoryService class or subclass.

_is_sync_config(item: Any)

Checks if item is a SQLAlchemySyncConfig.

Using isclass(item) doesn’t work here. May revisit at a later time.

_is_async_config(item: Any)

Checks if item is a SQLAlchemyAsyncConfig.

Using isclass(item) doesn’t work here. May revisit at a later time.

_is_importer(item: Any)

Checks if item is a Protocol of the Importer class.

_is_schedule(item: Any)

Checks if item is a ScheduleServiceBase class or subclass.

get_aa_services(is_async: bool = False, **kwargs) list[advanced_alchemy.service.SQLAlchemySyncRepositoryService | advanced_alchemy.service.SQLAlchemyAsyncRepositoryService]

Returns all SQLAlchemySyncRepositoryService or SQLAlchemyAsyncRepositoryService classes dynamically.

Args: is_async (bool, optional): If True, returns all SQLAlchemyAsyncRepositoryService classes. Defaults to False.

get_configs(is_async: bool = False) list[advanced_alchemy.config.SQLAlchemySyncConfig | advanced_alchemy.config.SQLAlchemyAsyncConfig]

Gets all SQLAlchemySyncConfig or SQLAlchemyAsyncConfig classes dynamically.

If try_local_first is True, the search will start on the host application, and if a config item is found, it will load instead of league manager’s default.

Args: is_async (bool, optional): If True, returns all SQLAlchemyAsyncConfig classes. Defaults to False.

get_importer_services(search_dir: pathlib.Path) list[leaguemanager.services.template_loader.league_importer.Importer]

Returns all Importer classes dynamically.

This will return all classes that implement the Importer protocol.

get_schedule_services(search_dir: pathlib.Path) list[leaguemanager.services.scheduling.base.ScheduleServiceBase]

Returns all ScheduleServiceBase classes dynamically.

This is used to load scheduling services that are defined in the user’s application.

For now, only implemented to look at internally defined modules.

load_objects(search_dir: pathlib.Path, compare: callable, local_only: bool = False) Iterable[types.ModuleType]

Looks through a list of objects and returns them based on a comparison function.

If local_only is True, then it will only search the local directory for modules. Use this to override League Manager’s default search location.

Args: search_dir (Path): Directory name to search recursively compare (bool): Boolean comparison of all py files in search_dir directory local_only (bool): If True, only search the local directory for modules. Defaults to False.

Returns: list: All modules that match the compare function.

collect_matching_objects(modules: Iterable[str | pathlib.Path], compare: callable, is_dotted_path: bool = True) Iterable[types.ModuleType]

Looks for all classes that match the compare function in a list of dotted paths.

It expects a list of dotted paths to modules. It attempts to import each item, ignoring circular imports and modules that don’t exist. If a module has an __all__ attribute, it will only run the compare function on items in that attribute, and will only return unique items found.

Args: modules (list[str]): List of dotted paths to modules compare (callable | bool): Boolean comparison of all py files in search_dir directory. If set to True, then all items in the module will be returned. is_dotted_path (bool, optional): Expects modules to be a list of dotted relative paths to modules (e.g. “app.app”). If False, expects a list of full paths (e.g. /home/user/app/app.py). Defaults to True.

Returns: list: All modules that match the compare function.

dotted_paths(search_path: pathlib.Path) Generator[str, None, None]

Creates dotted paths to all .py files in search_path directory.

Will exclude any files in directories in the _exclude list.

Args: search_path (Path): Directory name to search recursively

Returns: Generator[str]: Generator of dotted paths to all .py files in search_path directory

full_paths(search_path: pathlib.Path) Generator[pathlib.Path, None, None]

Creates full paths to all .py files in search_path directory.

Will exclude any files in directories in the _exclude list.

Args: search_path (Path): Directory name to search recursively

Returns: Generator[Path]: Generator of full paths to all .py files in search_path directory

import_module_from_full_path(module_name: str, full_path: str) Any