pyinfra.api.util module¶
-
pyinfra.api.util.
format_exception
(e: Exception) str ¶
-
pyinfra.api.util.
get_call_location
(frame_offset: int = 1)¶
-
pyinfra.api.util.
get_caller_frameinfo
(frame_offset: int = 0)¶
-
class
pyinfra.api.util.
get_file_io
(filename_or_io, mode='rb')¶ Bases:
object
Given either a filename or an existing IO object, this context processor will open and close filenames, and leave IO objects alone.
-
property
cache_key
¶
-
filename_or_io
: str | IO[Any]¶
-
mode
: str¶
-
property
-
pyinfra.api.util.
get_file_sha1
(filename_or_io)¶ Calculates the SHA1 of a file or file object using a buffer to handle larger files.
-
pyinfra.api.util.
get_kwargs_str
(kwargs: Dict[Any, Any])¶
-
pyinfra.api.util.
get_path_permissions_mode
(pathname: str)¶ Get the permissions (bits) of a path as an integer.
-
pyinfra.api.util.
get_template
(filename_or_io: str | IO, jinja_env_kwargs: dict[str, Any] | None = None)¶ Gets a jinja2
Template
object for the input filename or string, with caching based on the filename of the template, or the SHA1 of the input string.
-
pyinfra.api.util.
log_error_or_warning
(host: Host, ignore_errors: bool, description: str = '', continue_on_error: bool = False) None ¶
-
pyinfra.api.util.
log_operation_start
(op_meta: StateOperationMeta, op_types: List | None = None, prefix: str = '--> ') None ¶
-
pyinfra.api.util.
make_hash
(obj)¶ Make a hash from an arbitrary nested dictionary, list, tuple or set, used to generate ID’s for operations based on their name & arguments.
-
pyinfra.api.util.
memoize
(func: Callable[[...], Any])¶
-
pyinfra.api.util.
raise_if_bad_type
(value: Any, type_: Type, exception: type[Exception], message_prefix: str)¶
-
pyinfra.api.util.
sha1_hash
(string: str) str ¶ Return the SHA1 of the input string.
-
pyinfra.api.util.
try_int
(value)¶