
    h?                        d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
  G d d          Z e            Z G d de
          Z	 	 	 	 d'dZ G d d          Z G d de          Z G d de          Z G d dee          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Zd& ZdS )(z+
Color themes for the interactive console.
    N)AnyListOptionalTuplecast)Protocolc            	           e Zd Zi ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*Zd+ e                                D             Zd, Zd- Zd. Zd/S )0
ColorTableblack)z[30mz
#ansiblackred)z[31mz#ansiredgreen)z[32mz
#ansigreenyellow)z[33mz#ansiyellowblue)z[34mz	#ansibluepurple)z[35mz#ansipurplecyan)z[36mz	#ansicyanwhite)z[37m
#ansiwhitegrey)z[38;5;246mr   reset)z[39m	noinheritbg_black)z[40mzbg:#ansiblackbg_red)z[41mzbg:#ansiredbg_green)z[42mzbg:#ansigreen	bg_yellow)z[43mzbg:#ansiyellowbg_blue)z[44mzbg:#ansiblue	bg_purple)z[45mzbg:#ansipurplebg_cyan)z[46mzbg:#ansicyan)z[47mzbg:#ansiwhite)z[49mr   )z[0mr   )z[1mbold)z[4m	underline)z[5m )z[7mr    )bg_whitebg_resetnormalr   ulineblinkinvertc                 2    i | ]\  }}|d          |d         S )r       ).0kvs      P/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/themes.py
<dictcomp>zColorTable.<dictcomp>9   s&    555daqtQqT555    c                     dS )Nz<ColorTable>r)   selfs    r-   __repr__zColorTable.__repr__;   s    ~r/   c                 F    | j                             |dg          d         S )Nr    r   )colorsgetr2   attrs     r-   __getattr__zColorTable.__getattr__?   s    {tbT**1--r/   c                     | j                                         D ]\  }}|                    |d|z             }|                                S )z>
        Transform ansi encoded text to Pygments text
         )inv_mapitemsreplacestrip)r2   xr+   r,   s       r-   ansi_to_pygmentszColorTable.ansi_to_pygmentsC   sL    
 L&&(( 	& 	&DAq		!S1W%%AAwwyyr/   N)	__name__
__module____qualname__r5   r=   r<   r3   r9   rA   r)   r/   r-   r
   r
      sf       + 	' 	+	
 	- 	) 	- 	) 	+ 	0 	* 	1 	- 	1  	3!" 	/#$ 	3%& 	/'( 2-*#) !7  F: 65fllnn555G  . . .    r/   r
   c                   D    e Zd Z	 	 	 	 d
