o
    œ¨Êh×  ã                   @   s”   d Z ddlZddlZddlZejd dkZer dd„ Zdd„ Zndd„ Zd	d„ Zeed
dƒp2eedƒej	 Z
dZdd„ Zdd„ Zdd„ Zdd„ ZdS )zn
escape/unescape routines available for backends which need
alphanumeric usernames, services, or other values
é    Né   c                 C   s   | S ©N© ©Úsr   r   úE/var/www/html/env/lib/python3.10/site-packages/keyring/util/escape.pyÚu   s   r   c                 C   ó   t | ƒS r   )Úchr©Úcr   r   r   Ú_unichr   ó   r   c                 C   s
   |   d¡S )Núutf-8)Údecoder   r   r   r   r      s   
c                 C   r	   r   )Úunichrr   r   r   r   r      r   ÚlettersÚascii_lettersz_%02Xc                 C   s*   t | tƒr	t| ƒ} | tv r| S tt| ƒ S )zASingle char escape. Return the char, escaped if not already legal)Ú
isinstanceÚintr   ÚLEGAL_CHARSÚ
ESCAPE_FMTÚordr   r   r   r   Ú_escape_char$   s   
r   c                 C   s   d  dd„ |  d¡D ƒ¡S )zd
    Escapes given string so the result consists of alphanumeric chars and
    underscore only.
    Ú c                 s   s   � | ]}t |ƒV  qd S r   )r   )Ú.0r   r   r   r   Ú	<genexpr>0   s   € zescape.<locals>.<genexpr>r   )ÚjoinÚencode)Úvaluer   r   r   Úescape+   s   r    c                 C   s,   t |  d¡dƒ}tjdkrt|gƒS t|ƒS )NÚcodeé   )r   )r   ÚgroupÚsysÚversion_infoÚbytesr
   )Úregex_matchÚordinalr   r   r   Ú_unescape_code3   s   

r)   c                 C   s0   t  t dd¡ d¡¡}| t|  d¡¡ d¡S )z
    Inverse of escape.
    z%02Xz(?P<code>[0-9A-Fa-f]{2})Úasciir   )ÚreÚcompiler   Úreplacer   Úsubr)   r   )r   Úre_escr   r   r   Úunescape:   s   þr0   )Ú__doc__r+   Ústringr$   r%   ÚPY3r   r   ÚgetattrÚdigitsr   r   r   r    r)   r0   r   r   r   r   Ú<module>   s&    
ý