deep.processor.variable_processor
A set of functions to collect and process variable data.
There are many things to consider when collecting that data from a variable. Here we try to manage the collection as best we can without affecting the original data source. As a result we have different ways to collect the data and many options to consider when collecting.
ITER_LIKE_TYPES = ['list_iterator', 'listiterator', 'list_reverseiterator', 'listreverseiterator']
module-attribute
A list of types that we should handle like iterators.
LIST_LIKE_TYPES = ['frozenset', 'set', 'list', 'tuple']
module-attribute
A list of types that we should handle like lists.
NO_CHILD_TYPES = ['str', 'int', 'float', 'bool', 'type', 'module', 'unicode', 'long', 'NoneType', 'traceback']
module-attribute
A list of types that do not have child nodes, or only have child nodes we do not want to process.
Collector
Bases: ABC
A type that is used to manage variable collection.
Source code in deep/processor/variable_processor.py
max_collection_size: int
abstractmethod
property
Get the max size of a collection.
:return int: the configured value
max_string_length: int
abstractmethod
property
Get the max length of a string.
:return int: the configured value
max_var_depth: int
abstractmethod
property
Get the max depth to process.
:return int: the configured value
append_child(variable_id, child)
abstractmethod
Append a chile to existing variable.
This is called when a child variable has been processed and the result should be attached to a variable that has already been processed.
:param str variable_id: the internal variable id of the parent variable :param VariableId child: the internal variable id value to attach to the parent
Source code in deep/processor/variable_processor.py
append_variable(var_id, variable)
abstractmethod
Append a variable to the var lookup.
This is called when a variable has been processed
:param var_id: the internal id of the variable :param variable: the internal value of the variable
Source code in deep/processor/variable_processor.py
check_id(identity_hash_id)
abstractmethod
Check if the identity_hash_id is known to us, and return the lookup id.
:param identity_hash_id: the id of the object :return: the lookup id used
Source code in deep/processor/variable_processor.py
new_var_id(identity_hash_id)
abstractmethod
Create a new cache id for the lookup.
:param identity_hash_id: the id of the object :return: the new lookup id
VariableResponse
The response from processing a variable.
Source code in deep/processor/variable_processor.py
process_children
property
Continue with the child nodes.
variable_id
property
The variable id data for the processed variable.
__init__(variable_id, process_children=True)
correct_names(name, val)
If a value is 'private' then python will rename the value to be prefixed with the class name.
:param name: the name of the class :param val: the variable name we are modifying :return: the new name to use
Source code in deep/processor/variable_processor.py
find_children_for_parent(var_collector, parent_node, value, variable_type)
Scan the parent for children based on the type.
:param var_collector: the collector we are using :param parent_node: the parent node :param value: the variable value we are processing :param variable_type: the type of the variable :return: list of child nodes
Source code in deep/processor/variable_processor.py
process_child_nodes(var_collector, variable_id, var_value, frame_depth)
Collect the child nodes for this variable.
Child node collection is performed via a variety of functions based on the type of the variable we are processing.
:param var_collector: the collector we are using :param variable_id: the variable if to attach children to :param var_value: the value we are looking at for children :param frame_depth: the current depth we are at :return:
Source code in deep/processor/variable_processor.py
process_dict_breadth_first(parent_node, type_name, value, func=lambda x, y: y)
Process a dict value.
Take a dict and collect all the child nodes for the dict.
:param (ParentNode) parent_node: the node that represents the list, to be used as the parent for the returned nodes :param (str) type_name: the name of the type we are processing :param (any) value: the list value to process :param (Callable) func: an optional function to preprocess values
:param func: :return (list): the collected child nodes
Source code in deep/processor/variable_processor.py
process_list_breadth_first(var_collector, parent_node, value)
Process a list value.
Take a list and collect all the child nodes for the list. Returned list is limited by the config 'max_collection_size'.
:param (Collector) var_collector: the collector that is managing this collection :param (ParentNode) parent_node: the node that represents the list, to be used as the parent for the returned nodes :param (any) value: the list value to process :return (list): the collected child nodes
Source code in deep/processor/variable_processor.py
process_variable(var_collector, node)
Process the variable into a serializable type.
:param var_collector: the collector being used :param node: the variable node to process :return: a response to determine if we continue
Source code in deep/processor/variable_processor.py
truncate_string(string, max_length)
Truncate the incoming string to the specified length.
:param string: the string to truncate :param max_length: the length to truncated to :return: a tuple of the new string, and if it was truncated
Source code in deep/processor/variable_processor.py
var_modifiers(var_name)
Process access modifiers.
Python does not have true access modifiers. The convention is to use leading underscores, one for protected, two for private.
https://www.geeksforgeeks.org/access-modifiers-in-python-public-private-and-protected/
:param var_name: the name to check :return: a list of the modifiers, or an empty list
Source code in deep/processor/variable_processor.py
variable_to_string(variable_type, var_value)
Convert the variable to a string.
:param variable_type: the variable type :param var_value: the variable value :return: a string of the value