strataconf.utils
ResourcePath
A resource path is a path to a resource in the filesystem or a package.
type ResourcePath = str | Pathfind_resource
Finds the path to a resource that exists in one of the given directories. If the resource is an absolute file path or a package resource path, it is returned as is.
def find_resource(path: ResourcePath, dirs: list[str] | list[Path]) -> ResourcePathpathResourcePath-
The resource path to find.
dirslist[str] | list[Path]-
List of directories to search.
Returns
Path to the found resource; otherwise raises a FileNotFoundError.
Raises
FileNotFoundError: If the resource is not found in any of the given directories.
import_symbol
Import a symbol from a given import path (e.g., a fully-qualified class name).
def import_symbol(import_path: str) -> Anyimport_pathstr-
The import path to import the symbol from.
Returns
The imported symbol.
to_type
Convert a value to a target type, handling collections with complex types.
Value can be a mapping of properties used to construct a class, a collection of mappings (e.g., a list, dict, set, or tuple), an already constructed class, or a primitive value.
The target type can be a class, a collection type, or a primitive type.
def to_type(value: Any, target_type: TypeExpression) -> AnyvalueAny-
The value to convert
target_typeTypeExpression-
The type to convert the value to
Returns
The value converted to the target type.