
    z%i
.                         	 g d Z ddlZdZdZdZeez   ZdZedz   dz   Zd	Zd
Z	eez   e	z   ez   Z
ddZddlZddlmZ i Z G d d      Zej'                           G d d      Zy))ascii_lettersascii_lowercaseascii_uppercasecapwordsdigits	hexdigits	octdigits	printablepunctuation
whitespace	FormatterTemplate    Nz 	
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789abcdefABCDEF01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~c                 |    	 |xs dj                  t        t        j                  | j	                  |                  S )N )joinmapstr
capitalizesplit)sseps     :/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/string.pyr   r   %   s1    	 J3S>??    )ChainMapc                   p     e Zd Z	 dZdZdZej                  Z fdZ	d Z
d ZefdZefdZd	 Zd
 Z xZS )r   $z(?a:[_a-z][_a-z0-9]*)Nc           	      l   t         |           d| j                  v r| j                  }nTt	        j
                  | j                        }| j                  }| j                  xs | j                  }d| d| d| d| d	}t	        j                  || j                  t        j                  z        | _        y )Npatternz
            z(?:
              (?P<escaped>zC)  |   # Escape sequence of two delimiters
              (?P<named>zJ)       |   # delimiter and a Python identifier
              {(?P<braced>z)} |   # delimiter and a braced identifier
              (?P<invalid>)             # Other ill-formed delimiter exprs
            )
            )super__init_subclass____dict__r$   _reescape	delimiter	idpatternbraceidpatterncompileflagsVERBOSE)clsr$   delimidbid	__class__s        r   r&   zTemplate.__init_subclass__E   s    !#$kkGJJs}}-EB$$5CG  ' " 5 !	G kk'399s{{+BCr   c                     || _         y N)template)selfr7   s     r   __init__zTemplate.__init__W   s	     r   c                     |j                  d      }| j                  d | j                  d      }|sd}d}n+|t        dj	                  |d d             z
  }t        |      }t        d||fz        )NinvalidT)keepends    z.Invalid placeholder in string: line %d, col %d)startr7   
splitlineslenr   
ValueError)r8   moilinescolnolinenos         r   _invalidzTemplate._invalid\   s~    HHYbq!,,d,;EFBGGE#2J/00EZFI %) * 	*r   c                     t         u r|n|rt        |       fd} j                  j                  | j                        S )Nc                    | j                  d      xs | j                  d      }|t        |         S | j                  d      j                  S | j                  d      j                  |        t	        dj
                        Nnamedbracedescapedr;   #Unrecognized named group in pattern)groupr   r*   rI   rC   r$   rD   rM   mappingr8   s     r   convertz$Template.substitute.<locals>.convertn   s    HHW%;();E 75>**xx	".~~%xx	".b!B!\\+ +r   _sentinel_dict	_ChainMapr$   subr7   r8   rS   kwsrT   s   ``  r   
substitutezTemplate.substituteh   sA    n$GW-G
	+ ||77r   c                     t         u r|n|rt        |       fd} j                  j                  | j                        S )Nc                 T   | j                  d      xs | j                  d      }|	 t        |         S | j                  d      j                  S | j                  d      | j                         S t	        dj
                        # t        $ r | j                         cY S w xY wrL   )rQ   r   KeyErrorr*   rC   r$   rR   s     r   rT   z)Template.safe_substitute.<locals>.convert   s    HHW%;();E &wu~.. xx	".~~%xx	".xxz!B!\\+ +   &88:%&s   B B'&B'rU   rY   s   ``  r   safe_substitutezTemplate.safe_substitute{   sA    n$GW-G	+ ||77r   c                    | j                   j                  | j                        D ]`  }|j                  d       y|j                  d      (|j                  d      :|j                  d      Lt	        d| j                          y)Nr;   FrM   rN   rO   rP   T)r$   finditerr7   rQ   rC   )r8   rD   s     r   is_validzTemplate.is_valid   s    ,,''6 		"Bxx	".!)HHX&.HHY'/ !!FLL" "		" r   c                 N   g }| j                   j                  | j                        D ]z  }|j                  d      xs |j                  d      }|||vr|j	                  |       ?|B|j                  d      T|j                  d      ft        d| j                          |S )NrM   rN   r;   rO   rP   )r$   ra   r7   rQ   appendrC   )r8   idsrD   rM   s       r   get_identifierszTemplate.get_identifiers   s    ,,''6 	"BHHW%;();E U#%5

