a
    ,º]ì  ã                   @   sz   d Z ddlmZ ddlmZmZ er2ddlmZ nddlmZ e	Z
G dd„ deƒZdd„ ZG d	d
„ d
eee
ƒƒZd
gZdS )zH
Pure-Python implementation of a Python 2-like str object for Python 3.
é    )ÚIntegral)ÚPY2Úwith_metaclass)ÚIterablec                   @   s   e Zd Zdd„ ZdS )Ú
BaseOldStrc                 C   s
   t |tƒS ©N)Ú
isinstanceÚ_builtin_bytes)ÚclsÚinstance© r   úb/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/past/types/oldstr.pyÚ__instancecheck__   s    zBaseOldStr.__instancecheck__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   c                 C   s   |   ¡  d¡S )zî
    Interprets strings with escape sequences

    Example:
    >>> s = unescape(r'abc\def')   # i.e. 'abc\\def'
    >>> print(s)
    'abc\def'
    >>> s2 = unescape('abc\ndef')
    >>> len(s2)
    8
    >>> print(s2)
    abc
    def
    Úunicode_escape)ÚencodeÚdecode)Úsr   r   r   Úunescape   s    r   c                       sd   e Zd ZdZedd„ ƒZdd„ Z‡ fdd„Z‡ fdd	„Z‡ fd
d„Z	dd„ Z
dd„ Zdd„ Z‡  ZS )ÚoldstrzC
    A forward port of the Python 2 8-bit string object to Py3
    c                 C   s   t ‚d S r   )ÚAttributeError©Úselfr   r   r   Ú__iter__-   s    zoldstr.__iter__c                 C   s   dd„ t tƒD ƒS )Nc                 S   s   g | ]}|d kr|‘qS )r   r   )Ú.0Úthingr   r   r   Ú
<listcomp>2   ó    z"oldstr.__dir__.<locals>.<listcomp>)Údirr	   r   r   r   r   Ú__dir__1   s    zoldstr.__dir__c                    s   t t| ƒ ¡ }|dd … S ©Né   )Úsuperr   Ú__repr__©r   r   ©Ú	__class__r   r   r%   l   s    zoldstr.__repr__c                    s>   t t| ƒ ¡ }|d d… dkr*|d dks.J ‚t|dd… ƒS )Né   zb'éÿÿÿÿú')r$   r   Ú__str__r   r&   r'   r   r   r,   p   s     zoldstr.__str__c                    s8   t |tƒr$tt| ƒ t||d ƒ¡S tt| ƒ |¡S d S r"   )r   r   r$   r   Ú__getitem__Úslice)r   Úyr'   r   r   r-   v   s    
zoldstr.__getitem__c                 G   s   |   t|Ž ¡S r   )r-   r.   )r   Úargsr   r   r   Ú__getslice__|   s    zoldstr.__getslice__c                 C   s   t |tƒrdS d S )NF)r   Úint)r   Úkeyr   r   r   Ú__contains__   s    
zoldstr.__contains__c                 C   s   t | ƒS r   )Úbytesr   r   r   r   Ú
__native__ƒ   s    zoldstr.__native__)r   r   r   Ú__doc__Úpropertyr   r!   r%   r,   r-   r1   r4   r6   Ú__classcell__r   r   r'   r   r   (   s   
;r   N)r7   Únumbersr   Z
past.utilsr   r   Úcollectionsr   Úcollections.abcr5   r	   Útyper   r   r   Ú__all__r   r   r   r   Ú<module>   s   _