
    Xf3!              	          d Z ddlZddlmZmZ ddlmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZ  eddefdefg      ZeZ G d	 d
e      Z G d de      Z G d dej.                  e      Z G d de      Z G d de      Z ed      Zeee   ee   ee   ee   eej                     ee   ee   f   Z eeee f      Z!eeegef   Z" G d dee      Z#y)a#  All plugins output a TreeGrid object which must then be rendered (either by a
GUI, or as text output, html output or in some other form.

This module defines both the output format (:class:`TreeGrid`) and the
renderer interface which can interact with a TreeGrid to produce
suitable output.
    N)abstractmethodABCMeta)abc)AnyCallableClassVar	GeneratorList
NamedTupleOptionalTypeVarTypeTupleUnionColumnnametypec                   \    e Zd ZdZddeee      ddfdZedee   fd       Z	ed	d       Z
y)
RendererzLClass that defines the interface that all output renderers must
    support.Noptionsreturnc                      y)z5Accepts an options object to configure the renderers.N )selfr   s     \/home/panchajanya/Development/work/volatility3/volatility3/framework/interfaces/renderers.py__init__zRenderer.__init__&           c                      y)z$Returns a list of rendering options.Nr   r   s    r   get_render_optionszRenderer.get_render_options*   r   r   c                      y)zMTakes a grid object and renders it based on the object's
        preferences.Nr   )r   grids     r   renderzRenderer.render.   r   r   N)r#   TreeGridr   N)__name__
__module____qualname____doc__r   r
   RenderOptionr   r   r!   r$   r   r   r   r   r   "   s[    Dl); < D D 3D$6 3 3  r   r   )	metaclassc                   <    e Zd ZU dZeed<   edee   defd       Z	y)ColumnSortKeyT	ascendingvaluesr   c                      y)zOThe key function passed as a sort key to the TreeGrid's visit
        function.Nr   )r   r0   s     r   __call__zColumnSortKey.__call__7   r   r   N)
r'   r(   r)   r/   bool__annotations__r   r
   r   r2   r   r   r   r.   r.   4   s0    IttCy S  r   r.   c                       e Zd Zd Zeeded   fd              Zeedefd              Z	eede
d    fd              Zeedefd              Zedded	edd
fd       Zy
)TreeNodec                      y)zInitializes the TreeNode.Nr   )r   pathtreegridparentr0   s        r   r   zTreeNode.__init__>   r   r   r   	BaseTypesc                      y)zSReturns the list of values from the particular node, based on column
        index.Nr   r    s    r   r0   zTreeNode.valuesA   r   r   c                      y)zReturns a path identifying string.

        This should be seen as opaque by external classes, Parsing of
        path locations based on this string are not guaranteed to remain
        stable.
        Nr   r    s    r   r8   zTreeNode.pathG   r   r   c                      y)z-Returns the parent node of this node or None.Nr   r    s    r   r:   zTreeNode.parentQ   r   r   c                      y)z*Return the path depth of the current node.Nr   r    s    r   
path_depthzTreeNode.path_depthV   r   r   r8   addedNc                      y)zUpdates the path based on the addition or removal of a node higher
        up in the tree.

        This should only be called by the containing TreeGrid and
        expects to only be called for affected nodes.
        Nr   )r   r8   rA   s      r   path_changedzTreeNode.path_changed[   r   r   )F)r'   r(   r)   r   propertyr   r
   r0   strr8   r   r:   intr@   r3   rC   r   r   r   r6   r6   =   s    ( [)    c    <, <  < 9C 9  9  T d  r   r6   c                       e Zd ZdZy)BaseAbsentValuezCClass that represents values which are not present for some reason.N)r'   r(   r)   r*   r   r   r   rH   rH   e   s    Mr   rH   c            	       4    e Zd ZdZg dZ	 d	dedededdfdZy)
DisassemblyzbA class to indicate that the bytes provided should be disassembled
    (based on the architecture))intelintel64armarm64dataoffsetarchitecturer   Nc                     || _         d | _        || j                  v r|| _        t        |t              st        d      || _        y )NzOffset must be an integer type)rO   rQ   possible_architectures
