K i ddlZddlZddlmZddlmZddlmZmZm Z dZ GddeZ dde d e d ee fd Z dd e e efd e de d e fdZd e fdZGddeZeGddeZd efdZdde d efdZy)N) literal_eval)total_ordering) NamedTupleSequenceUnion)  …u
u
c,eZdZUeed<eed<eed<y)VersionmajorminormicroN__name__ __module__ __qualname__int__annotations__Q/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/parso/utils.pyrrs J J Jrrstringkeependsreturnc|r|jd}g}t|D]%\}} |d}|tvs|j|'t |D]} ||||dzz||<||dz=|j ds|j ds|dk(r|jd|Stjd|S#t$rYwxYw#t$rYwxYw)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_BREAKSappend IndexErrorreversedendswithresplit)rrlstmergeilinelast_chrindexs r split_linesr4s% ~ $GAt $8//LLO $e_ E  Z#eai.8E  N  ??4 FOOD$9Vr\ JJrN xx v..-    s#CC C  C  CCsourceencodingerrorscfd}ttrS| t|S#t$r|dk(rtd|cYSwxYw)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'``. ctd}j|rytjdj d}tj d|}|r0|j d}t |ts t|dd}|SS) 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 zb'\xef\xbb\xbf'utf-8s(?:[^\r\n]*(?:\r\n|\r|\n)){0,2}rscoding[=:]\s*([-\w.]+)r!asciireplace)r startswithr,matchgroupsearch isinstancestr) byte_markfirst_two_linespossible_encodinger6r5s rdetect_encodingz0python_bytes_to_unicode..detect_encodingTs !!34   Y '((#FOUUVWXII&@&57 !''*Aa%7I.HOrr<r:)rArB LookupError)r5r6r7rGs`` rpython_bytes_to_unicoderIIs`.&#  H 68V,,  Y  vw/ / s 0A Ac ddlm}tjd|}t t |Dcgc]\}}|dk(r|n t |c}}Scc}}w)z` Returns a namedtuple of parso's version, similar to Python's ``sys.version_info``. r) __version__z [a-z]+|\d+)parsorKr,findallrr&r)rKtuplr0xs r version_inforQ}sG " ::m[ 1D 4IA!q&Qc!f,I JJIsA c"eZdZUeed<eed<y)_PythonVersionInforrNrrrrrSrSs J JrrSc.eZdZfdZfdZdZxZS)PythonVersionInfoct|tr4t|dk7r td|j|j f|kDSt |||j|j fSNz'Can only compare to tuples of length 2.)rAtuplelen ValueErrorrrsuper__gt__selfother __class__s rr]zPythonVersionInfo.__gt__s[ eU #5zQ !JKKJJ +e3 3 u DJJ''rct|tr4t|dk7r td|j|j f|k(St ||yrW)rArYrZr[rrr\__eq__r^s rrczPythonVersionInfo.__eq__sH eU #5zQ !JKKJJ +u4 4 urc&|j| SN)rc)r_r`s r__ne__zPythonVersionInfo.__ne__s;;u%%%r)rrrr]rcrf __classcell__)ras@rrUrUs(&rrUctjd|}| tdt|j d}|j d}||dk(rd}n|dk(rd}n t dt|}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!rX7rL6z7Sorry, no support yet for those fancy new/old versions.)r,r>r[rr?NotImplementedErrorrU)versionr>rrs r_parse_versionrms HHEw OE }<= =  A E KKNE } A:E aZE%&_` ` JE UE **rrlc~|dtjddz}t|ts t dt |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.%srXz#version must be a string like "3.8")sysrQrArB TypeErrorrm)rls rparse_version_stringrqsA C,,Ra00 gs #=>> ' ""r)F)r:strictre)r,roastr functoolsrtypingrrrr'rrBboolr4bytesrIrQrSrUrmrqrrrrxs $.. j )/)/t)/ )/ZGO1 #u* 1),1@C11hKgK &*&&*+0+* ## #1B #r