misc (14)
add¶
add(text: str | None, prefix: str = '', suffix: str = '') -> str
Add a pre- or suffix to a value if the value is true-ish.
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str | None
|
The text to check |
required |
prefix
|
str
|
Prefix to add if text is true-ish |
''
|
suffix
|
str
|
Suffix to add if text is true-ish |
''
|
Source code in src/jinjarope/envglobals.py
68 69 70 71 72 73 74 75 76 |
|
attr¶
attr(environment: 'Environment', obj: Any, name: str) -> Union[jinja2.runtime.Undefined, Any]
Get an attribute of an object. foo|attr("bar")
works like
Example
Jinja call:
Result:<built-in method removesuffix of str object at 0x7f827f334a20>
Example
Jinja call:
Result:[<built-in method upper of str object at 0x7f82a03e3c40>, <built-in method upper of str object at 0x7f829f98ba20>]
DocStrings
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 |
|
check_output¶
check_output(call: 'str | Sequence[str]', cwd: 'str | os.PathLike[str] | None' = None, use_cache: 'bool' = False) -> 'str | None'
Execute a system call and return its output as a string.
Example
Jinja call:
Result:LICENSE docs mkdocs.yml ollama.pid pyproject.toml tests
README.md duties.py ollama.log overrides src uv.lock
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
call
|
str | Sequence[str]
|
The system call to make |
required |
cwd
|
str | PathLike[str] | None
|
The working directory for the call |
None
|
use_cache
|
bool
|
Whether to cache the output of calls |
False
|
Source code in src/jinjarope/envglobals.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 64 65 |
|
default¶
default(value: ~V, default_value: ~V = '', boolean: bool = False) -> ~V
If the value is undefined it will return the passed default value,
Aliases: d
DocStrings
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
|
get_hash¶
get_hash(obj: Any, hash_length: int | None = 7) -> str
Get a Md5 hash for given object.
DocStrings
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 |
|
getenv¶
getenv(key, default=None)
Get an environment variable, return None if it doesn't exist.
DocStrings
Source code in python3.12/os.py
808 809 810 811 812 |
|
hasattr¶
hasattr(obj, name, /)
Return whether the object has an attribute with the given name.
DocStrings
import_module¶
import_module(name, package=None)
Import a module.
Example
Jinja call:
Result:<module 'jinja2' from '/home/runner/work/jinjarope/jinjarope/.venv/lib/python3.12/site-packages/jinja2/__init__.py'>
DocStrings
Source code in importlib/__init__.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
load_file¶
load_file(path: 'str | os.PathLike[str]') -> 'str'
Return the text-content of file at given path.
Example
Jinja call:
Result: `## Emoji extension indexMkNodes provides a custom emoji index for the pymdownx.emoji extension in order to provide access to all > 180.000 icons provided by the Iconify framework.
Example: becomes:
Info
For compatibility, icons can also be accessed from the same name as the Material-MkDocs icon index, making
the MkNodes
index a superset of the MkDocs-Material
index.
Icon node¶
MkNodes also includes a node for Pyconify-Icons named [MkIcon][mknodes.MkIcon]. It can be used to include icons with custom color, rotation and size. `
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | PathLike[str]
|
The path to get str content from |
required |
Source code in src/jinjarope/envglobals.py
21 22 23 24 25 26 27 28 29 30 31 |
|
map¶
map(context: 'Context', value: Iterable[Any], *args: Any, **kwargs: Any) -> Iterable[Any]
Applies a filter on a sequence of objects or looks up an attribute.
Example
Jinja call:
Result:<generator object sync_do_map at 0x7f82800fcc40>
DocStrings
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 |
|
match¶
match(obj: Any, mapping: dict[str | type, str] | None = None, **kwargs: Any) -> str
A filter trying to imitate a python match-case statement.
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
Any
|
match object |
required |
mapping
|
dict[str | type, str] | None
|
a mapping for the different cases. If key is type, an isinstance will be performed. If key is a str, check for equality. |
None
|
kwargs
|
Any
|
Same functionality as mapping, but provided as keyword arguments for convenience. |
{}
|
Examples:
{{ "a" | match(a="hit", b="miss")
{{ MyClass() | match({MyClass: "hit", OtherClass: "miss"}) }}
Source code in src/jinjarope/envglobals.py
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 |
|
partial¶
partial(fn: 'Callable', *args: 'Any', **kwargs: 'Any')
Create new function with partial application of given arguments / keywords.
Example
Jinja call:
Result:functools.partial(<function join at 0x7f829f920b80>, 'abc')
DocStrings
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 |
|
random¶
random(context: 'Context', seq: 't.Sequence[V]') -> 't.Union[V, Undefined]'
Return a random item from the sequence.
DocStrings
Source code in .venv/lib/python3.12/site-packages/jinja2/filters.py
682 683 684 685 686 687 688 |
|
ternary¶
ternary(value: Any, true_val: Any, false_val: Any, none_val: Any = None)
Value ? true_val : false_val.
DocStrings
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
The value to check. |
required |
true_val
|
Any
|
The value to return if given value is true-ish |
required |
false_val
|
Any
|
The value to return if given value is false-ish |
required |
none_val
|
Any
|
Optional value to return if given value is None |
None
|
Source code in src/jinjarope/envglobals.py
79 80 81 82 83 84 85 86 87 88 89 90 |
|