casagui package
Subpackages
Submodules
casagui.resources module
casagui.utils module
- casagui.utils.find_ws_address(ip='127.0.0.1')
Find free port on
ip
network and return a tuple withip
and port numberThis function uses the low level socket function to find a free port and return a tuple representing the address plus port number.
- Parameters
ip (str) – network to be probed for an available port
- Returns
network address (str) and port number (int)
- Return type
tuple of str and int
- casagui.utils.partition(pred, iterable)
Split
iterable
into two lists based onpred
predicate.
- casagui.utils.path_to_url(path)
Convert a single filesystem path to a URL.
If the string specified in the
path
parameter exists. It is turned into a fully qualified path and converted to a URL and returned. Ifpath
does not exist,path
is returned unchanged.- Parameters
path (str) – path to be checked and expanded
- Returns
path
converted to a URL ifpath
exists, otherwisepath
unchanged- Return type
str
- casagui.utils.static_dir(func)
- casagui.utils.static_vars(**kwargs)
Initialize static function variables to for use within a function.
This function is used as a decorator which allows for the initialization of static local variables for use within a function. It is used like:
@static_vars(counter=0) def foo():
foo.counter += 1 print “Counter is %d” % foo.counter
This is used from: https://stackoverflow.com/questions/279561/what-is-the-python-equivalent-of-static-variables-inside-a-function?rq=1
- Parameters
variables. (Initialized static local) –