
    hg                        d Z ddlZddlmZmZ ddlZddlZddlZej        d         dk    Z	dZ
e
dz   Z ej                     i a e             d e            v r	 dand	a ej        d
          dk    rda G d de          Zd e
D             Zded<   e                                D ]0\  ZZ ed                    e                    Ze e            e<   1[[[[d Zd	d	e
fdZd Zd Zd Zd ZdS )z*A simple and elegant wrapper for colorama.    N)choiceseed   )redgreenyellowblueblackmagentacyanwhite)normalcleandisableenablerandomreplace_colorsreset_replace_colorsget_ipythonTFTERMdumbc                        e Zd ZdZd fd	Zd Zed             Zd Zd Z	d Z
ere
Znd	 Zd
 Zd Zd Zd Zd Z xZS )ColoredStringz9Enhanced string for __len__ operations on Colored output.Fc                    t          t          |                                            t          s0t	          |t
                    r|                    d          | _        nt          |          | _        t          
                    ||          | _        || _        || _        t          j        
                    d          r	d| _        d S d S )Nzutf-8CLINT_FORCE_COLORT)superr   __init__PY3
isinstanceunicodeencodesstrREPLACE_COLORSgetcoloralways_colorboldosenviron)selfr&   r"   r'   r(   	__class__s        @/var/www/fb-scrape/myenv/lib/python3.11/site-packages/crayons.pyr   zColoredString.__init__-   s    mT""++--- 	z!W-- 	XXg&&DFFVVDF#''u55
(	:>>-.. 	% $D	% 	%    c                       fd}|S )Nc                  *    t          j                  | i |}	 t          |t                    }n%# t          $ r t          |t
                    }Y nw xY w|r                    |          S t          |t                    rfd|D             S |S )Nc                 :    g | ]}                     |          S  )_new).0xr+   s     r-   
<listcomp>z@ColoredString.__getattr__.<locals>.func_help.<locals>.<listcomp>C   s#    555		!555r.   )getattrr"   r   
basestring	NameErrorr#   r3   list)argskwargsresultis_result_stringattr+   s       r-   	func_helpz,ColoredString.__getattr__.<locals>.func_help:   s    )WTVS))4:6::F;#-fj#A#A   ; ; ;#-fc#:#:   ; yy(((FD)) 5555f5555s   4 AAr2   )r+   r?   r@   s   `` r-   __getattr__zColoredString.__getattr__9   s*    	 	 	 	 	 	 r.   c                    | j         rdnd}t          t          j        | j                  t          t          j        |          | j        t          j        j        t          j        j        }| j	        r|S t          t          j        d          r't          j                                        r	t          s|S | j        S )NBRIGHTNORMALisatty)r(   r7   coloramaForer&   Styler"   RESETrD   r'   hasattrsysstdoutrE   DISABLE_COLOR)r+   stylecs      r-   	color_strzColoredString.color_strH   s     I38#HM4:>>>#HNE::: FF$M//$N11	3  	HSZ** 	J%%''	%	 H6Mr.   c                 *    t          | j                  S N)lenr"   r+   s    r-   __len__zColoredString.__len__Z   s    46{{r.   c                 (    d| j         d| j        dS )N<z
-string: 'z'>)r&   r"   rT   s    r-   __repr__zColoredString.__repr__]   s     &*jjj$&&&99r.   c                 h    | j         }t          |t                    r|                    d          S |S )Nutf8)rP   r   bytesdecode)r+   values     r-   __unicode__zColoredString.__unicode__`   s2    eU## 	(<<'''r.   c                     | j         S rR   rP   rT   s    r-   __str__zColoredString.__str__i   s
    >!r.   c                 *    t          | j                  S rR   )iterrP   rT   s    r-   __iter__zColoredString.__iter__l   s    DN###r.   c                 J    t          | j                  t          |          z   S rR   r#   rP   r+   others     r-   __add__zColoredString.__add__o   s    4>""SZZ//r.   c                 J    t          |          t          | j                  z   S rR   rf   rg   s     r-   __radd__zColoredString.__radd__r   s    5zzC////r.   c                     | j         |z  S rR   r`   rg   s     r-   __mul__zColoredString.__mul__u   s    &'r.   c                 ,    t          | j        |          S rR   )r   r&   )r+   r"   s     r-   r3   zColoredString._newx   s    TZ+++r.   )FF)__name__
__module____qualname____doc__r   rA   propertyrP   rU   rX   r^   r   ra   rd   ri   rk   rm   r3   __classcell__)r,   s   @r-   r   r   *   s       CC
% 
% 
% 
% 
% 
%     X"  : : :    "	" 	" 	"$ $ $0 0 00 0 0( ( (, , , , , , ,r.   r   c                 8    i | ]}||                                 S r2   upper)r4   r5   s     r-   
<dictcomp>rx   |   s"    
(
(
(A1aggii
(
(
(r.   rI   r   zZlambda s, always=False, bold=False: ColoredString("{}", s, always_color=always, bold=bold)c                 Z    t          j        d          }|                    d|           }|S )Nz(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~] )recompilesub)r"   striptxts      r-   r   r      s*    J9::E
))B

CJr.   c                     t          t          d |                    pt          }t          t	          |                                          | ||          S )z&Selects a color at random from a list.c                     | t           v S rR   )COLORS)r&   s    r-   <lambda>zrandom.<locals>.<lambda>   s
    u r.   )r'   r(   )r:   filterr   r   r   rw   )stringalwaysr(   colorss       r-   r   r      sW    &66??@@JFFv	   r.   c                  
    da dS )zDisables colors.TNrM   r2   r.   r-   r   r      s     MMMr.   c                  
    da dS )zEnables colors.FNr   r2   r.   r-   r   r      s     MMMr.   c                 p    t          | t                    sJ d |                                 D             adS )z?Replace colors to customize the look under specific background.c                 b    i | ],\  }}|                                 |                                 -S r2   rv   )r4   kvs      r-   rx   z"replace_colors.<locals>.<dictcomp>   s.    LLLtq!aggiiLLLr.   N)r   dictitemsr$   )replace_dicts    r-   r   r      s=     lD)))))LL|7I7I7K7KLLLNNNr.   c                  
    i a dS )zReset any set replace colors.N)r$   r2   r.   r-   r   r      s     NNNr.   ) rr   r)   r   r   r   r{   rK   rF   version_infor   r   __all__initr$   dirrM   getenvobjectr   _colorsr   keyvalevalformatfunctionlocalsr   r   r   r   r   r2   r.   r-   <module>r      s   0 0 				         				 



 	qQ

   
  CCEE
 MMM29VMO, O, O, O, O,F O, O, O,d )
(
(
(
(   HCtdkkloppr rHFFHHSMMgx    eF        M M M    r.   