Part of lp.services
Functions, lists and so forth. Nothing here that does system calls or network stuff.
|Function||AutoDecorate||Factory to generate metaclasses that automatically apply decorators.|
|Function||base||Convert 'number' to an arbitrary base numbering scheme, 'radix'.|
|Function||compress_hash||Compress a hash_obj using
|Function||iter_split||Iterate over ways to split 'string' in two with 'splitter'.|
|Function||value_string||Return a unicode string representing value.|
|Function||text_delta||Return a textual delta for a Delta object.|
|Class||CachingIterator||Remember the items extracted from the iterator for the next iteration.|
|Function||decorate_with||Create a decorator that runs decorated functions with 'context'.|
|Function||docstring_dedent||Remove leading indentation from a doc string.|
|Class||CapturedOutput||A fixture that captures output to stdout and stderr.|
|Function||run_capturing_output||Run function capturing output to stdout and stderr.|
|Function||utc_now||Return a timezone-aware timestamp for the current time.|
|Function||obfuscate_email||Obfuscate an email address.|
|Function||save_bz2_pickle||Save a bz2 compressed pickle of
|Function||load_bz2_pickle||Load and return a bz2 compressed pickle from
|Function||obfuscate_structure||Obfuscate the strings of a json-serializable structure.|
|Function||sanitise_urls||Sanitise a string that may contain URLs for logging.|
AutoDecorate is a metaclass factory that can be used to make a class implicitly wrap all of its methods with one or more decorators.
This function is based on work from the Python Cookbook and is under the Python licence.
Inverse function to int(str, radix) and long(str, radix)
Given an md5 or sha1 hash object, compress it down to either 22 or 27 characters in a way that's safe to be used in URLs. Takes the hex of the hash and converts it to base 62.
If 'string' is empty, then yield nothing. Otherwise, yield tuples like ('a/b/c', ''), ('a/b', '/c'), ('a', '/b/c') for a string 'a/b/c' and a splitter '/'.
The tuples are yielded such that the first result has everything in the first tuple. With each iteration, the first element gets smaller and the second gets larger. It stops iterating just before it would have to yield ('', 'a/b/c').
Splits, if specified, is an iterable of splitters to split the string at.
iterablein chunks of size
I'm amazed this isn't in itertools (mwhudson).
This text is special cased for enumerated types.
A list of strings is returned.
Only modified members of the delta will be shown.
|Parameters||instance_delta||The delta to generate a textual representation of.|
|delta_names||The names of all members to show changes to.|
|state_names||The names of all members to show only the new state of.|
|interface||The Zope interface that the input delta compared.|
Since the first line doesn't have indentation, split it off, dedent, and then reassemble.
|Parameters||function||A function to run.|
|args||Arguments passed to the function.|
|kwargs||Keyword arguments passed to the function.|
|Returns||A tuple of (ret, stdout, stderr), where ret is the value returned by function, stdout is the captured standard output and stderr is the captured stderr.|
__traceback_info__in the caller's locals.
This is more aesthetically pleasing that assigning to __traceback_info__, but it more importantly avoids spurious lint warnings about unused local variables, and helps to avoid typos.
The email address is obfuscated as <email address hidden> by default, or with the given replacement.
The pattern used to identify an email address is not 2822. It strives to match any possible email address embedded in the text. For example, mailto:firstname.lastname@example.org and http://person:email@example.com both match, though the http match is in fact not an email address.
Note: tuples are converted to lists because json encoders do not distinguish between lists and tuples.
|Parameters||o||Any json-serializable object.|
|Returns||a possibly-new structure in which all strings, list and tuple elements, and dict keys and values have undergone obfuscate_email recursively.|