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
84 85 86 87 88 89 90 91 92 93 94 |
|
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
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 |
|
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
131 132 133 134 135 136 137 138 139 140 141 |
|
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
69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
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
29 30 31 32 33 34 35 36 37 |
|
resolve
cached
¶
resolve(name: str, module: str | None = None) -> ModuleType | Callable[..., 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
.
Returns the object, if found. If not, propagates the error.
Source code in src/jinjarope/utils.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|