tlc.core.project_context
¶
Project context objects that provide project-related information.
Module Contents¶
Classes¶
Class |
Description |
---|---|
Project context objects that provide project-related information. |
Functions¶
Function |
Description |
---|---|
Context manager that sets the project context to a disabled sentinel value. |
API¶
- tlc.core.project_context.disabled_project_context() collections.abc.Generator[tlc.core.project_context._DisabledContextType, None, None] ¶
Context manager that sets the project context to a disabled sentinel value.
Restores the previous context on exit.
- class tlc.core.project_context.ProjectContext¶
Project context objects that provide project-related information.
This class provides context about a project, including its root directory and name. This is used to determine where to store project-specific information like timestamps and indexes.
- project_root: tlc.core.url.Url = None¶
The root URL of the project.
This is typically the directory containing the project’s configuration and data.
- project_name: str = None¶
The name of the project.
This is used to identify the project in various contexts.
- static get_context() tlc.core.project_context.ProjectContext | None | tlc.core.project_context._DisabledContextType ¶
Get the project context for the current thread.
- Returns:
The project context, None if not set.
- static get_project_context_from_url(url: tlc.core.url.Url) tlc.core.project_context.ProjectContext | None ¶
Get the project context from a URL.
- Parameters:
url – The URL to analyze.
- Returns:
The deduced ProjectContext or None if not applicable.
- static get_project_context_from_default_alias_url(default_alias_url: tlc.core.url.Url) tlc.core.project_context.ProjectContext | None ¶
Get the project context from a default aliases URL.
Default aliases (SECONDARY) can be placed:
In the root of the 3lc directory structure. This is alongside PRIMARY config files
In a projects directory (root/project_a), which makes the config file associated with a project.
- Parameters:
default_alias_url – The URL of the default alias config.
- Returns:
The deduced ProjectContext or None if not applicable.
- static get_project_context_from_config_url(config_url: tlc.core.url.Url) tlc.core.project_context.ProjectContext | None ¶
Get the project context from a config file URL.
Config files (PRIMARY) are placed in the root of the 3lc directory structure. Therefore the timestamp URL is a sibling of the config URL. These files do not have a project name.
- Parameters:
config_url – The URL of the config file.
- Returns:
The deduced ProjectContext or None if not applicable.
- static get_project_context_from_object_url(object_url: tlc.core.url.Url) tlc.core.project_context.ProjectContext | None ¶
Get the project context from an object URL.
- Parameters:
object_url – The URL of the object.
- Returns:
The deduced ProjectContext or None if not applicable.
- static push_scope(ctx: tlc.core.project_context.ProjectContext | None | tlc.core.project_context._DisabledContextType) contextlib.AbstractContextManager[tlc.core.project_context.ProjectContext | None | tlc.core.project_context._DisabledContextType] ¶
Push a context onto the stack and return a context manager that will restore the previous context.
- Parameters:
ctx – The context to push.
- Returns:
A context manager that will restore the previous context when exited.