utils
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
DataclassInstance jinjarope.utils |
🛈 DocStrings¶
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
81 82 83 84 85 86 87 88 89 90 91 |
|
get_dataclass_nondefault_values
¶
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
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 |
|
get_hash
¶
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
134 135 136 137 138 139 140 141 142 143 144 |
|
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
66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
partial
¶
Create new function with partial application of given arguments / keywords.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable
|
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
26 27 28 29 30 31 32 33 34 |
|
resolve
cached
¶
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 |
Source code in src/jinjarope/utils.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|