isinstancerF   	TypeErrorrP   )r   rO   rP   rQ   s       r   r   zDisassembly.__init__o   sF     	 4666 ,D&#&<==r   )r   rL   )	r'   r(   r)   r*   rS   bytesrF   rE   r   r   r   r   rJ   rJ   i   s<    # B AJ		#&	:=			r   rJ   _Typec                      e Zd ZU dZeeeeej                  e	fZ
ee   ed<   dededdfdZeededefd	              Ze	 	 	 dd
edededee   fd       Zeedefd              Zeedee   fd              Zededee   fd       Z ededee!df   fd       Z"edededefd       Z#edefd       Z$ededefd       Z%e	 ddee   d
ede&de'ddf
d       Z(y)r&   a  Class providing the interface for a TreeGrid (which contains TreeNodes)

    The structure of a TreeGrid is designed to maintain the structure of the tree in a single object.
    For this reason each TreeNode does not hold its children, they are managed by the top level object.
    This leaves the Nodes as simple data carries and prevents them being used to manipulate the tree as a whole.
    This is a data structure, and is not expected to be modified much once created.

    Carrying the children under the parent makes recursion easier, but then every node is its own little tree
    and must have all the supporting tree functions.  It also allows for a node to be present in several different trees,
    and to create cycles.
    
base_typescolumns	generatorr   Nc                      y)a  Constructs a TreeGrid object using a specific set of columns.

        The TreeGrid itself is a root element, that can have children but no values.
        The TreeGrid does *not* contain any information about formatting,
        these are up to the renderers and plugins.

        Args:
            columns: A list of column tuples made up of (name, type).
            generator: An iterable containing row for a tree grid, each row contains a indent level followed by the values for each column in order.
        Nr   )r   rZ   r[   s      r   r   zTreeGrid.__init__   r   r   textc                      y)z3Method used to sanitize column names for TreeNodes.Nr   )r]   s    r   sanitize_namezTreeGrid.sanitize_name   r   r   functioninitial_accumulatorfail_on_errorsc                      y)zPopulates the tree by consuming the TreeGrid's construction
        generator Func is called on every node, so can be used to create output
        on demand.

        This is equivalent to a one-time visit.
        Nr   )r   r`   ra   rb   s       r   populatezTreeGrid.populate   r   r   c                      y)z_Indicates that population has completed and the tree may now be
        manipulated separately.Nr   r    s    r   	populatedzTreeGrid.populated   r   r   c                      y)z;Returns the available columns and their ordering and types.Nr   r    s    r   rZ   zTreeGrid.columns   r   r   nodec                      y)z3Returns the subnodes of a particular node in order.Nr   r   rh   s     r   childrenzTreeGrid.children   r   r   .c                      y)z\Returns the values for a particular node.

        The values returned are mutable,
        Nr   rj   s     r   r0   zTreeGrid.values   r   r   
descendantc                      y)z?Returns true if descendent is a child, grandchild, etc of node.Nr   )r   rh   rm   s      r   is_ancestorzTreeGrid.is_ancestor   r   r   c                      y)z&Returns the maximum depth of the tree.Nr   r    s    r   	max_depthzTreeGrid.max_depth   r   r   c                     | j                   S )z,Returns the path depth of a particular node.)r@   )rh   s    r   r@   zTreeGrid.path_depth   s     r   sort_keyc                      y)a  Visits all the nodes in a tree, calling function on each one.

        function should have the signature function(node, accumulator) and return new_accumulator
        If accumulators are not needed, the function must still accept a second parameter.

        The order of that the nodes are visited is always depth first, however, the order children are traversed can
        be set based on a sort_key function which should accept a node's values and return something that can be
        sorted to receive the desired order (similar to the sort/sorted key).

        If node is None, then the root node is used.

        Args:
            node: The initial node to be visited
            function: The visitor to apply to the nodes under the initial node
            initial_accumulator: An accumulator that allows data to be transferred between one visitor call to the next
            sort_key: Information about the sort order of columns in order to determine the ordering of results
        Nr   )r   rh   r`   ra   rs   s        r   visitzTreeGrid.visit   r   r   )NNTr%   ))r'   r(   r)   r*   rF   rE   floatrV   datetimerJ   rY   r   r   r4   ColumnsTyper	   r   staticmethodr   r_   VisitorSignaturer   r3   r   	Exceptionrd   rD   rf   r
   r   rZ   r6   rk   r;   r0   ro   rq   r@   rW   r.   ru   r   r   r   r&   r&      s    
 	#J 
 
	 
d 
 BC BC B  B  &*#'#	" ! 	
 
)	  #4 #  # Jf J  J BX B$x. B B 8 in(=   N Nh N4 N N 53 5 5  c    #'x  # #	
   
 r   r&   )$r*   rw   r   r   r   collectionstypingr   r   r   r	   r
   r   r   r   r   r   r   rE   r   r+   r   r.   Sequencer6   objectrH   rJ   rW   rF   rv   rV   r;   rx   rz   r&   r   r   r   <module>r      s    '     
H}vsm<	= $g %s||w %PNf N& * 	IIKK			 5i()Xu-u45 pv pr   