
    *1f                         d dl Z d dlmZmZmZ d dlmZmZ d dlZ e j                  e
      Z G d d      Z G d d      Zy)    N)AnyListOptional)	constants
interfacesc                   r    e Zd Zdee   fdZdej                  j                  dee   fdZ	dee
   defdZy)		CLIFilterfiltersc                 2    | j                  ||      | _        y N)_prepare_filters)selftreegridr
   s      M/home/panchajanya/Development/work/volatility3/volatility3/cli/text_filter.py__init__zCLIFilter.__init__
   s    h8    r   c           	      x   g }|D ]  }d}d}d}d}|j                  d      rd}|dd }n|j                  d      r|dd }|j                  d      }	t        |	      dk  r|	d	   }n|	d	   }dj                  |	dd       }|r|j	                  d
      rd}|dd }d}
|rKt        |j                        D ]3  \  }}|j                         |j                  j                         v s1|}
 n |s|j                  t        |
|||              t        j                  t        j                  dt        |      z          |S )zHRuns through the filter strings and creates the necessary filter objectsFN-T   +,   r   !z	Filters:
)
startswithsplitlenjoinendswith	enumeratecolumnslowernameappendColumnFiltervolloglogr   LOGLEVEL_VVVrepr)r   r   r
   outputfilterexcluderegexpatterncolumn_name
components
column_numnumcolumns                r   r   zCLIFilter._prepare   sO    	QFGEGK  %""3'c*J:"$Q-(m((:ab>27++C0!#2,J#,X-=-=#> KC"((*fkk.?.?.AA%(
 l:wwOP5	Q8 	

9))<$v,+FGr   rowreturnc                     | j                   syt        | j                   D cg c]  }|j                  |       c}      }| S c c}w )z3Filters the row based on each of the column_filtersF)r   anyfound)r   r5   column_filterr9   s       r   r,   zCLIFilter.filter1   s@    
 }}4==Q-]((-QRy Rs   AN)__name__
__module____qualname__r   strr   r   	renderersTreeGridr   r   boolr,    r   r   r	   r	   	   sQ    9$s) 9"!5!5!>!> "c "H#Y 
r   r	   c                   b    e Zd Z	 	 ddee   dedededdf
dZdefdZd	e	e
   defd
ZdefdZy)r&   r2   r/   r.   r-   r6   Nc                 <    || _         || _        || _        || _        y r   )r2   r/   r-   r.   )r   r2   r/   r.   r-   s        r   r   zColumnFilter.__init__=   s      %
r   c                     	 | j                   r!t        j                  | j                  |       S | j                  | v S # t        $ r Y yw xY w)z=Identifies whether an item is found in the appropriate columnF)r.   researchr/   IOError)r   items     r   findzColumnFilter.findI   sH    	zzyy$99<<dV,, 		s   ,> > 	A
	A
r5   c                     | j                   )t        |D cg c]  }| j                  |       c}      }n| j                  || j                            }| j                  r| S |S c c}w )zDetermines whether a row should be filtered

        If the classes exclude value is false, and the necessary pattern is found, the row is not filtered,
        otherwise it is filtered.
        )r2   r8   rJ   r-   )r   r5   xr9   s       r   r9   zColumnFilter.foundR   s[     ??"s3!134EIIc$//23E<<9 4s   A%c           	      p    d| j                    d| j                   d| j                   d| j                   d	S )z$Returns a display of a column filterzColumnFilter(column=z	,exclude=z,regex=z	,pattern=))r2   r-   r.   r/   )r   s    r   __repr__zColumnFilter.__repr__`   s>    %doo%6i~WUYU_U_T``ijnjvjviwwxyyr   )FF)r;   r<   r=   r   intr>   rA   r   rJ   r   r   r9   rO   rB   r   r   r&   r&   <   st    
 
SM
 
 	

 
 

D c t z# zr   r&   )loggingtypingr   r   r   volatility3.frameworkr   r   rF   	getLoggerr;   r'   r	   r&   rB   r   r   <module>rU      s=     & & 7 				8	$0 0f&z &zr   