SEPPrinting¶
Color Printing¶
- SEPPrinting.print_colors =True¶
Deprecated since version 2.1.1.
Global color printing control is now disabled.
- SEPModules.SEPPrinting.color_string(s, style=AnsiControl((0, 'm')), *, boolean=False)¶
Add color ANSI escape sequences to a string. Longer name version of
cl_s().See also
Function
cl_s()for documentation.
- SEPModules.SEPPrinting.cl_s(s, style=AnsiControl((0, 'm')), *, boolean=False)¶
Add color ANSI escape sequences to a string. Shorter name version of
color_string().- Parameters
s (Any) – object to convert to string (any type, but must implement
__bool__ifbooleanargument is set toTrue)style (SEPModules.SEPPrinting.AnsiControl) – a
AnsiControlinstanceboolean (bool) – keyword only parameter, when set to
Trueautomatically formats the input as green or red string based on its boolean value
- Returns
ANSI escape sequences of defined style(s) concatenated with
str(s), where s may be of any type
Changed in version 2.1.1: Removed support for global
print_colorsattribute.
ANSI Control Sequences¶
- class SEPModules.SEPPrinting.AnsiControl(*style)¶
AnsiControlrepresents ANSI control sequences and which actions can be performed on them. New AnsiControl objects may be instantiated usingintANSI CSI codes which will be combined asCSI int; or sequences ofint, andstr, which will be combined asCSI int0;int1;...;int_n str0. Furthermore, style can be combined into composite style by the bitwise&and|and the+operator. Strings (or bytes) can also be combined with styles, in which case strings (or bytes) concatenated with the entire control sequence will be returned.- Parameters
style (Union[int, Sequence[Union[int, str]]]) – an arbitrary amount of ANSI style codes
Printing Utilities¶
- SEPModules.SEPPrinting.time_str(secs, n_digits=3, force_unit=None)¶
Helper function to format durations of times.
- Parameters
secs (SupportsFloat) – seconds as number
n_digits (int) – the number of digits for floating point values in the output string
force_unit (Optional[Literal[ns, µs, ms, s, m, h]]) – can be str of value
ns,µs,ms,s,m, orhto force a specific unit to display
- Returns
formatted string with adequately chosen units
- Raises
ValueError – if secs is negative
ValueError – if type of force_unit is not one of the specified literals
See also
- SEPModules.SEPPrinting.get_appropriate_time_unit(secs)¶
Turns a second value into a string of the appropriate unit.
See also
The literals returned by this function are compatible with
time_str().- Parameters
secs (SupportsFloat) – seconds as integer or float
- Returns
the unit-string determining the most appropriate unit for this seconds count
- Return type
Literal[ns, µs, ms, s, m, h]
- SEPModules.SEPPrinting.repr_str(obj, *properties, value_function=repr, include_none=False, include_empty_str=False, joiner=', ', **kwargs)¶
Provides a
__repr__string for any class using one instance of it.- Parameters
obj (Any) – the object to create this repr string from
properties (property[_T]) – the values which should be displayed in this repr string
value_function (Callable[[_T], str]) – which function to apply to each element of
valuesinclude_none (bool) – whether or not to include
Nonevaluesinclude_empty_sized (bool) – whether or not to include empty
Sizedobjectsinclude_empty_str (bool) – deprecated, whether or not to include empty strings
joiner (AnyStr) – which string to use to join the values together (see
str.join())kwargs (Any) – an arbitrary amount of keyword arguments to include in the final output string (of course excluding those keyword arguments, which are used in this function!)
- Returns
a repr string for
cls- Raises
NameError – if the given properties are not found in the class of
objTypeError – if a type error is raised during retrieval of the value of the properties
- Return type
str
- SEPModules.SEPPrinting.error_str(original, error_from, error_to, error_msg=None, *, error_style=AnsiControl((31, 'm')), enable_color=True)¶