
    <hdI                        S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
JrJrJrJrJrJrJrJrJrJrJrJr  \R.                  S:  a  SSKJr  OSSK
Jr   " S S	\5      r " S
 S\5      rS5S\S\S\S\S\4
S jjr S\\\\   4   S\\   4S jr!S6S\S\S\S\4S jjr"S\S\4S jr#S\S\4S jr$S\S\4S jr% " S S\5      r& " S S \5      r' " S! S"\'5      r( S7S#\\   S$\S%\S\\\      4S& jjr)S'\\   S%\S(\S)\S\\\4   4
S* jr*\" S+5      r+S,\\+   S-\S.\+S\+4S/ jr, S8S0\\   S1\S2\S3\S\4
S4 jjr-g)9z~
Utilities for working with strings and text.

Inheritance diagram:

.. inheritance-diagram:: IPython.utils.text
   :parts: 3
    N)	Formatter)Path)ListDictTupleOptionalcastSequenceMappingAnyUnionCallableIteratorTypeVar)      )Selfc                       \ rS rSr% Sr\\   \S'   \\S'   \\   \S'   S\\   4S jr	\
" \	5      =rrS\4S jr\
" \5      =rrS\4S	 jr\
" \5      =rrS\\   4S
 jr\
" \5      =rrSrg)LSString(   a<  String derivative with a special access attributes.

These are normal strings, but with the special attributes:

    .l (or .list) : value as list (split on newlines).
    .n (or .nlstr): original value (the string itself).
    .s (or .spstr): value as whitespace-separated string.
    .p (or .paths): list of path objects (requires path.py package)

Any values which require transformations are computed only once and
cached.

