utils
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| DataclassInstance jinjarope.utils |
🛈 DocStrings¶
entry_points
¶
Get entry points for a group using epregistry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str
|
Entry point group name |
required |
Returns:
| Type | Description |
|---|---|
Mapping[str, Callable[..., Any]]
|
Mapping of entry point names to loaded callables |
Source code in src/jinjarope/utils.py
fsspec_get
cached
¶
Fetch a file via fsspec and return file content as a string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
The path to fetch the file from |
required |
Source code in src/jinjarope/utils.py
get_dataclass_nondefault_values
¶
get_dataclass_nondefault_values(instance: DataclassInstance) -> dict[str, Any]
Return dictionary with non-default key-value pairs of given dataclass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
DataclassInstance
|
dataclass instance |
required |
Source code in src/jinjarope/utils.py
get_hash
¶
get_hash(obj: Any, hash_length: int | None = 7) -> str
Get a Md5 hash for given object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to get a hash for () |
required |
hash_length
|
int | None
|
Optional cut-off value to limit length |
7
|
Source code in src/jinjarope/utils.py
get_repr
¶
Get a suitable repr string for an object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_obj
|
Any
|
The object to get a repr for. |
required |
args
|
Any
|
Arguments for the repr |
()
|
kwargs
|
Any
|
Keyword arguments for the repr |
{}
|
Source code in src/jinjarope/utils.py
partial
¶
Create new function with partial application of given arguments / keywords.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[..., T]
|
The function to generate a partial from |
required |
args
|
Any
|
patially applied arguments |
()
|
kwargs
|
Any
|
partially applied keywords |
{}
|
Source code in src/jinjarope/utils.py
resolve
¶
resolve(name: str, module: str | None = None, *, py_type: type[T]) -> T
resolve(
name: str, module: str | None = None, py_type: type[T] | None = None
) -> T | Any
Resolve name to a Python object via imports / attribute lookups.
If module is None, name must be "absolute" (no leading dots).
If module is not None, and name is "relative" (has leading dots),
the object will be found by navigating relative to module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name to resolve |
required |
module
|
str | None
|
Optional base module for relative imports |
None
|
py_type
|
type[T] | None
|
Optional type to validate the resolved object against |
None
|
Returns:
| Type | Description |
|---|---|
T | Any
|
The resolved object |
Raises:
| Type | Description |
|---|---|
ValueError
|
If using a relative name without a base module |
TypeError
|
If py_type is provided and the resolved object doesn't match that type |