taurus.core.util
¶
This package consists of a collection of useful classes and functions. Most of the elements are taurus independent and can be used generically.
This module contains a python implementation of json
. This was done because
json only became part of python since version 2.6.
The json implementation follows the rule:
if python >= 2.6 use standard json from python distribution
otherwise use private implementation distributed with taurus
Modules
Classes
Functions
-
CallableRef
(object, del_cb=None)[source]¶ This function returns a callable weak reference to a callable object. Object can be a callable object, a function or a method.
- Parameters
object (callable object) – a callable object
del_cb (callable object or None) – calback function. Default is None meaning to callback.
- Returns
a weak reference for the given callable
- Return type
-
deprecation_decorator
(func=None, alt=None, rel=None, dbg_msg=None)[source]¶ decorator to mark methods as deprecated
-
dictFromSequence
(seq)[source]¶ Translates a sequence into a dictionary by converting each to elements of the sequence (k,v) into a k:v pair in the dictionary
- Parameters
seq (
sequence
) – any sequence object- Return type
- Returns
dictionary built from the given sequence
-
getDictAsTree
(dct)[source]¶ This method will print a recursive dict in a tree-like shape:
>>> print(getDictAsTree({'A':{'B':[1,2],'C':[3]}}))
-
getSystemUserName
()[source]¶ Finds out user inf (currently just the logged user name) for Windows and Posix machines. sets a USER_NAME variable containing the logged user name defines a UNKNOWN_USER variable to which username falls back.
- Return type
- Returns
current user name
-
propertx
(fct)[source]¶ Decorator to simplify the use of property. Like @property for attrs who need more than a getter. For getter only property use @property.
adapted from http://code.activestate.com/recipes/502243/
-
self_locked
(func, reentrant=True)[source]¶ Decorator to make thread-safe class members Decorator to create thread-safe objects.
Warning
With Lock() this decorator should not be used to decorate nested functions; it will cause Deadlock!
With RLock this problem is avoided … but you should rely more on python threading