a
    Š©lcÜ  ã                   @   sÜ   d dl Z d dlZd dlmZ d dlmZ d dlmZmZm	Z	 dZ
G dd„ deƒZdeeee d	œd
d„Zde	eef eeedœdd„Zedœdd„ZG dd„ deƒZeG dd„ deƒƒZedœdd„Zdeedœdd„ZdS ) é    N)Úliteral_eval)Útotal_ordering)Ú
NamedTupleÚSequenceÚUnion)úúúúúõ   Â…u   â€¨u   â€©c                   @   s&   e Zd ZU eed< eed< eed< dS )ÚVersionÚmajorÚminorÚmicroN©Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__© r   r   úG/var/www/html/django/DPS/env/lib/python3.9/site-packages/parso/utils.pyr      s   
r   F)ÚstringÚkeependsÚreturnc              	   C   sØ   |rÈ|   d¡}g }t|ƒD ]:\}}z|d }W n ty@   Y q0 |tv r| |¡ qt|ƒD ]>}z&|| ||d   ||< ||d = W q^ tyš   Y q^0 q^|  d¡sº|  d¡sº| dkrÄ| d¡ |S t d| ¡S dS )	a¯  
    Intended for Python code. In contrast to Python's :py:meth:`str.splitlines`,
    looks at form feeds and other special characters as normal text. Just
    splits ``\n`` and ``\r\n``.
    Also different: Returns ``[""]`` for an empty string input.

    In Python 2.7 form feeds are used as normal characters when using
    str.splitlines. However in Python 3 somewhere there was a decision to split
    also on form feeds.
    Téÿÿÿÿé   Ú
úÚ z
\n|\r\n|\rN)	Ú
splitlinesÚ	enumerateÚ
IndexErrorÚ_NON_LINE_BREAKSÚappendÚreversedÚendswithÚreÚsplit)r   r   ÚlstÚmergeÚiÚlineZlast_chrÚindexr   r   r   Úsplit_lines   s(    

r/   úutf-8Ústrict)ÚsourceÚencodingÚerrorsr   c                    sb   ‡ ‡fdd„}t ˆtƒrˆS |ƒ ‰ ztˆˆ |ƒW S  ty\   |dkrVtˆd|ƒ Y S ‚ Y n0 dS )aM  
    Checks for unicode BOMs and PEP 263 encoding declarations. Then returns a
    unicode object like in :py:meth:`bytes.decode`.

    :param encoding: See :py:meth:`bytes.decode` documentation.
    :param errors: See :py:meth:`bytes.decode` documentation. ``errors`` can be
        ``'strict'``, ``'replace'`` or ``'ignore'``.
    c                     sd   t dƒ} ˆ | ¡rdS t dˆ¡ d¡}t d|¡}|r\| d¡}t|tƒsXt|ddƒ}|S ˆ S d	S )
zà
        For the implementation of encoding definitions in Python, look at:
        - http://www.python.org/dev/peps/pep-0263/
        - http://docs.python.org/2/reference/lexical_analysis.html#encoding-declarations
        zb'\xef\xbb\xbf'r0   s   (?:[^\r\n]*(?:\r\n|\r|\n)){0,2}r   s   coding[=:]\s*([-\w.]+)r   ÚasciiÚreplaceN)r   Ú
startswithr(   ÚmatchÚgroupÚsearchÚ
isinstanceÚstr)Z	byte_markZfirst_two_linesZpossible_encodingÚe©r3   r2   r   r   Údetect_encodingT   s    
ÿ

z0python_bytes_to_unicode.<locals>.detect_encodingr6   r0   N)r;   r<   ÚLookupError)r2   r3   r4   r?   r   r>   r   Úpython_bytes_to_unicodeI   s    
rA   )r   c                  C   s.   ddl m}  t d| ¡}tdd„ t|ƒD ƒŽ S )z`
    Returns a namedtuple of parso's version, similar to Python's
    ``sys.version_info``.
    r   )Ú__version__z
[a-z]+|\d+c                 S   s$   g | ]\}}|d kr|nt |ƒ‘qS )é   )r   )Ú.0r,   Úxr   r   r   Ú
<listcomp>„   ó    z version_info.<locals>.<listcomp>)ZparsorB   r(   Úfindallr   r"   )rB   Ztuplr   r   r   Úversion_info}   s    rI   c                   @   s   e Zd ZU eed< eed< dS )Ú_PythonVersionInfor   r   Nr   r   r   r   r   rJ   ‡   s   
rJ   c                       s0   e Zd Z‡ fdd„Z‡ fdd„Zdd„ Z‡  ZS )ÚPythonVersionInfoc                    sF   t |tƒr.t|ƒdkrtdƒ‚| j| jf|kS tƒ  |¡ | j| jfS ©Né   z'Can only compare to tuples of length 2.)r;   ÚtupleÚlenÚ
ValueErrorr   r   ÚsuperÚ__gt__©ÚselfÚother©Ú	__class__r   r   rR   Ž   s    
zPythonVersionInfo.__gt__c                    s>   t |tƒr.t|ƒdkrtdƒ‚| j| jf|kS tƒ  |¡ d S rL   )r;   rN   rO   rP   r   r   rQ   Ú__eq__rS   rV   r   r   rX   —   s
    
zPythonVersionInfo.__eq__c                 C   s   |   |¡ S )N)rX   rS   r   r   r   Ú__ne__ž   s    zPythonVersionInfo.__ne__)r   r   r   rR   rX   rY   Ú__classcell__r   r   rV   r   rK   Œ   s   	rK   c                 C   sr   t  d| ¡}|d u rtdƒ‚t| d¡ƒ}| d¡}|d u r`|dkrJd}n|dkrXd}ntdƒ‚t|ƒ}t||ƒS )	Nz-(\d+)(?:\.(\d{1,2})(?:\.\d+)?)?((a|b|rc)\d)?$zNThe given version is not in the right format. Use something like "3.8" or "3".r   rM   Ú7rC   Ú6z7Sorry, no support yet for those fancy new/old versions.)r(   r8   rP   r   r9   ÚNotImplementedErrorrK   )Úversionr8   r   r   r   r   r   Ú_parse_version¢   s    
r_   )r^   r   c                 C   s4   | du rdt jdd…  } t| tƒs,tdƒ‚t| ƒS )z«
    Checks for a valid version number (e.g. `3.8` or `3.10.1` or `3`) and
    returns a corresponding version info that is always two characters long in
    decimal.
    Nz%s.%srM   z#version must be a string like "3.8")ÚsysrI   r;   r<   Ú	TypeErrorr_   )r^   r   r   r   Úparse_version_string·   s
    
rb   )F)r0   r1   )N)r(   r`   Úastr   Ú	functoolsr   Útypingr   r   r   r$   r   r<   Úboolr/   ÚbytesrA   rI   rJ   rK   r_   rb   r   r   r   r   Ú<module>   s$   - ÿþ4
