expliot.core.common¶
Common helpers for EXPLIoT.
Submodules¶
Functions¶
|
Convert bytes or a bytearray object to a string. |
|
Iterate through a list or a dict recursively. |
Package Contents¶
- expliot.core.common.bstr(byts)¶
Convert bytes or a bytearray object to a string.
Preserving the binary data as is.
- Args:
- byts(bytes or bytearray): A bytes/bytearray object that needs to be
converted to binary string.
- Returns:
str: The converted string that preserves the binary data as is.
- expliot.core.common.recurse_list_dict(obj, callback, cbdata, rlevel=0)¶
Iterate through a list or a dict recursively.
Calls the callback method at three places while iterating: 1. If the object is a dict, for each key, value pair
If the value is a dict or a list - callback()
If the value is not a dict or a list i.e. a leaf - callback()
- If the object is a list, for each value
If the value is not a dict or a list i.e. a leaf - callback()
- Args:
obj (list or dict): The list or dict object that has to be recursively iterated. callback (method): The callback method that has to be called. cbdata (opaque): This is passed to the callback and is opaque for this method rlevel (int): Recursion level of the method. Call MUST NOT pass any value to this
as it is initialized to zero by default.
- Returns:
Nothing
Callback method prototype: def mycallback(cbdata, robj, rlevel, key=None, value=None):
- Args:
cbdata (defined by callback): This callback method’s specific data. robj (list or dict): The list or dict object at the specified recursion level.
This object may be updated by the callback, which means the original obj passed to recurse_list_dict() will be eventually updated.
rlevel (int): The current recursion level at which this callback instance is called. key (str): The key if the robj is a dict. value (can be any type): 1. The value of the key if robj is a dict or
A value from the robj if it is a list
- Returns:
Nothing