formats ¤
Output-printing formats.
Format ¤
Class to define a display format.
Parameters:
-
template
(str
) –The main template.
-
progress_template
(str | None
, default:None
) –The template to show progress.
-
accept_ansi
(bool
, default:True
) –Whether to accept ANSI sequences.
Source code in src/failprint/formats.py
49 50 51 52 53 54 55 56 57 58 59 |
|
accept_custom_format ¤
Store the value in formats
if it starts with custom.
Parameters:
-
string
(str
) –A format name.
Returns:
-
str
–The format name, or
custom
if it started withcustom=
.
Source code in src/failprint/formats.py
84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
as_python_statement ¤
as_python_statement(
func: Callable | LazyCallable,
args: Sequence | None = None,
kwargs: dict | None = None,
) -> str
Transform a callable and its arguments into a Python statement string.
Parameters:
-
func
(Callable | LazyCallable
) –The callable to transform.
-
args
(Sequence | None
, default:None
) –Positional arguments passed to the function.
-
kwargs
(dict | None
, default:None
) –Keyword arguments passed to the function.
Returns:
-
str
–A Python statement.
Source code in src/failprint/formats.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
as_shell_command ¤
Rebuild a command line from system arguments.
Parameters:
Returns:
-
str
–A printable and shell-runnable command.
Source code in src/failprint/formats.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
escape ¤
Escape text for ansiprint by replacing <
and >
with special strings.
Parameters:
-
text
(str
) –The text to escape.
Returns:
-
str
–The escaped text.
Source code in src/failprint/formats.py
22 23 24 25 26 27 28 29 30 31 |
|
printable_command ¤
printable_command(
cmd: CmdFuncType,
args: Sequence | None = None,
kwargs: dict | None = None,
) -> str
Transform a command or function into a string.
Parameters:
-
cmd
(CmdFuncType
) –The command or function to transform.
-
args
(Sequence | None
, default:None
) –Positional arguments passed to the function.
-
kwargs
(dict | None
, default:None
) –Keyword arguments passed to the function.
Returns:
-
str
–A shell command or python statement string.
Source code in src/failprint/formats.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
unescape ¤
Unescape text by replacing special strings with <
and >
.
Parameters:
-
text
(str
) –The text to unescape.
Returns:
-
str
–The unescaped text.
Source code in src/failprint/formats.py
34 35 36 37 38 39 40 41 42 43 |
|