Such strings are very useful to efficiently interact with the shell, which
typically only understands whitespace-separated options for commands._LSString__list_LSString__spstr_LSString__pathsreturnc                      U R                   $ ! [         a%    U R                  S5      U l         U R                   s $ f = fN
)r   AttributeErrorsplitselfs    eC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\IPython/utils/text.pyget_listLSString.get_list<   s:    	;; 	**T*DK;;	    ,==c                      U R                   $ ! [         a&    U R                  SS5      U l         U R                   s $ f = f)Nr    )r   r   replacer    s    r"   	get_spstrLSString.get_spstrE   s<    	 << 	 <<S1DL<<	 s    ->>c                     U $ N r    s    r"   	get_nlstrLSString.get_nlstrN           c                     U R                   $ ! [         ak    U R                  S5       Vs/ s H4  n[        R                  R                  U5      (       d  M)  [        U5      PM6     Os  snf snU l         U R                   s $ f = fr   )r   r   r   ospathexistsr   r!   ps     r"   	get_pathsLSString.get_pathsS   sa    	 << 	 -1ZZ-=S-=PQARGDG-=SDL<<	 s     B(A'A'&BB)__list__paths__spstrN)__name__
__module____qualname____firstlineno____doc__r   str__annotations__r   r#   propertyllistr)   sspstrr   r.   nnlstrr8   r7   paths__static_attributes__r-   r1   r"   r   r   (   s    M IL$Z$s)  !!A 3   ##A4  ##A 4:   ##Ar1   r   c            	       x   \ rS rSr% Sr\\S'   \\S'   \\   \S'   S\	4S jr
\" \
5      =rrS\4S jr\" \5      =rrS\4S	 jr\" \5      =rrS\\   4S
 jr\" \5      =rr  SS\\\\/\R6                  \   S-  4   4   S\S\\   S\	4S jjrS\\   S\\\      4S jr   SS\\\      S\S\	4S jjr!Sr"g)SListi   a  List derivative with a special access attributes.

These are normal lists, but with the special attributes:

* .l (or .list) : value as list (the list itself).
* .n (or .nlstr): value as a string, joined on newlines.
* .s (or .spstr): value as a string, joined on spaces.
* .p (or .paths): list of path objects (requires path.py package)

Any values which require transformations are computed only once and
cached._SList__spstr_SList__nlstr_SList__pathsr   c                     U $ r,   r-   r    s    r"   r#   SList.get_listz   r0   r1   c                      U R                   $ ! [         a%    SR                  U 5      U l         U R                   s $ f = f)Nr'   )rP   r   joinr    s    r"   r)   SList.get_spstr   s9    	 << 	 88D>DL<<	 r%   c                      U R                   $ ! [         a%    SR                  U 5      U l         U R                   s $ f = fr   )rQ   r   rV   r    s    r"   r.   SList.get_nlstr   s9    	 << 	 99T?DL<<	 r%   c                      U R                   $ ! [         a\    U  Vs/ s H4  n[        R                  R	                  U5      (       d  M)  [        U5      PM6     Os  snf snU l         U R                   s $ f = fr,   )rR   r   r3   r4   r5   r   r6   s     r"   r8   SList.get_paths   sU    	 << 	 -1GTRWW^^A5FGDGTGDL<<	 s     A4(AAA43A4Npatternprunefieldc           
      d  ^^ S[         S[         4U4S jjn[        T[         5      (       a  U4S jnOTnU(       d6  [        U 5      " U  Vs/ s H  oe" U" U5      5      (       d  M  UPM     sn5      $ [        U 5      " U  Vs/ s H  oe" U" U5      5      (       a  M  UPM     sn5      $ s  snf s  snf )aa  Return all strings matching 'pattern' (a regex or callable)

This is case-insensitive. If prune is true, return all items
NOT matching the pattern.

If field is specified, the match must occur in the specified
whitespace-separated field.

Examples::

    a.grep( lambda x: x.startswith('C') )
    a.grep('Cha.*log', prune=1)
    a.grep('chm', field=-1)
rG   r   c                 ^   > Tc  U $ U R                  5       n UT   nU$ ! [         a     gf = f)N )r   
IndexError)rG   partstgtr^   s      r"   match_target SList.grep.<locals>.match_target   s=    }GGIEEl
 s    
,,c                 P   > [         R                  " TU [         R                  5      $ r,   )research
IGNORECASE)xr\   s    r"   <lambda>SList.grep.<locals>.<lambda>   s    biiBMMBr1   )rB   
isinstancetype)r!   r\   r]   r^   re   predels    ` `   r"   grep
SList.grep   s    *	C 	C 	 gs##BDD:DKDbDb9I4JrDKLL:DODb\"=M8NrDOPP LOs   B(%B(B-B-fieldsc                    [        U5      S:X  a   U  Vs/ s H  o"R                  5       PM     sn$ [        5       nU  Vs/ s H  oDR                  5       PM     sn HK  n/ nU H  n UR                  X&   5        M     U(       d  M+  UR                  SR                  U5      5        MM     U$ s  snf s  snf ! [         a     Ma  f = f)a#  Collect whitespace-separated fields from string list

Allows quick awk-like usage of string lists.

Example data (in var a, created by 'a = !ls -l')::

    -rwxrwxrwx  1 ville None      18 Dec 14  2006 ChangeLog
    drwxrwxrwx+ 6 ville None       0 Oct 24 18:05 IPython

* ``a.fields(0)`` is ``['-rwxrwxrwx', 'drwxrwxrwx+']``
* ``a.fields(1,0)`` is ``['1 -rwxrwxrwx', '6 drwxrwxrwx+']``
  (note the joining by space).
* ``a.fields(-1)`` is ``['ChangeLog', 'IPython']``

IndexErrors are ignored.

Without args, fields() just split()'s the strings.
r   r'   )lenr   rN   appendrb   rV   )r!   rt   rq   resf	linepartsfds          r"   rt   SList.fields   s    & v;!)-.2HHJ..g&*+d779d+BI$$RV, 
 y

388I./ , 
 / , " s   B+B0%B55
CCnumsc                 "   Ub.  U  Vs/ s H   n[        U/5      R                  U5      U/PM"     nnOU  Vs/ s H  o3U/PM     nnU(       ak  [        [        U5      5       HS  nSR	                  XE   S    Vs/ s H  ofR                  5       (       d  M  UPM     sn5      n [        U5      nXU   S'   MU     UR                  5         [        U 5      " U V	s/ s H  oS   PM	     sn	5      $ s  snf s  snf s  snf ! [         a    Sn N\f = fs  sn	f )zsort by specified fields (see fields())

Example::

    a.sort(1, nums = True)

Sorts a by second field, in numerical order (so that 21 > 3)

ra   r      )
rN   rt   rangerv   rV   isdigitint
ValueErrorsortro   )
r!   r^   r}   linedsuichnumstrrI   ts
             r"   r   
SList.sort   s      DHIDDE4&M((/$7DCIC-12TT4=TC23s8_svay!IyJJL"y!IJFA Aq	 % 	
Dz-AQ4-.. J2 "J " A .s.   'C+C07C5
C5
!C:D:D	D	)__nlstrr;   r<   )FN)NF)#r=   r>   r?   r@   rA   rB   rC   r   r   r   r#   rD   rE   rF   r)   rG   rH   r.   rI   rJ   r8   r7   rK   r   r   r   rh   Matchboolr   r   rr   rt   r   rL   r-   r1   r"   rN   rN   i   sL   
 LL$Z$  !!A 3   ##A 3   ##A 4:   ##A
 #	&QsHcUBHHSMD,@%@AAB&Q &Q }	&Q
 
&QP"d3i "DcO "L &*/S	"/ / 
	/ /r1   rN   instrnspacesntabsflattenr   c                 Z   SU-  SU-  -   nU(       a&  [         R                  " S[         R                  5      nO%[         R                  " S[         R                  5      n[         R                  " XTU 5      nUR	                  [
        R                  U-   5      (       a  US[        U5      *  $ U$ )aN  Indent a string a given number of spaces or tabstops.

indent(str, nspaces=4, ntabs=0) -> indent str by ntabs+nspaces.

Parameters
----------
instr : basestring
    The string to be indented.
nspaces : int (default: 4)
    The number of spaces to be indented.
ntabs : int (default: 0)
    The number of tabs to be indented.
flatten : bool (default: False)
    Whether to scrub existing indentation.  If True, all lines will be
    aligned to the same indentation.  If False, existing indentation will
    be strictly increased.

Returns
-------
str : string indented by ntabs and nspaces.

	r'   z^\s*^N)rh   compile	MULTILINEsubendswithr3   lineseprv   )r   r   r   r   indpatoutstrs          r"   indentr     s    . ,w
&Cjj",,/jjr||,VVCe$Frzz#~&&jCy!!r1   argc                 6    [        U [        5      (       a  U /$ U $ )au  Always return a list of strings, given a string or list of strings
as input.

Examples
--------
::

    In [7]: list_strings('A single string')
    Out[7]: ['A single string']

    In [8]: list_strings(['A single string in a list'])
    Out[8]: ['A single string in a list']

    In [9]: list_strings(['A','list','of','strings'])
    Out[9]: ['A', 'list', 'of', 'strings']
)rn   rB   )r   s    r"   list_stringsr   +  s    $ #su
r1   txtwidthmarkc                     U (       d  X!-  SU $ U[        U 5      -
  S-
  [        U5      -  S-  nUS:  a  SnX#-  nU< SU < SU< 3$ )aa  Return the input string centered in a 'marquee'.

Examples
--------
::

    In [16]: marquee('A test',40)
    Out[16]: '**************** A test ****************'

    In [17]: marquee('A test',40,'-')
    Out[17]: '---------------- A test ----------------'

    In [18]: marquee('A test',40,' ')
    Out[18]: '                 A test                 '

N   r   r'   rv   )r   r   r   nmarkmarkss        r"   marqueer   C  sU    " 
FU##3s8^AD	)1,Eqy%JEs5))r1   strngc                 t    [         R                  " S[         R                  5      nUR                  SU 5      n U $ )zPFormat a string for screen printing.

This removes some latex-type format codes.z\\$ra   )rh   r   r   r   )r   par_res     r"   format_screenr   \  s-    
 ZZr||,FJJr% ELr1   textc                     U R                  S5      (       a  [        R                  " U 5      $ U R                  SS5      n[	        U5      S:X  a  [        R                  " U 5      $ Uu  p#[        R                  " U5      nSR                  X#/5      $ )zEquivalent of textwrap.dedent that ignores unindented first line.

This means it will still dedent strings like:
'''foo
is a bar
'''

For use in wrap_paragraphs.
r   r   )
startswithtextwrapdedentr   rv   rV   )r   splitsfirstrests       r"   r   r   f  su     tt$$ ZZQF
6{at$$KE??4 D99e]##r1   c                    U R                  5       nSn[        U6  HC  n[        [        U5      5      S:  a    O*US   nU[        R
                  ;   d  US:X  a  US-  nMC    O   SR                  U Vs/ s H  oUUS PM	     sn5      n U $ s  snf )a  Strip leading email quotation characters ('>').

Removes any combination of leading '>' interspersed with whitespace that
appears *identically* in all lines of the input text.

Parameters
----------
text : str

Examples
--------

Simple uses::

    In [2]: strip_email_quotes('> > text')
    Out[2]: 'text'

    In [3]: strip_email_quotes('> > text\n> > more')
    Out[3]: 'text\nmore'

Note how only the common prefix that appears in all lines is stripped::

    In [4]: strip_email_quotes('> > text\n> > more\n> more...')
    Out[4]: '> text\n> more\nmore...'

So if any line has no quote marks ('>'), then none are stripped from any
of them ::

    In [5]: strip_email_quotes('> > text\n> > more\nlast different')
    Out[5]: '> > text\n> > more\nlast different'
r   r   >r   N)
splitlinesziprv   setstring
whitespacerV   )r   lines	strip_len
charactersprefix_charlns         r"   strip_email_quotesr     s    @ OOEI5k
s:!# m&+++{c/ANI " 99u5unu56DK 6s   1Bc            
       <    \ rS rSrSrS\S\S\S\\\4   4S jrSr	g	)
EvalFormatteri  a1  A String Formatter that allows evaluation of simple expressions.

Note that this version interprets a `:`  as specifying a format string (as per
standard string formatting), so if slicing is required, you must explicitly
create a slice.

This is to be used in templating cases, such as the parallel batch
script templates, where simple arithmetic on arguments is useful.

Examples
--------
::

    In [1]: f = EvalFormatter()
    In [2]: f.format('{n//4}', n=8)
    Out[2]: '2'

    In [3]: f.format("{greeting[slice(2,4)]}", greeting="Hello")
    Out[3]: 'll'
nameargskwargsr   c                     [        X5      nXA4$ r,   )eval)r!   r   r   r   vs        r"   	get_fieldEvalFormatter.get_field  s    wr1   r-   N)
r=   r>   r?   r@   rA   rB   r   r   r   rL   r-   r1   r"   r   r     s0    *c  c eCHo r1   r   c                   B    \ rS rSrSrS\S\\   S\\\4   S\4S jr	Sr
g	)
FullEvalFormatteri  a!  A String Formatter that allows evaluation of simple expressions.

Any time a format key is not found in the kwargs,
it will be tried as an expression in the kwargs namespace.

Note that this version allows slicing using [1:2], so you cannot specify
a format string. Use :class:`EvalFormatter` to permit format strings.

Examples
--------
::

    In [1]: f = FullEvalFormatter()
    In [2]: f.format('{n//4}', n=8)
    Out[2]: '2'

    In [3]: f.format('{list(range(5))[2:4]}')
    Out[3]: '[2, 3]'

    In [4]: f.format('{3*2}')
    Out[4]: '6'
format_stringr   r   r   c                 X   / nU R                  U5       H  u  pVpxU(       a  UR                  U5        Uc  M#  U(       a  SR                  Xg/5      n[        U[	        U5      5      n	U R                  X5      n	UR                  U R                  U	S5      5        M     SR                  U5      $ )N:ra   )parserw   rV   r   dictconvert_fieldformat_field)
r!   r   r   r   resultliteral_text
field_nameformat_spec
conversionobjs
             r"   vformatFullEvalFormatter.vformat  s     AEB
=Lk l+ % !$:*C!DJ :tF|4 ((9 d//R893B
6 wwvr1   r-   N)r=   r>   r?   r@   rA   rB   r
   r   r   r   rL   r-   r1   r"   r   r     s9    0   (0 ?FsCx?P 	 r1   r   c            	       p    \ rS rSrSr\R                  " S5      rS\S\	\
\\\\4      4S jrS\4S jrSrg	)
DollarFormatteri  a  Formatter allowing Itpl style $foo replacement, for names and attribute
access only. Standard {foo} replacement also works, and allows full
evaluation of its arguments.

Examples
--------
::

    In [1]: f = DollarFormatter()
    In [2]: f.format('{n//4}', n=8)
    Out[2]: '2'

    In [3]: f.format('23 * 76 is $result', result=23*76)
    Out[3]: '23 * 76 is 1748'

    In [4]: f.format('$a or {b}', a=1, b=2)
    Out[4]: '1 or 2'
z,(.*?)\$(\$?[\w\.]+)(?=([^']*'[^']*')*[^']*$)
fmt_stringr   c              #   L  #    [         R                  " X5       H  u  p#pESnSnU R                  R                  U5       HQ  nUR	                  SS5      u  pU
R                  S5      (       a  XyU
-   -  nOXy-   U
SS 4v   SnUR                  5       nMS     XrUS  -   X4U4v   M     g 7f)Nr   ra   r   r   $)r   r   #_dollar_pattern_ignore_single_quotefinditergroupr   end)r!   r   literal_txtr   r   r   continue_fromr   mnew_txt	new_fields              r"   r   DollarFormatter.parse%  s     @IA
<K[ MC==FF{S%&WWQq\"'',,Y..C=)R>>C ! T ]^44jzZZ#A
s   B"B$c                     g)Nz<DollarFormatter>r-   r    s    r"   __repr__DollarFormatter.__repr__9  s    "r1   r-   N)r=   r>   r?   r@   rA   rh   r   r   rB   r   r   r   r   r   rL   r-   r1   r"   r   r     sP    & +-**7+'[ [sCc7I1J(K [(## #r1   r   rE   max_rows	row_firstc              #   *  #    U(       a^  [        U 5      U-  [        U 5      U-  S:  -   n[        U5       H.  n[        U[        U 5      U5       Vs/ s H  oPU   PM	     snv   M0     g[        S[        U 5      U5       H  nXXA-    v   M     gs  snf 7f)z5Yield successive max_rows-sized column chunks from l.r   N)rv   r   )rE   r   r   ncolsr   js         r"   _col_chunksr   A  s      Q8#A(9A(=>uA!&q#a&%!89!8AQ4!899  q#a&(+Aq|%% , :s   ABB5Brlistseparator_sizedisplaywidthc                 
   [        S[        U 5      S-   5       HL  n[        [        [        [        XU5      5      5      n[        U5      n[        U5      nXbUS-
  -  -   U::  d  ML    O   WUS-
  (       a  UW-
  US-
  -  OSWWS.$ )z4Calculate optimal info to columnize a list of stringr   r   )num_columnsoptimal_separator_widthr   column_widths)r   rv   rF   mapmaxr   sum)r   r   r   r   r   
col_widths	sumlengthr   s           r"   _find_optimalr  N  s     !SZ!^,#c;u	#JKL

O	J33|C - !UZ]^U^y(@eai'Pef ' r1   Tmylistr   defaultc                 ,    U[        U 5      :  a  U$ X   $ )z2return list item number, or default if don't existr   )r  r   r  s      r"   _get_or_defaultr  b  s    CKyr1   list_last_sepsepwrap_item_withc                     [        U 5      S:X  a  gU(       a  U  Vs/ s H  nU< U< U< 3PM     n n[        U 5      S:X  a  U S   $ UR                  S U SS  5       5      < U< U S   < 3$ s  snf )a  
Return a string with a natural enumeration of items

>>> get_text_list(['a', 'b', 'c', 'd'])
'a, b, c and d'
>>> get_text_list(['a', 'b', 'c'], ' or ')
'a, b or c'
>>> get_text_list(['a', 'b', 'c'], ', ')
'a, b, c'
>>> get_text_list(['a', 'b'], ' or ')
'a or b'
>>> get_text_list(['a'])
'a'
>>> get_text_list([])
''
>>> get_text_list(['a', 'b'], wrap_item_with="`")
'`a` and `b`'
>>> get_text_list(['a', 'b', 'c', 'd'], " = ", sep=" + ")
'a + b + c = d'
r   ra   r   c              3   $   #    U  H  ov   M     g 7fr,   r-   ).0r   s     r"   	<genexpr> get_text_list.<locals>.<genexpr>  s     'JqJs   N)rv   rV   )r	  r
  r  r  items        r"   get_text_listr  j  s    . 5zQ  ,T>B 	  
5zQQx'E#2J''%) 	 s   A.)   r   F)ra   N   *)F)z and z, ra   ).rA   r3   rh   r   sysr   warningsr   pathlibr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   version_infotyping_extensionsr   rB   r   rF   rN   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r-   r1   r"   <module>r     s   
 	  
        g&2$s 2$B\/D \/~ #      $  SV  FeCcN+ S	 0* *# *# * *2  $ $ $6/S /S /dI <9	 9x-#' -#j 49
&Cy
&
&,0
&d3i
&9!%7:JM	#s(^" CLDG  a A  WY 9  # 47 PS  r1   