errbot.utils module

exception errbot.utils.ValidationException[source]

Bases: Exception

errbot.utils.collect_roots(base_paths, file_sig='*.plug')[source]

Collects all the paths from base_paths recursively that contains files of type file_sig.

Parameters:
  • base_paths -- a list of base paths to walk from elements can be a string or a list/tuple of strings
  • file_sig (str) -- the file pattern to look for
Returns:

a set of paths

errbot.utils.compat_str(s)[source]

Detect if s is a string and convert it to unicode if it is bytes. :param s: the string to ensure compatibility from.

class errbot.utils.deprecated(new=None)[source]

Bases: object

deprecated decorator. emits a warning on a call on an old method and call the new method anyway

__init__(new=None)[source]
errbot.utils.drawbar(value, max_)[source]
errbot.utils.ensure_sys_path_contains(paths)[source]

Ensure that os.path contains paths :param base_paths:

a list of base paths to walk from elements can be a string or a list/tuple of strings
errbot.utils.find_roots(path, file_sig='*.plug')[source]

Collects all the paths from path recursively that contains files of type file_sig.

Parameters:
  • path -- a base path to walk from
  • file_sig (str) -- the file pattern to look for
Returns:

a set of paths

errbot.utils.format_timedelta(timedelta)[source]
errbot.utils.get_class_for_method(meth)[source]
errbot.utils.get_class_that_defined_method(meth)[source]
errbot.utils.rate_limited(min_interval)[source]

decorator to rate limit a function.

Parameters:min_interval -- minimum interval allowed between 2 consecutive calls.
Returns:the decorated function
errbot.utils.recurse_check_structure(sample, to_check)[source]
errbot.utils.repeatfunc(func, times=None, *args)[source]

Repeat calls to func with specified arguments.

Example: repeatfunc(random.random)

Parameters:
  • args -- params to the function to call.
  • times -- number of times to repeat.
  • func -- the function to repeatedly call.
errbot.utils.split_string_after(str_, n)[source]

Yield chunks of length n from the given string

Parameters:
  • n -- length of the chunks.
  • str -- the given string.
errbot.utils.tail(f, window=20)[source]
errbot.utils.unescape_xml(text)[source]

Removes HTML or XML character references and entities from a text string. @param text The HTML (or XML) source text. @return The plain text, as a Unicode string, if necessary.

errbot.utils.utf8(key)[source]
errbot.utils.version2array(version)[source]
errbot.utils.which(program)[source]