Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
utils.cpython-313.pyc96 linesDownload Raw Back to __pycache__
1�

2��j�#�	��SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J3r4 SSKJr SSK
Jr SSKJr SSKJr SSKJr SSKJrJrJrJrJrJrJrJrJr SSKr \RB"S	5r"\\#\4r$\\$r%\"S55r&"SS\65r'S
r(S\)S\#4Sjr*S,Sjr+"SS\ RXRZ5r.Sr/Sr0S-S\#S\1S\\)4Sjjr2Sr3Sr4S\S\4Sjr5S\S\\4Sjr6S\\&S\\&/\74S\\\&\\&44S jr8S!\9S\\94S"jr:S#\#S\#4S$jr;"S%S&\<5r=\S'\S\\\SS44S(j5r>S)\#S*\#S\74S+jr?g).�N)�OrderedDict)�contextmanager)�parse_ns_headers)�Path��pformat)�urlsplit)	�Any�List�Optional�Tuple�	Generator�Callable�Iterable�IO�TypeVarz
, (?=[^ ;]+=)�Tc�\�\rSrSrSr\RS:�rS\4Sjr	SSjr7S\4S	jrS8rg)�JsonDictPreservingDuplicateKeys�z2A specialized JSON dict preserving duplicate keys.)���itemsc�0�XlUR5 g�N)�_items�_ensure_items_used)�selfrs  �RD:\code\apps\devtools\python\user_packages\Python313\site-packages\httpie/utils.py�__init__�(JsonDictPreservingDuplicateKeys.__init__$s�������!��returnNc�2�UR(aSUS'gg)aHACK: Force `json.dumps()` to use `self.items()` instead of an empty dict.9 10Two JSON encoders are available on CPython: pure-Python (1) and C (2) implementations.11 12(1) The pure-python implementation will do a simple `if not dict: return '{}'`,13and we could fake that check by implementing the `__bool__()` method.14Source:15    - <https://github.com/python/cpython/blob/9d318ad/Lib/json/encoder.py#L334-L336>16 17(2) On the other hand, the C implementation will do a check on the number of18items contained inside the dict, using a verification on `dict->ma_used`, which19is updated only when an item is added/removed from the dict. For that case,20there is no workaround but to add an item into the dict.21Sources:22    - <https://github.com/python/cpython/blob/9d318ad/Modules/_json.c#L1581-L1582>23    - <https://github.com/python/cpython/blob/9d318ad/Include/cpython/dictobject.h#L53>24    - <https://github.com/python/cpython/blob/9d318ad/Include/cpython/dictobject.h#L17-L18>25 26To please both implementations, we simply add one item to the dict.27 28�__hack__N�r�rs rr�2JsonDictPreservingDuplicateKeys._ensure_items_used(s��,�;�;�)�D���r"c��UR$)z4Return all items, duplicate ones included.29 30        r&r's rr�%JsonDictPreservingDuplicateKeys.itemsAs���{�{�r"r&)r#N)
�__name__�31__module__�__qualname__�__firstlineno__�__doc__�sys�version_info�SUPPORTS_SORTING�Itemsr rr�__static_attributes__�r"rrrs5��<��'�'�6�1��"�e�"�*�2�u�r"rc�4�[R"U[S9$)N)�object_pairs_hook)�json�loadsr)�ss r�&load_json_preserve_order_and_dupe_keysr;Hs���:�:�a�+J�K�Kr"�dr#c��[U5$rr)r<s r�	repr_dictr>Ls���1�:�r"c�Z�/SQnUS:XagUHup4X:�dM O UW-SUS3SW3$)a�Return a humanized string representation of a number of bytes.32 33>>> humanize_bytes(1)34'1 B'35>>> humanize_bytes(1024, precision=1)36'1.0 kB'37>>> humanize_bytes(1024 * 123, precision=1)38'123.0 kB'39>>> humanize_bytes(1024 * 12342, precision=1)40'12.1 MB'41>>> humanize_bytes(1024 * 12342, precision=2)42'12.05 MB'43>>> humanize_bytes(1024 * 1234, precision=2)44'1.21 MB'45>>> humanize_bytes(1024 * 1234 * 1111, precision=2)46'1.31 GB'47>>> humanize_bytes(1024 * 1234 * 1111, precision=1)48'1.3 GB'49 50))l �PB)l�TB)i@�GB)i�MB)i�kB)��BrEz1 B�.�f� r5)�n�	precision�abbrevs�factor�suffixs     r�humanize_bytesrOPsK��0�G�	�A�v��!����;��"�51�&�j��9�+�Q��
'�q���1�1r"c��\rSrSrSrSrSrg)�ExplicitNullAuth�|zoForces requests to ignore the ``.netrc``.52<https://github.com/psf/requests/issues/2773#issuecomment-174312831>53c��U$rr5)r�rs  r�__call__�ExplicitNullAuth.__call__�s���r"r5N)r+r,r-r.r/rUr4r5r"rrQrQ|s���r"rQc�2�[R"USS9S$)z�54Return the content type for ``filename`` in format appropriate55for Content-Type headers, or ``None`` if the file type is unknown56to ``mimetypes``.57 58F)�strictr)�	mimetypes�59guess_type)�filenames r�get_content_typer\�s�������7��:�:r"c�>�U(d/$[RU5$)z�60When ``requests`` stores cookies in ``response.headers['Set-Cookie']``61it concatenates all of them through ``, ``.62 63This function splits cookies apart being careful to not to64split on ``, `` which may be part of cookie value.65)�RE_COOKIE_SPLIT�split)�cookiess r�
split_cookiesra�s����	�� � ��)�)r"r`�nowc�^�T=(d [R"5mS[[S[4U4Sjjn[	[U55nUVs/sHn[
USSUSSS9PM nn[UTS9 UVs/sH7nU"URS5S9(dMUS	URS66S5S.PM9 sn$s snfs snf)
N�expiresr#c�$>�USL=(a UT:*$rr5)rdrbs �r�67is_expired�'get_expired_cookies.<locals>.is_expired�s����d�"�5�w�#�~�5r"rEr)�name)r`rb)rdrh�path�/)rhri)	�timer�float�boolrra�dict�_max_age_to_expires�get)r`rbrf�	attr_sets�attrs�cookies `    r�get_expired_cookiesrt�s����68�69�����C�6�H�U�O�6��6�(8��g��(�I����E�	
�U�1�2�Y�U�1�X�a�[�)������S�1���70�F��f�j�j��3�4�	71��6�N��J�J�v�s�+�	72�������s�C�C�"Cc��UHMnSU;aMURS5nU(dM%UR5(dM<U[U5-US'MO g)z�73Translate `max-age` into `expires` for Requests to take it into account.74 75HACK/FIXME: <https://github.com/psf/requests/issues/5743>76 77rdzmax-ageN)rp�isdigitrl)r`rbrs�max_ages    rroro�sK���������*�*�Y�'���7�w���(�(� #�e�G�n� 4�F�9��r"c�P�URS5nUSR5USSp20nSnUHrnUR5nU(dMUSp�URS5n	U	S:wa*USU	RU5nXiS-SRU5nX�UR5'Mt X$4$)	zBorrowed from requests.�;rrENz"' T�=�����)r_�strip�find�lower)78�header�tokens�content_type�params�params_dict�items_to_strip�param�key�value�index_of_equalss79          r�parse_content_type_headerr��s���
�\�\�#�
�F�!�!�9�?�?�,�f�Q�R�j�&��K��N������
���5����#�j�j��o�O��"�$��,�_�-�3�3�N�C����1�2�3�9�9�.�I��',��	�	��$���$�$r"ric�\�[R"SS[U50UES9n[U5$)N�purelib�base)�vars)�	sysconfig�get_path�strr)ri�80extra_vars�site_packages_paths   r�as_siter��s5��"�+�+���c�$�i�
.�:�
.����"�#�#r"c#�# �SSKJnJnJn U(a/UupEUupF[	XVS-5Hn[UUSU3S9v� M g[U5v� g7f)Nr)�MIN_SUPPORTED_PY_VERSION�MAX_SUPPORTED_PY_VERSION�	is_frozenrErG)�py_version_short)�
httpie.compatr�r�r��ranger�)rir�r�r��major�	min_minor�	max_minor�minors        r�get_site_pathsr��sa������5���5����9�!�m�4�E���$)�7�!�E�7�!3��
�5��d�m��s�AA�iterabler�c��//p2UH4nU"U5(aURU5 M#URU5 M6 X#4$r)�append)r�r��left�right�items     r�split_iterabler��s>���b�%����t�9�9��K�K����L�L���	�81�;�r"�excc�^�URn[U[5(a[U5$U$r)�__context__�82isinstance�	Exception�unwrap_context)r��contexts  rr�r�s(���o�o�G��'�9�%�%��g�&�&��83r"�urlc�P�[U5RRS5S$)N�@r{)r	�netlocr_)r�s r�url_as_hostr�84s"���C�=���%�%�c�*�2�.�.r"c��\rSrSrSrg)�
LockFileErrorir5N)r+r,r-r.r4r5r"rr�r�s��r"r��filec/��# �[R"[R"U55R	5n[[R"55U-nURSS9 [U/UQ70UD6nUv� SSS5 UR5 g![an[S5UeSnAff=f!,(df   N==f!UR5 f=f7f)NF)�exist_okzCan't modify a locked file.)
�base64�	b64encode�os�fsencode�decoder�tempfile�85gettempdir�touch�FileExistsErrorr��open�unlink)r��args�kwargs�file_id�target_filer��streams       r�open_with_lockfiler�s�������r�{�{�4�0�1�8�8�:�G��x�*�*�,�-��7�K�D����5��)��
�$�
(��
(��
(�F��L�)�	������D��9�:��C��D��)�
(��	����sT�AC�B�-C	�<B8�C	�	C�86B5�$B0�0B5�5C�887C�C	�	C�C�	version_1�	version_2c�X�S[S[[S44SjnU"U5U"U5:�$)N�versionr#.c��/nURS5SSHnUR[U55 M  [	U5$![a  Mf=f)NrGr)r_r��int�88ValueError�tuple)r��parts�parts   r�
split_version�)is_version_greater.<locals>.split_version,sV�����M�M�#�&�r��*�D�
����S��Y�'�+�89�U�|����
��
�s�A�90A�A)r�r
r�)r�r�r�s   r�is_version_greaterr�%s4���s��u�S�#�X�����#�m�I�&>�>�>r")�r)@r�r�r8rY�rer0rkr�r��collectionsr�91contextlibr�http.cookiejarr�pathlibr�pprintr�urllib.parser	�typingr92rrr
rrrrr�
requests.auth�requests�compiler^r��Itemr3rrr;rnr>rO�auth�AuthBaserQr\rarlrtror�r�r�rmr�r�r�r�r�r�r�r�r5r"r�<module>r�s���	�
���	�93����#�%�+���!�Y�Y�Y���*�*�-�.���S�#�X����T�94���C�L��*�k�*�ZL����#��)2�X�x�}�}�-�-��;�95*���
��	��96�$�Z��@5�%�$$�$�$��$����(�4�.��&�X�a�[��x���T�	�/B��u�T�RS�W�VZ�[\�V]�M]�G^���	��h�y�&9��/�S�/�S�/�	�J�	���T��y��C��$�PT�AT�7U����$?�#�?�#�?�$�?r"
codekingpro/portable-devtools · Team Ai