Files
intellecton/venv/lib/python3.12/site-packages/pygments/__pycache__/util.cpython-312.pyc
T

140 lines
14 KiB
Plaintext
Raw Normal View History

Ë
j>'ãódZddlZddlmZejd«Zejdej ejzejz«Z ejdejej zejz«Z ejdej«Z
Gdd e«ZGd
d e«Zd d Zd!d
Zd!dZd!dZdZdZdZdZdZiZdZdZd"dZd#dZGdd«Z dZ!dZ"dZ#Gdde«Z$y)$z´
pygments.util
~~~~~~~~~~~~~
Utility functions.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
éN)Ú
TextIOWrapperz[/\\ ]z”
<!DOCTYPE\s+(
[a-zA-Z_][a-zA-Z0-9]*
(?: \s+ # optional in HTML5
[a-zA-Z_][a-zA-Z0-9]*\s+
"[^"]*")?
)
[^>]*>
z<(.+?)(\s.*?)?>.*?</.+?>z\s*<\?xml[^>]*\?>cóeZdZdZy)Ú
ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__©óúP/home/antigravity/intellecton/venv/lib/python3.12/site-packages/pygments/util.pyrrsÚMr rcóeZdZdZy)Ú OptionErrorzƒ
This exception will be raised by all option processing functions if
the type or value of the argument is not correct.
Nrr r r
rr"sòr rc óÆ|j||«}|r|j«}||vr8tdj|dj t t |««««|S)z}
If the key `optname` from the dictionary is not in the sequence
`allowed`, raise an error, otherwise return it.
z%Value for option {} must be one of {}z, )ÚgetÚlowerrÚformatÚjoinÚmapÚstr)ÚoptionsÚoptnameÚallowedÚdefaultÚnormcaseÚstrings r
Úget_choice_optr(s^ð
[‰[˜ 
*€FÙØˆØ
ÜÐA×ÐRV×R[ÑR[Ô\_Ô`cÐelÓ\mÓRnÓ €Mr có4|j||«}t|t«r|St|t«r t|«St|t«st d|d|d«|j
«dvry|j
«dvryt d|d|d«) a@
Intuitively, this is `options.get(optname, default)`, but restricted to
Boolean value. The Booleans can be represented as string, in order to accept
Boolean value from the command line arguments. If the key `optname` is
present in the dictionary `options` and is not associated with a Boolean,
raise an `OptionError`. If it is absent, `default` is returned instead.
The valid string values for ``True`` are ``1``, ``yes``, ``true`` and
``on``, the ones for ``False`` are ``0``, ``no``, ``false`` and ``off``
(matched case-insensitively).
ú
Invalid type ú for option z%; use 1/0, yes/no, true/false, on/off)ÚyesÚtrueÚonT)ÚnoÚfalseÚoffFúInvalid value )rÚ
isinstanceÚboolÚintrrr©rrrrs r
Ú get_bool_optr.5s­ð[‰[˜ 
*€FÜ&œ$ÔØˆ
Ü FœCÔ ÜF‹|ÐÜ
˜¤Ô
˜M¨&¨°<À¸IÐ5Ñ 5ØØ Ð6Ñ 6Øä˜N¨6¨*°LÀÀ ðJ =r có°|j||«} t|«S#t$rtd|d|d«t$rtd|d|d«wxYw)z?As :func:`get_bool_opt`, but interpret the value as an integer.rr z ; you must give an integer valuer))rr,Ú TypeErrorrÚ
ValueErrorr-s r
Ú get_int_optr2Rs€à
[‰[˜ 
*€Fð6‹{ÐøÜ ò˜M¨&¨°<À¸I ò˜N¨6¨*°LÀÀ ðJ8ús
Ÿ6AcóÌ|j||«}t|t«r|j«St|tt
f«r t |«St
d|d|d«)
If the key `optname` from the dictionary `options` is a string,
split it at whitespace and return it. If it is already a list
or a tuple, it is returned as a list.
rr z; you must give a list value)rr*rÚsplitÚlistÚtupler)rrrÚvals r
Ú get_list_optr8^sfð +‰+g˜
'€CÜ#”sÔØy‰y‹{ÐÜ Cœ$¤˜Ô 'ÜC‹yÐä˜M¨#¨° ¸W¸IðF 4r có |jsyg}|jj«j«D]6}|j«r#|jd|j«z«Œ6ndj |«j «S)ú )r
ÚstripÚ
splitlinesÚappendrÚlstrip)ÚobjÚresÚlines r
Údocstring_headlinerCnsrØ ;Š;ØØ
€CØ ×ˆØ :‰:Œ<Ø J‰Js˜TŸZ™Z ð ð
7‰73<× Ñ Ó Ð r cóFˆfd}j|_t|«S)zAReturn a static text analyser function that returns float values.c ó¤ |«}|sy tdtdt|«««S#t$rYywxYw#tt
f$rYywxYw)Nggð?)Ú ExceptionÚminÚmaxÚfloatr1r0)ÚtextÚrvÚfs €r
Ú text_analysez%make_analysator.<locals>.text_analyse|sbø€ð Ù4“ˆBñØð ÜsœC ¤U¨2£YÓ 0øô ò Ùð ûô œIÐ Ùð úsƒ.=® :¹:½AÁA)r
Ú staticmethod)rLrMs` r
Úmake_analysatorrOzs!ø€ô
ðŸ9™9€LÔÜ ˜ Ó %r cóÌ|jd«}|dk\r|d|j«}n|j«}|jd«r… tj |ddj ««Dcgc]}|r|jd«s|Œc}d}tjd |d
tj«}|j|«y ycc}w#t $rYywxYw) Check if the given regular expression matches the last part of the
shebang if one exists.
>>> from pygments.util import shebang_matches
>>> shebang_matches('#!/usr/bin/env python', r'python(2\.\d)?')
True
>>> shebang_matches('#!/usr/bin/python2.4', r'python(2\.\d)?')
True
>>> shebang_matches('#!/usr/bin/python-ruby', r'python(2\.\d)?')
False
>>> shebang_matches('#!/usr/bin/python/ruby', r'python(2\.\d)?')
False
>>> shebang_matches('#!/usr/bin/startsomethingwith python',
... r'python(2\.\d)?')
True
It also checks for common windows executable file extensions::
>>> shebang_matches('#!C:\\Python2.4\\Python.exe', r'python(2\.\d)?')
True
Parameters (``'-f'`` or ``'--foo'`` are ignored so ``'perl'`` does
the same as ``'perl -e'``)
Note that this method automatically searches the whole string (eg:
the regular expression is wrapped in ``'^$'``)
ú
rNz#!éú-éÿÿÿÿFú^z(\.(exe|cmd|bat|bin))?$T) ÚfindrÚ
startswithÚ
split_path_rer4r<Ú
IndexErrorÚreÚcompileÚ
IGNORECASEÚsearch)rJÚregexÚindexÚ
first_lineÚfounds r
Úshebang_matchesrcð8
I‰IdO€EØ ˜&˜5\×)‰
à—ZZ“\ˆ
Ø×ј Ü -× 3Ñ 3°J¸q¸r°N×4HÑ4HÓ4JÓ Kö5˜ !§,¡,¨sÔ"3òò5Ø57ñ9ˆ
˜a ˜wÐ&=ÐÇ
Á
ÓNˆØ <‰<˜Ó Ð Ø ùò5øäò Ùð ús$Á
(CÁ5CÂCÃCÃ C#Ã"C#cóÚtj|«}|y|jd«}tj|tj
«j
|j««duS)zÁCheck if the doctype matches a regular expression (if present).
Note that this method only checks the first part of a DOCTYPE.
eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
NFé)Údoctype_lookup_rer]ÚgrouprZr[Úmatchr<)rJr^Údoctypes r
Údoctype_matchesrl¸sTô × Ñ  Ó&€AØ€yØØg‰ga‹j€GÜ
:‰:eœRŸT™TÓ ¯©«Ó Ð Er cót|d«S)z3Check if the file looks like it has a html doctype.Úhtml)rl)rJs r
Úhtml_doctype_matchesroÅsä ˜4 Ó )r cóòtj|«ryt|«} t|S#t$rAt
j
|«}|Yytj
|dd«du}|t|<|cYSwxYw)z2Check if a doctype exists or if we have some tags.TNiè)Ú xml_decl_reriÚhashÚ_looks_like_xml_cacheÚKeyErrorrfr]Útag_re)rJÚkeyrjrKs r
Úlooks_like_xmlrwÍs|ä×Ñ˜ÔØÜ
ˆt‹*€CðÜ$ SÑ)øÜ òÜ × $ TÓ Ø ˆ=ÙÜ
]‰]˜4  ˜
'¨tÐ
3ˆØ%'Ô˜Š ð
ús£,¬ A6Á%A6Á5A6có"d|dz zd|dzzfS)zoGiven a unicode character code with length greater than 16 bits,
return the two 16 bit surrogate pair.
iÀ×é
iÜiÿr )Úcs r