cterasdk.common.object module#
- class cterasdk.common.object.Object(**kwargs)#
Bases:
MutableMapping
- class cterasdk.common.object.ObjectEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
Bases:
JSONEncoder- default(o)#
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
- cterasdk.common.object.delete_attr(obj, path)#
Delete attribute
- Parameters:
object (cterasdk.common.object.Object) – The object
path (str) – Attribute path
- Returns:
The modified object
- Return type:
- cterasdk.common.object.delete_attrs(obj, paths)#
Delete attributes
- Parameters:
object (cterasdk.common.object.Object) – The object
paths (list[str]) – List of attributes to remove
- Returns:
The modified object
- Return type:
- cterasdk.common.object.find_attr(obj, path)#
Find attribute
- Parameters:
object (cterasdk.common.object.Object) – The object
path (str) – A string or an array of the attribute path
- Returns:
The attribute, or
Noneif not found
- cterasdk.common.object.get_attr(obj, attr)#
Get attribute
- Parameters:
object (cterasdk.common.object.Object) – The object
attr (str) – The name of the attribute to retrieve
- Returns:
The attribute, or
Noneif not found
- cterasdk.common.object.remove_array_element(array, attr)#
- cterasdk.common.object.remove_array_element_by_key(array, key, value)#
- cterasdk.common.object.remove_attr(obj, attr)#
Remove attribute
- Parameters:
object (cterasdk.common.object.Object) – The object
attr (str) – The name of the attribute to remove