5!-HHY'/HHY'/ !!FLL" "	" 
r   )__name__
__module____qualname__r*   r+   r,   r(   
IGNORECASEr.   r&   r9   rI   rV   r[   r_   rb   rf   __classcell__)r4   s   @r   r   r   9   sN    8I
 )INNNED$!

* "0 8& '5 8*r   r   c                   F    e Zd Zd Zd Z	 ddZd Zd Zd Zd Z	d Z
d	 Zy
)r   c                (    | j                  |||      S r6   )vformat)r8   format_stringargskwargss       r   formatzFormatter.format   s    ||M488r   c                 p    t               }| j                  ||||d      \  }}| j                  |||       |S )N   )set_vformatcheck_unused_args)r8   ro   rp   rq   	used_argsresult_s          r   rn   zFormatter.vformat   s:    E	MM-vy!L	y$7r   c           	      $   |dk  rt        d      g }| j                  |      D ]  \  }}	}
}|r|j                  |       |	|	dk(  r |du rt        d      t        |      }	|dz  }n|	j	                         r|rt        d      d}| j                  |	||      \  }}|j                  |       | j                  ||      }| j                  |
||||dz
  |      \  }
}|j                  | j                  ||
              dj                  |      |fS )Nr   zMax string recursion exceededr>   FzJcannot switch from manual field specification to automatic field numberingr=   )auto_arg_index)rC   parserd   r   isdigit	get_fieldaddconvert_fieldrv   format_fieldr   )r8   ro   rp   rq   rx   recursion_depthr|   ry   literal_text
field_nameformat_spec
conversionobjarg_useds                 r   rv   zFormatter._vformat   sQ   Q<==

=),	C=L*k: l+ %
 #%.( *5 6 6 "%^!4J"a'N'')%( *5 6 6
 &+N !%z4 HXh' ((j9 /3mmvq0#1 /< /3+^ d//[ABY,	C\ wwv..r   c                 6    t        |t              r||   S ||   S r6   )
isinstanceint)r8   keyrp   rq   s       r   	get_valuezFormatter.get_value   s     c39#;r   c                      y r6    )r8   rx   rp   rq   s       r   rw   zFormatter.check_unused_args  s    r   c                     t        ||      S r6   )rr   )r8   valuer   s      r   r   zFormatter.format_field  s    e[))r   c                     ||S |dk(  rt        |      S |dk(  rt        |      S |dk(  rt        |      S t        dj	                  |            )Nr   raz"Unknown conversion specifier {0!s})r   reprasciirC   rr   )r8   r   r   s      r   r   zFormatter.convert_field  sZ    L3u:3;3<=DDZPQQr   c                 ,    t        j                  |      S r6   )_stringformatter_parser)r8   ro   s     r   r}   zFormatter.parse  s    ''66r   c                     t        j                  |      \  }}| j                  |||      }|D ]  \  }}|rt        ||      }||   } ||fS r6   )r   formatter_field_name_splitr   getattr)	r8   r   rp   rq   firstrestr   is_attrrE   s	            r   r   zFormatter.get_field(  s`    88DtnnUD&1  	JGQc1o!f		 Ezr   N)r   )rg   rh   ri   rr   rn   rv   r   rw   r   r   r}   r   r   r   r   r   r      s6    9 !"3/l*
R(7r   r   r6   )__all__r   r   r   r   r   r   r   r   r
   r	   r   rer(   collectionsr    rW   rV   r   r&   r   r   r   r   <module>r      s    2  
../1	X(		5]"[0:=	
@  -r rl 	   y yr   