Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
util.cpython-313.pyc143 linesDownload Raw Back to __pycache__
1�

2�j>'��(�SrSSKrSSKJr \R"S5r\R"S\R\R-\R-5r	\R"S\R\R-\R-5r\R"S\R5r
"SS	\5r"S3S\5rS SjrS!S
jrS!SjrS!SjrSrSrSrSrSr0rSrSrS"SjrS#Sjr"SS5r Sr!Sr"Sr#"SS\5r$g)$z�4pygments.util5~~~~~~~~~~~~~6 7Utility functions.8 9:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.10:license: BSD, see LICENSE for details.11�N)�
TextIOWrapperz[/\\ ]z�12    <!DOCTYPE\s+(13     [a-zA-Z_][a-zA-Z0-9]*14     (?: \s+      # optional in HTML515     [a-zA-Z_][a-zA-Z0-9]*\s+16     "[^"]*")?17     )18     [^>]*>19z<(.+?)(\s.*?)?>.*?</.+?>z\s*<\?xml[^>]*\?>c��\rSrSrSrSrg)�
ClassNotFound�zCRaised if one of the lookup functions didn't find a matching class.�N��__name__�20__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__r��SD:\code\apps\devtools\python\user_packages\Python313\site-packages\pygments/util.pyrrs��Mrrc��\rSrSrSrSrg)�OptionError�"zw21This exception will be raised by all option processing functions if22the type or value of the argument is not correct.23rNrrrrrr"s��rrc���URX5nU(aUR5nXR;a8[SRUSR	[[U5555eU$)zq24If the key `optname` from the dictionary is not in the sequence25`allowed`, raise an error, otherwise return it.26z%Value for option {} must be one of {}z, )�get�lowerr�format�join�map�str)�options�optname�allowed�default�normcase�strings      r�get_choice_optr!(sZ��27�[�[��
*�F�������
���A�H�H��RV�R[�R[�\_�`c�el�\m�Rn�o�p�p��Mrc�\�URX5n[U[5(aU$[U[5(a[U5$[U[5(d[SU<SUS35eUR
5S;agUR
5S;ag[SU<SUS35e)	a28Intuitively, this is `options.get(optname, default)`, but restricted to29Boolean value. The Booleans can be represented as string, in order to accept30Boolean value from the command line arguments. If the key `optname` is31present in the dictionary `options` and is not associated with a Boolean,32raise an `OptionError`. If it is absent, `default` is returned instead.33 34The valid string values for ``True`` are ``1``, ``yes``, ``true`` and35``on``, the ones for ``False`` are ``0``, ``no``, ``false`` and ``off``36(matched case-insensitively).37�
Invalid type � for option z%; use 1/0, yes/no, true/false, on/off)�1�yes�true�onT)�0�no�false�offF�Invalid value )r�38isinstance�bool�intrrr�rrrr s    r�get_bool_optr25s����[�[��
*�F��&�$����
�	�F�C�	 �	 ��F�|��
���
$�
$��M�&��<��y�I<�<�=�	=�	����5�	5��	����6�	6���N�6�*�L��	�J<�<�=�	=rc��URX5n[U5$![a [SU<SUS35e[a [SU<SUS35ef=f)z?As :func:`get_bool_opt`, but interpret the value as an integer.r#r$z ; you must give an integer valuer-)rr0�	TypeErrorr�39ValueErrorr1s    r�get_int_optr6Rs~��
�[�[��
*�F�8��6�{����8��M�&��<��y�I7�7�8�	8��8��N�6�*�L��	�J7�7�8�	8�8�s	�40�:Ac���URX5n[U[5(aUR5$[U[[4145(a[	U5$[
SU<SUS35e)z�42If the key `optname` from the dictionary `options` is a string,43split it at whitespace and return it. If it is already a list44or a tuple, it is returned as a list.45r#r$z; you must give a list value)rr.r�split�list�tupler)rrr�vals    r�get_list_optr<^sj���+�+�g�46'�C��#�s����y�y�{��	�C�$���	'�	'��C�y���M�#���W�I�F3�3�4�	4rc�8�UR(dg/nURR5R5H<nUR5(a$URSUR5-5 M< O SR	U5R5$)N�� )r
�strip�47splitlines�appendr�lstrip)�obj�res�lines   r�docstring_headlinerGnso���;�;��48�C����!�!�#�.�.�0���:�:�<�<��J�J�s�T�Z�Z�\�)�*��	1�49�7�7�3�<��� � rc�H^�U4SjnTRUl[U5$)zAReturn a static text analyser function that returns float values.c	�>�T"U5nU(dg[S[S[U555$![a gf=f![[504a gf=f)Ngg�?)�	Exception�min�max�floatr5r4)�text�rv�fs  �r�text_analyse�%make_analysator.<locals>.text_analyse|sb���	��4��B���	��s�C��U�2�Y�/�0�0���	��	���I�&�	��	�s�3�A�51A�A�A�A)r
�staticmethod)rPrQs` r�make_analysatorrTzs!���52��9�9�L����%�%rc��URS5nUS:�aUSUR5nOUR5nURS5(a�[R	USSR55Vs/sH&nU(dMURS5(aM$UPM( snSn[R"S	US533[R5nURU5bggs snf![a gf=f)a�Check if the given regular expression matches the last part of the54shebang if one exists.55 56    >>> from pygments.util import shebang_matches57    >>> shebang_matches('#!/usr/bin/env python', r'python(2\.\d)?')58    True59    >>> shebang_matches('#!/usr/bin/python2.4', r'python(2\.\d)?')60    True61    >>> shebang_matches('#!/usr/bin/python-ruby', r'python(2\.\d)?')62    False63    >>> shebang_matches('#!/usr/bin/python/ruby', r'python(2\.\d)?')64    False65    >>> shebang_matches('#!/usr/bin/startsomethingwith python',66    ...                 r'python(2\.\d)?')67    True68 69It also checks for common windows executable file extensions::70 71    >>> shebang_matches('#!C:\\Python2.4\\Python.exe', r'python(2\.\d)?')72    True73 74Parameters (``'-f'`` or ``'--foo'`` are ignored so ``'perl'`` does75the same as ``'perl -e'``)76 77Note that this method automatically searches the whole string (eg:78the regular expression is wrapped in ``'^$'``)79�80rNz#!��-�����F�^z(\.(exe|cmd|bat|bin))?$T)�findr�81startswith�
split_path_rer8r@�82IndexError�re�compile�83IGNORECASE�search)rN�regex�index�84first_line�x�founds      r�shebang_matchesrh�s���8
�I�I�d�O�E���z��&�5�\�'�'�)�85��Z�Z�\�86����T�"�"�	� -� 3� 3�J�q�r�N�4H�4H�4J� K�5� K�1���"#�,�,�s�"3�� K�5�57�9�E��87�88�a��w�&=�>��
�
�N���<�<���*����5���	��	�s0�(C0�;C+�89C+�"C+�(C0�+C0�090C=�<C=c���[RU5nUcgURS5n[R"U[R915R
UR55SL$)z�Check if the doctype matches a regular expression (if present).92 93Note that this method only checks the first part of a DOCTYPE.94eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'95NF�)�doctype_lookup_rerb�groupr_r`�I�matchr@)rNrc�m�doctypes    r�doctype_matchesrq�sT��	� � ��&�A��y���g�g�a�j�G�
�:�:�e�R�T�T�"�(�(�����9��E�Erc��[US5$)z3Check if the file looks like it has a html doctype.�html)rq)rNs r�html_doctype_matchesrt�s���4��)�)rc��[RU5(ag[U5n[U$![aB [96R
U5nUbg[R
USS5SLnU[U'Us$f=f)z2Check if a doctype exists or if we have some tags.TNi�)�xml_decl_rern�hash�_looks_like_xml_cache�KeyErrorrkrb�tag_re)rN�keyrorOs    r�looks_like_xmlr|�s���������97�t�*�C��$�S�)�)�����$�$�T�*���=��
�]�]�4���;�
'�t�
3��%'��c�"��	�
�s�1�"A=�%A=�<A=c�"�SUS-	-SUS--4$)zgGiven a unicode character code with length greater than 16 bits,98return the two 16 bit surrogate pair.99i���100i�i�r)�cs r�
surrogatepairr��s!��
�a�2�g���1�u�9�!5�7�7rc�\�/nSU-S-nSUS--S-nURXP-S-5 U(a UHnURXg-S-5 M O6UH0n[US-5nURXhSS-US	-S-5 M2 URUS101-5 SRU5$)z)Formats a sequence of strings for output.r?�rjz = (�,�"N�����rY�)rV)rB�reprr)	�var_name�seq�raw�indent_level�lines�base_indent�inner_indent�i�rs	         r�format_linesr��s����E���$�q�(�K��,��*�+�a�/�L�	�L�L��'�&�0�1�102��A��L�L��)�C�/�0���A��Q��W�
�A��L�L��#�2��.��2��6��<�=��103�L�L��s�"�#��9�9�U��rc��/n[5nUH1nXC;dXA;aMURU5 URU5 M3 U$)zU104Returns a list with duplicates removed from the iterable `it`.105 106Order is preserved.107)�setrB�add)�it�already_seen�lst�seenr�s     r�duplicates_removedr��sD��
�C��5�D�
���9��)���108�109�1�
������	�110�Jrc��\rSrSrSrSrSrg)�Futurei	z{Generic class to defer some work.111 112Handled specially in RegexLexerMeta, to support regex string construction at113first use.114c��[e�N)�NotImplementedError��selfs rr�115Future.gets��!�!rrN)r	r116rrr
rrrrrr�r�	s���117"rr�c���URS5nUS4$![aY SSKnUR5nURU5nX4s$![[4a URS5nUS4ss$f=ff=f)z�Decode *text* with guessed encoding.118 119First try UTF-8; this should fail for non-UTF-8 encodings.120Then try the preferred locale encoding.121Fall back to latin-1, which always works.122zutf-8rN�latin1)�decode�UnicodeDecodeError�locale�getpreferredencoding�LookupError)rNr��prefencodings   r�guess_decoder�s���"��{�{�7�#���W�}����"�	"��!�6�6�8�L��;�;�|�,�D��%�%��"�K�0�	"��;�;�x�(�D���>�!�	"��
"�s,��123A:�'A�	A:�%A6�1A:�5A6�6A:c��[USS5(a)URUR5nXR4$[	U5$![a Nf=f)z�Decode *text* coming from terminal *term*.124 125First try the terminal encoding, if given.126Then try UTF-8.  Then try the preferred locale encoding.127Fall back to latin-1, which always works.128�encodingN)�getattrr�r�r�r�)rN�terms  r�guess_decode_from_terminalr�(sX���t�Z��&�&�	'��;�;�t�}�}�-�D����&�&������	"�	��	�s�A�129A�Ac�f�[USS5(aUR$SSKnUR5$)z7Return our best guess of encoding for the given *term*.r�Nr)r�r�r�r�)r�r�s  r�terminal_encodingr�9s-���t�Z��&�&��}�}����&�&�(�(rc��\rSrSrSrSrg)�UnclosingTextIOWrapperiAc�$�UR5 gr�)�flushr�s r�close�UnclosingTextIOWrapper.closeCs���130�131�rrN)r	r132rrr�rrrrr�r�As��rr�)NFr�)Fr)r)%r
r_�iorr`r]�DOTALL�	MULTILINE�VERBOSErkrarzrmrvr5rrJrr!r2r6r<rGrTrhrqrtrxr|r�r�r�r�r�r�r�r�rrr�<module>r�s���133���134�135�9�%�
��J�J� ��Y�Y������136�137�*�,��138���/��M�M�B�I�I�-����<�139>���j�j�-�r�t�t�4��N�J�N��)��140�=�:1418�
4� 	!�&�"*�Z142F�*�143��
� 8��&
� "�"�"�*�")��]�r
codekingpro/portable-devtools · Team Ai