
    f              	           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e      Zdded	ed
ee   fdZ	 dde	eef   deded
efdZd
efdZ G d de      Ze G d de             Zd
efdZdded
efdZy)    N)literal_eval)total_ordering)
NamedTupleSequenceUnion)   u    u    c                   ,    e Zd ZU eed<   eed<   eed<   y)VersionmajorminormicroN__name__
__module____qualname__int__annotations__     F/var/www/cvtools/html/venv/lib/python3.12/site-packages/parso/utils.pyr   r      s    JJJr   r   stringkeependsreturnc                    |r| j                  d      }g }t        |      D ]%  \  }}	 |d   }|t        v s|j                  |       ' t        |      D ]  }	 ||   ||dz      z   ||<   ||dz   =  | j                  d      s| j                  d      s| dk(  r|j                  d       |S t        j                  d|       S # t        $ r Y w xY w# t        $ r Y w xY w)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|\r)	
splitlines	enumerate_NON_LINE_BREAKSappend
IndexErrorreversedendswithresplit)r   r   lstmergeilinelast_chrindexs           r   split_linesr4      s    %  ~ 	$GAt$8 //LLO	$ e_ 	E Z#eai.8E
	N	 ??4 FOOD$9Vr\JJrN
xxv..-     s#   CC	CC	CCsourceencodingerrorsc                       fd}t         t              r S  |       	 t         |      S # t        $ r |dk(  rt         d|      cY S  w xY w)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                     t        d      } j                  |       ryt        j                  d      j	                  d      }t        j
                  d|      }|r0|j	                  d      }t        |t              st        |dd      }|S 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'utf-8s   (?:[^\r\n]*(?:\r\n|\r|\n)){0,2}r   s   coding[=:]\s*([-\w.]+)r!   asciireplace)r   
startswithr,   matchgroupsearch
isinstancestr)	byte_markfirst_two_linespossible_encodinger6   r5   s       r   detect_encodingz0python_bytes_to_unicode.<locals>.detect_encodingT   s     !!34	Y'((#FOUUVWXII&@&57!''*Aa%7I.H Or   r<   r:   )rA   rB   LookupError)r5   r6   r7   rG   s   ``  r   python_bytes_to_unicoderI   I   s`    . &# H
68V,, Y
 vw//s   0 AAc            	          ddl m}  t        j                  d|       }t	        t        |      D cg c]  \  }}|dk(  r|n
t        |       c}} S c c}}w )z`
    Returns a namedtuple of parso's version, similar to Python's
    ``sys.version_info``.
    r   )__version__z
[a-z]+|\d+   )parsorK   r,   findallr   r&   r   )rK   tuplr0   xs       r   version_inforQ   }   sG    
 "::m[1D4IA!q&Qc!f,IJJIs   A
c                   "    e Zd ZU eed<   eed<   y)_PythonVersionInfor   r   Nr   r   r   r   rS   rS      s    JJr   rS   c                   .     e Zd Z fdZ fdZd Z xZS )PythonVersionInfoc                     t        |t              r4t        |      dk7  rt        d      | j                  | j
                  f|kD  S t        |   |       | j                  | j
                  fS N   z'Can only compare to tuples of length 2.)rA   tuplelen
ValueErrorr   r   super__gt__selfother	__class__s     r   r]   zPythonVersionInfo.__gt__   s[    eU#5zQ !JKKJJ

+e33u

DJJ''r   c                     t        |t              r4t        |      dk7  rt        d      | j                  | j
                  f|k(  S t        |   |       y rW   )rA   rY   rZ   r[   r   r   r\   __eq__r^   s     r   rc   zPythonVersionInfo.__eq__   sH    eU#5zQ !JKKJJ

+u44ur   c                 &    | j                  |       S N)rc   )r_   r`   s     r   __ne__zPythonVersionInfo.__ne__   s    ;;u%%%r   )r   r   r   r]   rc   rf   __classcell__)ra   s   @r   rU   rU      s    (&r   rU   c                    t        j                  d|       }|t        d      t        |j	                  d            }|j	                  d      }||dk(  rd}n|dk(  rd}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!   rX   7rL   6z7Sorry, no support yet for those fancy new/old versions.)r,   r>   r[   r   r?   NotImplementedErrorrU   )versionr>   r   r   s       r   _parse_versionrm      s    HHEwOE} < = 	= AEKKNE} A:EaZE%&_``JEUE**r   rl   c                 ~    | dt         j                  dd z  } 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.%srX   z#version must be a string like "3.8")sysrQ   rA   rB   	TypeErrorrm   )rl   s    r   parse_version_stringrq      sA     C,,Ra00gs#=>>'""r   )F)r:   strictre   )r,   ro   astr   	functoolsr   typingr   r   r   r'   r   rB   boolr4   bytesrI   rQ   rS   rU   rm   rq   r   r   r   <module>rx      s    	 
  $ . .

 j )/ )/t )/ )/Z GO1#u*1),1@C11hKg K 
 &* & &*+0 +*## #1B #r   