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

140 lines
14 KiB
Plaintext
Raw Normal View History

<EFBFBD>
<00><16>i/'<00><00><00>dZddlZddlmZejd<04>Zejdej ejzejz<00>Z ejdejej zejz<00>Z ejdej<00>Z Gd<08>d e<0E>ZGd
<EFBFBD>d e<10>Zd d <0C>Zd!d <0A>Zd!d<0E>Zd!d<0F>Zd<10>Zd<11>Zd<12>Zd<13>Zd<14>ZiZd<15>Zd<16>Zd"d<17>Zd#d<18>ZGd<19>d<1A>Z d<1B>Z!d<1C>Z"d<1D>Z#Gd<1E>de<03>Z$y)$z<>
pygments.util
~~~~~~~~~~~~~
Utility functions.
:copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
<EFBFBD>N)<01> 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<00><00>eZdZdZy)<03> ClassNotFoundzCRaised if one of the lookup functions didn't find a matching class.N<><04>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F><00><00>S/home/daniel/Projects/tamigo-cli/venv/lib/python3.12/site-packages/pygments/util.pyrrs<00><00>Mr rc<00><00>eZdZdZy)<03> OptionErrorz<72>
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<00><00>r rc <00><><00>|j||<03>}|r|j<00>}||vr8tdj|dj t t |<02><00><00><00><00>|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, )<07>get<65>lowerr<00>format<61>join<69>map<61>str)<06>options<6E>optname<6D>allowed<65>default<6C>normcase<73>strings r <00>get_choice_optr(s^<00><00>
<15>[<5B>[<5B><17>'<27> *<2A>F<EFBFBD><0F><17><1C><1C><1E><06> <0A>W<EFBFBD><1C><19>A<>H<>H<><17>RV<52>R[<5B>R[<5B>\_<>`c<>el<65>\m<>Rn<52>o<>p<>p<> <11>Mr c<00>4<00>|j||<02>}t|t<00>r|St|t<00>r t|<03>St|t<00>st d|<03>d|<01>d<03><05><00>|j <00>dvry|j <00>dvryt d|<03>d|<01>d<03><05><00>) 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).
<20> Invalid type <20> for option z%; use 1/0, yes/no, true/false, on/off)<04>1<>yes<65>true<75>onT)<04>0<>no<6E>false<73>offF<66>Invalid value )r<00>
isinstance<EFBFBD>bool<6F>intrrr<00>rrrrs r <00> get_bool_optr.5s<><00><00><15>[<5B>[<5B><17>'<27> *<2A>F<EFBFBD><11>&<26>$<24><1F><15> <0A> <13>F<EFBFBD>C<EFBFBD> <20><13>F<EFBFBD>|<7C><1B> <17><06><03> $<24><19>M<EFBFBD>&<26><1A><<3C><07>y<EFBFBD>I<<3C><<3C>=<3D> =<3D> <0F><1C><1C><1E>5<> 5<><13> <0F><1C><1C><1E>6<> 6<><14><19>N<EFBFBD>6<EFBFBD>*<2A>L<EFBFBD><17> <09>J<<3C><<3C>=<3D> =r c<00><><00>|j||<02>} t|<03>S#t$rtd|<03>d|<01>d<03><05><00>t$rtd|<03>d|<01>d<03><05><00>wxYw)z?As :func:`get_bool_opt`, but interpret the value as an integer.rr z ; you must give an integer valuer))rr,<00> TypeErrorr<00>
ValueErrorr-s r <00> get_int_optr2Rs<><00><00> <14>[<5B>[<5B><17>'<27> *<2A>F<EFBFBD>8<><12>6<EFBFBD>{<7B><1A><> <14>8<><19>M<EFBFBD>&<26><1A><<3C><07>y<EFBFBD>I7<>7<>8<> 8<> <15>8<><19>N<EFBFBD>6<EFBFBD>*<2A>L<EFBFBD><17> <09>J7<>7<>8<> 8<>8<>s <00>
<00>6Ac<00><><00>|j||<02>}t|t<00>r|j<00>St|tt
f<02>r t |<03>St d|<03>d|<01>d<03><05><00>)z<>
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<00>split<69>list<73>tupler)rrr<00>vals r <00> get_list_optr8^sf<00><00> <12>+<2B>+<2B>g<EFBFBD>w<EFBFBD>
'<27>C<EFBFBD><11>#<23>s<EFBFBD><1B><12>y<EFBFBD>y<EFBFBD>{<7B><1A> <13>C<EFBFBD>$<24><05><1D> '<27><13>C<EFBFBD>y<EFBFBD><18><19>M<EFBFBD>#<23><17> <0C>W<EFBFBD>I<EFBFBD>F3<>3<>4<> 4r c<00> <00>|jsyg}|jj<00>j<00>D]6}|j<00>r#|jd|j<00>z<00><00>6ndj |<01>j <00>S)N<><00> )r
<00>strip<69>
splitlines<EFBFBD>appendr<00>lstrip)<03>obj<62>res<65>lines r <00>docstring_headlinerCnsr<00><00> <0E>;<3B>;<3B><11>
<0C>C<EFBFBD><13> <0B> <0B>!<21>!<21>#<23>.<2E>.<2E>0<><12><04> <0F>:<3A>:<3A><<3C> <0F>J<EFBFBD>J<EFBFBD>s<EFBFBD>T<EFBFBD>Z<EFBFBD>Z<EFBFBD>\<5C>)<29> *<2A> <11> <12>
<0E>7<EFBFBD>7<EFBFBD>3<EFBFBD><<3C> <1E> <1E> <20> r c<00>F<00><00><00>fd<01>}<01>j|_t|<01>S)zAReturn a static text analyser function that returns float values.c <00><><00><01> <00>|<00>}|sy tdtdt|<01><00><00>S#t$rYywxYw#tt
f$rYywxYw)Ngg<00>?)<06> Exception<6F>min<69>max<61>floatr1r0)<03>text<78>rv<72>fs <20>r <00> text_analysez%make_analysator.<locals>.text_analyse|sb<00><><00> <17><12>4<EFBFBD><17>B<EFBFBD><12><16> <17><16>s<EFBFBD>C<EFBFBD><03>U<EFBFBD>2<EFBFBD>Y<EFBFBD>/<2F>0<> 0<><30> <19> <17><16> <17><> <1B>I<EFBFBD>&<26> <17><16> <17>s<00>.<00>=<00> :<03>:<03>A<03>A)r
<00> staticmethod)rLrMs` r <00>make_analysatorrOzs!<00><><00>
<17><1D>9<EFBFBD>9<EFBFBD>L<EFBFBD><18> <17> <0C> %<25>%r c<00><><00>|jd<01>}|dk\r|d|j<00>}n|j<00>}|jd<04>r<> tj |ddj <00><00>D<00>cgc]}|r|jd<06>s|<04><02>c}d}tjd |<01>d
<EFBFBD>tj<00>}|j|<05><00>y ycc}w#t $rYywxYw) a<>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 ``'^$'``)
<20>
rNz#!<21><00>-<2D><><EFBFBD><EFBFBD><EFBFBD>F<EFBFBD>^z(\.(exe|cmd|bat|bin))?$T) <0B>findr<00>
startswith<EFBFBD> split_path_rer4r<<00>
IndexError<EFBFBD>re<72>compile<6C>
IGNORECASE<EFBFBD>search)rJ<00>regex<65>index<65>
first_line<EFBFBD>x<>founds r <00>shebang_matchesrc<00>s<><00><00>8 <11>I<EFBFBD>I<EFBFBD>d<EFBFBD>O<EFBFBD>E<EFBFBD> <0C><01>z<EFBFBD><19>&<26>5<EFBFBD>\<5C>'<27>'<27>)<29>
<EFBFBD><19>Z<EFBFBD>Z<EFBFBD>\<5C>
<EFBFBD><11><1C><1C>T<EFBFBD>"<22> <19> -<2D> 3<> 3<>J<EFBFBD>q<EFBFBD>r<EFBFBD>N<EFBFBD>4H<34>4H<34>4J<34> K<>5<>1<EFBFBD><19>!<21>,<2C>,<2C>s<EFBFBD>"3<><17>5<>57<35>9<>E<EFBFBD><13>
<EFBFBD>
<EFBFBD>a<EFBFBD><05>w<EFBFBD>&=<3D>><3E><02> <0A> <0A>N<><05> <10><<3C><<3C><05> <1E> *<2A><17> <10><>5<><35><19> <19><18> <19>s$<00> (C<00>5C<04>C<00>C<00> C#<03>"C#c<00><><00>tj|<00>}|<02>y|jd<03>}tj|tj
<00>j |j<00><00>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<4E>)<08>doctype_lookup_rer]<00>grouprZr[<00>I<>matchr<)rJr^<00>m<>doctypes r <00>doctype_matchesrl<00>sT<00><00> <1A> <20> <20><14>&<26>A<EFBFBD><08>y<EFBFBD><14><0F>g<EFBFBD>g<EFBFBD>a<EFBFBD>j<EFBFBD>G<EFBFBD> <0A>:<3A>:<3A>e<EFBFBD>R<EFBFBD>T<EFBFBD>T<EFBFBD> "<22> (<28> (<28><17><1D><1D><1F> 9<><14> E<>Er c<00><00>t|d<01>S)z3Check if the file looks like it has a html doctype.<2E>html)rl)rJs r <00>html_doctype_matchesro<00>s<00><00> <1A>4<EFBFBD><17> )<29>)r c<00><><00>tj|<00>ryt|<00>} t|S#t$rAt
j |<00>}|<02>Yytj |dd<00>du}|t|<|cYSwxYw)z2Check if a doctype exists or if we have some tags.TNi<4E>)<08> xml_decl_reri<00>hash<73>_looks_like_xml_cache<68>KeyErrorrfr]<00>tag_re)rJ<00>keyrjrKs r <00>looks_like_xmlrw<00>s|<00><00><12><18><18><14><1E><13>
<0E>t<EFBFBD>*<2A>C<EFBFBD><12>$<24>S<EFBFBD>)<29>)<29><> <13><12> <1D> $<24> $<24>T<EFBFBD> *<2A><01> <0C>=<3D><17> <13>]<5D>]<5D>4<EFBFBD><05><14>;<3B> '<27>t<EFBFBD> 3<><02>%'<27><1D>c<EFBFBD>"<22><11> <09> <12>s<00>,<00> A6<03>%A6<03>5A6c<00>"<00>d|dz zd|dzzfS)zoGiven a unicode character code with length greater than 16 bits,
return the two 16 bit surrogate pair.
i<><69><00>
i<00>i<>r )<01>cs r <00> surrogatepairr{<00>s!<00><00> <13>a<EFBFBD>2<EFBFBD>g<EFBFBD> <1E><16>1<EFBFBD>u<EFBFBD>9<EFBFBD>!5<> 7<>7r c<00>P<00>g}d|zdz}d|dzzdz}|j||zdz<00>|r|D]}|j||zdz<00><00>n5|D]0}t|dz<00>}|j||ddz|d zdz<00><00>2|j|d
z<00>d j|<04>S) z)Formats a sequence of strings for output.r;<00>rez = (<28>,<2C>"N<><4E><EFBFBD><EFBFBD><EFBFBD>rT<00>)rQ)r><00>reprr) <09>var_name<6D>seq<65>raw<61> indent_level<65>lines<65> base_indent<6E> inner_indent<6E>i<>rs r <00> format_linesr<73><00>s<><00><00> <0E>E<EFBFBD><15> <0C>$<24>q<EFBFBD>(<28>K<EFBFBD><16>,<2C><11>*<2A>+<2B>a<EFBFBD>/<2F>L<EFBFBD> <09>L<EFBFBD>L<EFBFBD><1B>x<EFBFBD>'<27>&<26>0<>1<>
<EFBFBD><14> 1<>A<EFBFBD> <11>L<EFBFBD>L<EFBFBD><1C><01>)<29>C<EFBFBD>/<2F> 0<> 1<><15> ><3E>A<EFBFBD><14>Q<EFBFBD><13>W<EFBFBD> <0A>A<EFBFBD> <11>L<EFBFBD>L<EFBFBD><1C><01>#<23>2<EFBFBD><06>.<2E><11>2<EFBFBD><15>6<><13><<3C> =<3D> ><3E>
<EFBFBD>L<EFBFBD>L<EFBFBD><1B>s<EFBFBD>"<22>#<23> <0F>9<EFBFBD>9<EFBFBD>U<EFBFBD> <1B>r c<00><><00>g}t<00>}|D]-}||vs||vr<01> |j|<04>|j|<04><00>/|S)za
Returns a list with duplicates removed from the iterable `it`.
Order is preserved.
)<03>setr><00>add)<05>it<69> already_seen<65>lst<73>seenr<6E>s r <00>duplicates_removedr<64><00>sM<00><00> <0A>C<EFBFBD> <0E>5<EFBFBD>D<EFBFBD> <0F><14><01> <0C><04>9<EFBFBD><01>\<5C>)<29> <14> <0B>
<EFBFBD>
<EFBFBD>1<EFBFBD> <0A> <0C><08><08><11> <0B> <14>
<0F>Jr c<00><00>eZdZdZd<02>Zy)<04>Futurez<65>Generic class to defer some work.
Handled specially in RegexLexerMeta, to support regex string construction at
first use.
c<00><00>t<00><01>N)<01>NotImplementedError<6F><01>selfs r rz
Future.gets<00><00>!<21>!r N)rrr r
rr r r r<>r<> s <00><00><08>
"r r<>c<00><><00> |jd<01>}|dfS#t$rX ddl}|j<00>}|j<00>}||fcYS#ttf$r|jd<04>}|dfcYcYSwxYwwxYw)z<>Decode *text* with guessed encoding.
First try UTF-8; this should fail for non-UTF-8 encodings.
Then try the preferred locale encoding.
Fall back to latin-1, which always works.
zutf-8rN<>latin1)<05>decode<64>UnicodeDecodeError<6F>locale<6C>getpreferredencoding<6E> LookupError)rJr<><00> prefencodings r <00> guess_decoder<65>s<><00><00> "<22><13>{<7B>{<7B>7<EFBFBD>#<23><04><13>W<EFBFBD>}<7D><1C><> <1D>"<22> "<22> <19>!<21>6<>6<>8<>L<EFBFBD><17>;<3B>;<3B>=<3D>D<EFBFBD><17><1C>%<25> %<25><>"<22>K<EFBFBD>0<> "<22><17>;<3B>;<3B>x<EFBFBD>(<28>D<EFBFBD><17><18>><3E> !<21> "<22><> "<22>s,<00><00> A8<03>'A <02>A8<03> $A4<05>/A8<03>3A4<05>4A8c<00><><00>t|dd<02>r* |j|j<00>}||jfSt |<00>S#t$r Yt |<00>SwxYw)z<>Decode *text* coming from terminal *term*.
First try the terminal encoding, if given.
Then try UTF-8. Then try the preferred locale encoding.
Fall back to latin-1, which always works.
<20>encodingN)<05>getattrr<72>r<>r<>r<>)rJ<00>terms r <00>guess_decode_from_terminalr<6C>(sd<00><00><0F>t<EFBFBD>Z<EFBFBD><14>&<26> '<27><17>;<3B>;<3B>t<EFBFBD>}<7D>}<7D>-<2D>D<EFBFBD><18><14><1D><1D>&<26> &<26> <17><04> <1D><1D><> "<22> <11> <10> <18><04> <1D><1D>  <11>s<00>A<00> A<03>Ac<00>\<00>t|dd<02>r |jSddl}|j<00>S)z7Return our best guess of encoding for the given *term*.r<>Nr)r<>r<>r<>r<>)r<>r<>s r <00>terminal_encodingr<67>9s*<00><00><0E>t<EFBFBD>Z<EFBFBD><14>&<26><13>}<7D>}<7D><1C><11> <11> &<26> &<26> (<28>(r c<00><00>eZdZd<01>Zy)<03>UnclosingTextIOWrapperc<00>$<00>|j<00>yr<>)<01>flushr<68>s r <00>closezUnclosingTextIOWrapper.closeCs <00><00> <0C>
<EFBFBD>
<EFBFBD> r N)rrr r<>r r r r<>r<>As<00><00>r r<>)NFr<46>)Fr)r )%r
rZ<00>iorr[rX<00>DOTALL<4C> MULTILINE<4E>VERBOSErfr\rurhrqr1rrFrrr.r2r8rCrOrcrlrorsrwr{r<>r<>r<>r<>r<>r<>r<>r r r <00><module>r<>s$<00><01><04>
<EFBFBD><1C><1B><02>
<EFBFBD>
<EFBFBD>9<EFBFBD>%<25> <0A><1E>B<EFBFBD>J<EFBFBD>J<EFBFBD> <04><08>Y<EFBFBD>Y<EFBFBD><12><1C><1C><1D><02>
<EFBFBD>
<EFBFBD>*<2A>,<2C><11>
<14><12><1A><1A>/<2F><16>M<EFBFBD>M<EFBFBD>B<EFBFBD>I<EFBFBD>I<EFBFBD>-<2D><02> <0C> <0C><<3C>
><3E><06><18>b<EFBFBD>j<EFBFBD>j<EFBFBD>-<2D>r<EFBFBD>t<EFBFBD>t<EFBFBD>4<> <0B>N<01>J<EFBFBD>N<01><08>)<29><08>
<12>=<3D>:
8<> 4<> !<21>&<26>"*<11>Z
F<01>*<2A>
<1B><15> <12> 8<><1C>& <0F> "<22>"<22>"<22>*<1E>")<29><15>]<5D>r