o
    ÒmÆif	  ã                	   @  s¬   d Z ddlmZ ddlZddlZddlZddlmZ d&dd„Zdd	„ Z	d
d„ Z
eZdd„ Ze d¡Zdd„ Zdd„ ZdddddddddœZd'd d!„Ze d"¡Zd(d$d%„ZdS ))zn
Utility functions and objects to ease Python 2/3 compatibility,
and different versions of support libraries.
é    )ÚannotationsN)ÚMatchúutf-8c                 C  s   t | tƒr
|  |¡S | S )N)Ú
isinstanceÚstrÚencode)ÚsÚenc© r
   úG/home/kim/smarthome/.venv/lib/python3.10/site-packages/rdflib/compat.pyÚ
cast_bytes   s   

r   c                 C  s   t  d¡| ƒS )NÚascii)ÚcodecsÚ	getreader)Ústreamr
   r
   r   r      s   r   c                  O  s   t | ddi|¤ŽS )NÚmodeÚrb)Úopen)ÚargsÚkwargsr
   r
   r   Úbopen   s   r   c                 C  s   | dk rdS | dkrdS dS )Nr   éÿÿÿÿé   r
   )Únr
   r
   r   Úsign    s
   r   z%(\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})c                 C  s   t  dd„ | ¡S )Nc                 S  s   t t|  d¡dd … dƒƒS )Nr   é   é   )ÚchrÚintÚgroup)Úmr
   r
   r   Ú<lambda>,   s    z _unicodeExpand.<locals>.<lambda>)Úr_unicodeEscapeÚsub©r   r
   r
   r   Ú_unicodeExpand+   s   r%   c                 C  st   t  tdƒ¡ 	 |  dd¡} |  dd¡} |  dd¡} |  dd	¡} |  d
d¡} |  dd¡} |  dd¡} |  dd¡} | S )NzÍrdflib.compat.decodeStringEscape() is deprecated, it will be removed in rdflib 7.0.0. This function is not used anywhere in rdflib anymore and the utility that it does provide is not implemented correctly.z\tú	z\nÚ
z\rúz\búz\fúz\"ú"z\'ú'z\\ú\)ÚwarningsÚwarnÚDeprecationWarningÚreplacer$   r
   r
   r   ÚdecodeStringEscape/   s   ÿÿr2   r&   r)   r'   r(   r*   r+   r,   r-   )ÚtÚbr   ÚrÚfr+   r,   r-   Úmatchú
Match[str]Úreturnr   c                 C  s2   |   ¡ \}}|d urt| S tt|dd … dƒƒS )Nr   r   )ÚgroupsÚ_string_escape_mapr   r   )r7   ZsmatchZumatchr
   r
   r   Ú_turtle_escape_subberU   s   r<   z5\\(?:([tbnrf"'\\])|(u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}))Úescapedc                 C  s   d| vr| S t  t| ¡S )Nr-   )Ú_turtle_escape_patternr#   r<   )r=   r
   r
   r   ÚdecodeUnicodeEscapeb   s   r?   )r   )r7   r8   r9   r   )r=   r   r9   r   )Ú__doc__Ú
__future__r   r   Úrer.   Útypingr   r   r   r   r   Z	long_typer   Úcompiler"   r%   r2   r;   r<   r>   r?   r
   r
   r
   r   Ú<module>   s8    

ø
ÿ