Commonly used utility functions.
Dictionary like context object passed to resource callables and view callables. Use of context objects has more implications than just passing around data values. Resource callables, typically identified by the request-URLs, are responsible for fetching the necessary data for before representing it to clients. And view callables are responsible to represent the data in desired format to clients.
Parse a single line of comma separated values, into a list of strings
Parse a multi-line text where each line contains comma separated values.
If obj is class object return the same. Other wise assume that it is an instance object and return its class.
Check whether cls is a subclass of one of the super-classes passed in supers. Gotcha : if supers has a built-in type this function will fail.
Convert a string representation of boolean value to boolean type.
Convert string representation of integer value to integer type.
Convert string representation of float value to floating type.
Equivalent to td.total_seconds() (introduced in python 2.7).
Use stdlib’s fcnt.fcnt() function to set FILE-DESCRIPTORS fds to be automatically closed when this program exits.
Use stdlib’s fcnt.fcnt() function to set FILE-DESCRIPTORS fds to non-blocking read / write.
If an entrypoint is callable, use this API to both identify the entry point, evaluate them by loading and calling it. Return the result from the called function. Note that the entrypoint must be uniquely identified using, distribution, group and name. args and kwargs will be passed on to the entypoint callable.
If os.urandom is available, this method does the same thing as random.seed ! (at least as of python 2.6). If os.urandom is not available, we mix in the pid in addition to a timestamp.
For a list of dictionaries in args return a new dictionary containing super-imposed key,value pairs from args
List ls is a list of tuple (attr, value), there can be more than one tuple with the same attr name. Make a dictionary where the key values are list.
Iterate over lst until pred is True and return only the iterated elements.
Iterate over lst until pred is True and return the remaining elements in lst.
Import a module, or import an object from a module.
A module name like foo.bar:baz() can be used, where foo.bar is the module, and baz() is an expression evaluated in the context of that module. Note this is not safe on arbitrary strings because of the eval.