loaderregistry
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
LoaderRegistry jinjarope.loaderregistry Registry which caches and builds jinja loaders. |
🛈 DocStrings¶
LoaderRegistry
¶
Registry which caches and builds jinja loaders.
Source code in src/jinjarope/loaderregistry.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
by_path
¶
by_path(path: str | PathLike[str]) -> FileSystemLoader | FsSpecFileSystemLoader
Convenience method to get a suiting loader for given path.
Return a FsSpec loader for protocol-like paths or else a FileSystem loader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | PathLike[str]
|
The path to get a loader for |
required |
Source code in src/jinjarope/loaderregistry.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
get_filesystem_loader
¶
get_filesystem_loader(path: str | PathLike[str]) -> FileSystemLoader
Return a FileSystem loader for given path from registry.
If the loader does not exist yet, create and cache it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | PathLike[str]
|
The path to get a loader for |
required |
Source code in src/jinjarope/loaderregistry.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
get_fsspec_loader
¶
get_fsspec_loader(path: str) -> FsSpecFileSystemLoader
Return a FsSpec loader for given path from registry.
If the loader does not exist yet, create and cache it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to get a loader for |
required |
Source code in src/jinjarope/loaderregistry.py
40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
get_loader
¶
get_loader(
*args: str | ModuleType,
dir_paths: list[str] | None = None,
module_paths: list[str] | None = None,
functions: list[Callable[..., Any]] | None = None,
static: dict[str, str] | None = None,
fsspec_paths: bool = True
) -> BaseLoader
Construct a Loader.
If given a positional argument, return a loader for given argument, otherwise return a ChoiceLoader based on given keyword arguments. Loader is constructed from cached sub-loaders if existing, otherwise they are created (and cached).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
str | ModuleType
|
What to get a loader for (can be path or module) |
()
|
dir_paths
|
list[str] | None
|
Directory paths (either FsSpec-protocol URLs to a folder or filesystem paths) |
None
|
module_paths
|
list[str] | None
|
(dotted) package paths |
None
|
functions
|
list[Callable[..., Any]] | None
|
A list of callables |
None
|
static
|
dict[str, str] | None
|
A dictionary containing a path-> template mapping |
None
|
fsspec_paths
|
bool
|
Whether a loader for FsSpec protcol paths should be added |
True
|
Source code in src/jinjarope/loaderregistry.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
get_package_loader
¶
get_package_loader(package: str) -> PackageLoader
Return a Package loader for given (dotted) package path from registry.
If the loader does not exist yet, create and cache it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package
|
str
|
The package to get a loader for |
required |
Source code in src/jinjarope/loaderregistry.py
72 73 74 75 76 77 78 79 80 81 82 83 84 |
|