Utils#

Utility functions.

saltfactories.utils.random_string(prefix, size=6, uppercase=True, lowercase=True, digits=True)[source]#

Generates a random string.

Parameters:
  • prefix (str) – The prefix for the random string

  • size (int) – The size of the random string

  • uppercase (bool) – If true, include upper-cased ascii chars in choice sample

  • lowercase (bool) – If true, include lower-cased ascii chars in choice sample

  • digits (bool) – If true, include digits in choice sample

Return str:

The random string

saltfactories.utils.running_username()[source]#

Return the username that is running the code.

saltfactories.utils.cast_to_pathlib_path(value)[source]#

Cast the passed value to an instance of pathlib.Path.

saltfactories.utils.warn_until(version, message, category=<class 'DeprecationWarning'>, stacklevel=None, _dont_call_warnings=False, _pkg_version_=None)[source]#

Show a deprecation warning.

Helper function to raise a warning, by default, a DeprecationWarning, until the provided version, after which, a RuntimeError will be raised to remind the developers to remove the warning because the target version has been reached.

Parameters:
  • version (str) – The version string after which the warning becomes a RuntimeError. For example 2.1.

  • message (str) – The warning message to be displayed.

  • category (Type[Warning]) – The warning class to be thrown, by default DeprecationWarning

  • stacklevel (int | None) – There should be no need to set the value of stacklevel.

  • _dont_call_warnings (bool) – This parameter is used just to get the functionality until the actual error is to be issued. When we’re only after the version checks to raise a RuntimeError.

  • _pkg_version_ (str | None) –

Return type:

None