dedee         dedededefd	ZdS )_ColorFormatterTypeNr    valfmtfmt2beforeafterreturnc                     d S Nr)   )r2   rG   rH   rI   rJ   rK   s         r-   __call__z_ColorFormatterType.__call__Q   s	     	r/   )Nr    r    r    )rB   rC   rD   r   r   strrO   r)   r/   r-   rF   rF   P   sw         '+!  sm  	
 
 &)     r/   rF   r    %sc                     | |||fdt           dt          t                   dt          dt          dt          dt          fd}|S )NrG   rH   rI   rJ   rK   rL   c                 F    |t          |           }n|| z  }|||z   |z   z  S rN   rP   )rG   rH   rI   rJ   rK   svals         r-   do_stylezcreate_styler.<locals>.do_style`   s3    
 ;s88DD9Dv}u,--r/   )r   r   rP   )rH   rJ   rK   rI   rV   s        r-   create_stylerrW   Z   si     '*!%#		. 	.c 	.sm	.	. 	. 		. ),		. 	. 	. 	. Or/   c                       e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Zd Zd Zd ZdS )
ColorThemer    c                      d| j         j        z  S )Nz<%s>)	__class__rB   r1   s    r-   r3   zColorTheme.__repr__   s    ///r/   c                     | j         ddfS )Nr)   r[   r1   s    r-   
__reduce__zColorTheme.__reduce__   s    B''r/   c                 B    |dv rt                      t                      S )N)__getstate____setstate____getinitargs____reduce_ex__)AttributeErrorrW   r7   s     r-   r9   zColorTheme.__getattr__   s*     % % % """r/   c                 h    |                     d          D ]} t          | |          |          }|S )N+)splitgetattr)r2   stringrH   styles       r-   formatzColorTheme.format   s;    YYs^^ 	2 	2E)WT5))&11FFr/   N)rB   rC   rD   style_normalstyle_promptstyle_punctstyle_idstyle_not_printablestyle_layer_namestyle_field_namestyle_field_valuestyle_emph_field_namestyle_emph_field_valuestyle_depreciate_field_namestyle_packetlist_namestyle_packetlist_protostyle_packetlist_value
style_failstyle_success	style_odd
style_evenstyle_openingstyle_activestyle_closed
style_leftstyle_right
style_logor3   r^   r9   rk   r)   r/   r-   rY   rY   m   s        LLKH"$JMIJMLLJKJ0 0 0( ( (      r/   rY   c                       e Zd ZdS )NoThemeNrB   rC   rD   r)   r/   r-   r   r              Dr/   r   c                       e Zd Zd ZdS )AnsiColorThemec                 r   |                     d          rt          |          d|z  }|| j        j        v rt	          | |          }| j        }nXt          | t                    s?|t          j	        v r1t          j	        |         d         }t          j	        d         d         }ndx}}t          ||          S )N__style_%sr   r#   r    )rJ   rK   )
startswithrd   r[   __dict__rh   rl   
isinstanceBlackAndWhiteColorr5   rW   )r2   r8   srJ   rK   s        r-   r9   zAnsiColorTheme.__getattr__   s    ??4   	' &&&'''T1%%F%EED-00 	 TU\5I5I\$'*FL*1-EEFUF%8888r/   N)rB   rC   rD   r9   r)   r/   r-   r   r      s#        9 9 9 9 9r/   r   c                       e Zd ZdS )r   Nr   r)   r/   r-   r   r      r   r/   r   c                   >   e Zd Zej        Zej        ej        z   Zej        Z	ej        ej        z   Z
ej        Zej        Zej        ej        z   Zej        Zej        Zej        ej        z   ej        z   Zej        ej        z   ej        z   Zej        ej        z   Zej        Zej        Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        Zej        Z ej        Z!ej        Z"ej        ej#        z   Z$ej        ej#        z   Z%ej&        ej        z   Z'dS )DefaultThemeN)(rB   rC   rD   r   r#   rl   r   r   rm   rn   ro   r   rp   r   rv   r   rq   rr   r   rs   r$   rt   ru   rw   rx   ry   rz   r{   r   r}   r|   r   r~   r   r   r&   r   r   r   r   r)   r/   r-   r   r      s"       <L:
*L,KzEJ&H+"'*y5:-z!J4uzA"\EK7%*D!I
2"Z"\UZ'JJ+Muz)JILM;L;Lel*J)el*Kuz)JJJr/   r   c                      e Zd Zej        Zej        Zej        ej        z   Z	ej
        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej
        ej        z   Zej        ej        z   Zej        ej        z   Zej
        ej        z   Zej        ej        z   Zej        ej        z   Zej        Zej        ej        z   Zej        ej        z   Zej        ej        z   ZdS )BrightThemeN) rB   rC   rD   r   r#   rl   rn   r   r   ro   r   rq   rr   r   rs   rt   r   ru   rw   rx   ry   rz   r   r{   r   r}   r|   r   r&   r   r   r   r)   r/   r-   r   r      s        <L,K|ej(Hy5:-|ej0uz1!L5:5"[5:5!I
2"\EJ6"\EJ6UZ'JJ+Muz)JIel*J,-Kuz)JJJr/   r   c                      e Zd Zej        ej        z   ej        z   Zej        ej        z   Z	ej
        Zej        ej        z   Zej        Zej
        ej        z   Zej        ej        z   Zej        ej        z   Zej        Zej        Zej
        ej        z   Zej        ej        z   Zej        ej        z   Zej
        Zej
        ej        z   Zej        Zej        Zej        ej        z   Zej
        ej        z   Zej        ej        z   ZdS )
RastaThemeN)rB   rC   rD   r   r#   r   r   rl   r   rm   r   rn   ro   rp   rq   rr   rs   rt   ru   rw   rx   ry   rz   r{   r}   r|   r&   r   r   r   r)   r/   r-   r   r      s       <%+-
:L<%*,L)K{UZ'H+y5:-|ej0ej0!K"[!I
2"\EJ6"[5:5JI
*MJI,J)el*Kuz)JJJr/   r   c                   T   e Zd ZdZej        Zej        ej        z   Z	ej        Z
ej        Zej        ej        z   Zej        ej        z   Zej        Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        ej        z   Zej        Zej        ej        z   Zej        Zej        Zej        ej        z   Z ej        ej        z   Z!ej        ej        z   Z"ej        ej        z   Z#ej        ej        z   Z$dS )ColorOnBlackThemez!Color theme for black backgroundsN)%rB   rC   rD   __doc__r   r#   rl   r   r   rm   rn   ro   r   rp   r   rq   r   rr   r   rs   rt   r   ru   rw   rx   ry   rz   r{   r}   r   r|   r~   r   r   r   r   r   r)   r/   r-   r   r      s.       ++<L;+L,K{H+
2|ej0zuz1!J3"Y3!K%*4"\EJ6"\EJ6UZ'JKMuz)JILM;+L;+Lej(J)ej(Kuz)JJJr/   r   c                       e Zd ZdedefdZdS )FormatThemer8   rL   c                     |                     d          rt          |          | j        j                            d|z  d          }t          |          S )Nr   r   rQ   )rI   )r   rd   r[   r   r6   rW   )r2   r8   colfmts      r-   r9   zFormatTheme.__getattr__  sT    ??4   	' &&&(,,Z$->EE&))))r/   N)rB   rC   rD   rP   rF   r9   r)   r/   r-   r   r     s7        * *(; * * * * * *r/   r   c                   h     e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZd	Zd
Zdedef fdZ xZS )
LatexThemezd
    You can prepend the output from this theme with
    \tt\obeyspaces\obeylines\tiny\noindent
    z\textcolor{blue}{%s}z\textcolor{gray}{%s}z\textcolor{red}{\bf %s}z\textcolor{purple}{%s}z \textcolor{blue}{\underline{%s}}z"\textcolor{purple}{\underline{%s}}z\textcolor{blue}{\bf %s}z\textcolor{red}{%s}z\textcolor{green}{\bf %s}r8   rL   c                     ddl m t          t          |                               |          t          t          fd          S )Nr   
tex_escapec                 H      t          |                     g|R i |S rN   rT   )r@   argskwargsstylerr   s      r-   <lambda>z(LatexTheme.__getattr__.<locals>.<lambda>=  s1    vvjjQ.@.@'R4'R'R'R6'R'R r/   )scapy.utilsr   superr   r9   r   rF   )r2   r8   r   r   r[   s     @@r-   r9   zLatexTheme.__getattr__8  sX    ******z4((44T::RRRRR
 
 	
r/   )rB   rC   rD   r   rm   rp   rq   rr   rs   rt   ru   rw   rx   ry   rz   r{   r   r   r   rP   rF   r9   __classcell__r]   s   @r-   r   r   !  s          +L11.1?B646+J/M(J(K .J
 
(; 
 
 
 
 
 
 
 
 
 
r/   r   c                   N    e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZd	Zd
ZdS )LatexTheme2z@`@textcolor@[@blue@]@@[@%s@]@z@`@textcolor@[@gray@]@@[@%s@]@z.@`@textcolor@[@red@]@@[@@`@bfseries@[@@]@%s@]@z @`@textcolor@[@purple@]@@[@%s@]@z0@`@textcolor@[@blue@]@@[@@`@underline@[@%s@]@@]@z2@`@textcolor@[@purple@]@@[@@`@underline@[@%s@]@@]@z/@`@textcolor@[@blue@]@@[@@`@bfseries@[@@]@%s@]@z/@`@textcolor@[@gray@]@@[@@`@bfseries@[@@]@%s@]@z@`@textcolor@[@red@]@@[@%s@]@z0@`@textcolor@[@green@]@@[@@`@bfseries@[@@]@%s@]@N)rB   rC   rD   rm   rp   rq   rr   rs   rt   ru   rw   rx   ry   rz   r{   r}   r   r   r   r)   r/   r-   r   r   A  sg        4L;H8;ORM>@BJFMCJ2J2KDJJJr/   r   c                   N    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdS )	HTMLThemez<span class=prompt>%s</span>z#<span class=not_printable>%s</span>z <span class=layer_name>%s</span>z <span class=field_name>%s</span>z!<span class=field_value>%s</span>z%<span class=emph_field_name>%s</span>z&<span class=emph_field_value>%s</span>z%<span class=packetlist_name>%s</span>z&<span class=packetlist_proto>%s</span>z&<span class=packetlist_value>%s</span>z<span class=fail>%s</span>z<span class=success>%s</span>z<span class=even>%s</span>z<span class=odd>%s</span>z<span class=left>%s</span>z<span class=right>%s</span>NrB   rC   rD   rm   rp   rq   rr   rs   rt   ru   rw   rx   ry   rz   r{   r}   r|   r   r   r)   r/   r-   r   r   U  sg        1L?99;CECEE-J3M-J+I-J/KKKr/   r   c                   N    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdS )
HTMLTheme2z$#[#span class=prompt#]#%s#[#/span#]#z+#[#span class=not_printable#]#%s#[#/span#]#z(#[#span class=layer_name#]#%s#[#/span#]#z(#[#span class=field_name#]#%s#[#/span#]#z)#[#span class=field_value#]#%s#[#/span#]#z-#[#span class=emph_field_name#]#%s#[#/span#]#z.#[#span class=emph_field_value#]#%s#[#/span#]#z-#[#span class=packetlist_name#]#%s#[#/span#]#z.#[#span class=packetlist_proto#]#%s#[#/span#]#z.#[#span class=packetlist_value#]#%s#[#/span#]#z"#[#span class=fail#]#%s#[#/span#]#z%#[#span class=success#]#%s#[#/span#]#z"#[#span class=even#]#%s#[#/span#]#z!#[#span class=odd#]#%s#[#/span#]#z"#[#span class=left#]#%s#[#/span#]#z##[#span class=right#]#%s#[#/span#]#Nr   r)   r/   r-   r   r   h  sg        9LGAACKMKMM5J;M5J3I5J7KKKr/   r   c                   	 	 ddl m}m n,# t          $ r ddlm} |                    d           Y dS w xY wddlm} i }t          |j
        t                    rd| _        nKt          |j
        t                    rd| _        n)t          |j
        t                    rd	| _        nd
| _        	 t                       | j        j        d         d         } || j                   n# t$          $ r Y nw xY wt          |j        |          r|j        | _        nt          |j
        t*          t          f          rt          |j
        t,                    rt/          j        |j                  	n8t          |j
        t2                    rddlm}  ||j                  	n|j        	|j
                            	          	n@t9          |j                  	t:                              |j
        j                  |j         <    G 	fdd|          }|| _        	tB          _"        || _#        	 t                      $                                 dS # t$          $ r Y dS w xY w)zVUpdates the specified IPython console shell with
    the conf.color_theme scapy theme.r   )PromptsToken)log_loadingz.IPython too old. Shell color won't be handled.N)confnocolorlightbglinuxneutralliner5   r   c                   (    e Zd Zd fd	Z fdZdS )*apply_ipython_style.<locals>.ClassicPromptNc                     j         fgS rN   )Prompt)r2   clir   prompts     r-   in_prompt_tokensz;apply_ipython_style.<locals>.ClassicPrompt.in_prompt_tokens  s    v.11r/   c                     j         dfgS )Nr    )	OutPrompt)r2   r   s    r-   out_prompt_tokensz<apply_ipython_style.<locals>.ClassicPrompt.out_prompt_tokens  s    "-00r/   rN   )rB   rC   rD   r   r   )r   r   s   r-   ClassicPromptr     sQ        2 2 2 2 2 2 21 1 1 1 1 1 1r/   r   )%IPython.terminal.promptsr   r   	Exceptionscapy.errorr   warningscapy.configr   r   color_themer   r5   r   r   get_ipythonmagics_managermagics	NameErrorr   prompts_classr   r   htmlescaper   r   r   rP   r   rA   rm   r   sysps1highlighting_style_overridesrefresh_style)
shellr   r   r   scapy_stylecolor_magicr   r   r   r   s
           @@r-   apply_ipython_styler   {  s   ;;;;;;;;;   ++++++<	
 	
 	
 	 "!!!!!K$"G,, 
! 	D$k	2	2 ! 	D$&7	8	8 ! !*1&9(CEL!!!!    $+w'' "kd&g(>?? 	$*I66 %T[11D,j99 %222222#DK00%,,V44FF %%F(-(>(> -) )K%	1 	1 	1 	1 	1 	1 	1 	1G 	1 	1 	1 ,)4E&##%%%%%   s0    %66/6C& &
C32C3- I 
II)Nr    r    rQ   )r   r   r   typingr   r   r   r   r   scapy.compatr   r
   r   rF   rW   rY   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r/   r-   <module>r      sI     



              " ! ! ! ! !/ / / / / / / /d 	
    (       &- - - - - - - -`	 	 	 	 	j 	 	 	9 9 9 9 9Z 9 9 9$	 	 	 	 	NG 	 	 	* * * * *> * * *6* * * * *. * * *** * * * * * * *.* * * * * * * *6* * * * ** * * *
 
 
 
 
 
 
 
@E E E E E+ E E E(0 0 0 0 0 0 0 0&8 8 8 8 8 8 8 8&H H H H Hr/   