Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j-T�	�&�SrSSKJr SSKrSSKrSSKrSSKJrJr SSK	J3r4JrJr SSK
JrJrJrJr SSKJr SS	KJr SS5KJrJrJrJr \(aSSKJr SSKJr SSK r "S
S5r!"SS5r"S!Sjr#S"Sjr$S#S$Sjjr%"SS\&5r'"SS\\\(\(S-45r)S%Sjr*S&Sjr+S'Sjr,\"S\S9r-\S(S)Sjj5r.\S*S+Sjj5r.S(S,Sjjr.S-S jr/g).z�6requests.cookies7~~~~~~~~~~~~~~~~8 9Compatibility code to be able to use `http.cookiejar.CookieJar` with requests.10 11requests.utils imports from here, so be careful with imports.12�)�annotationsN)�Iterator�MutableMapping)�Cookie�	CookieJar�CookiePolicy)�
TYPE_CHECKING�Any�TypeVar�overload�)�to_native_string)�is_prepared)�Morsel�	cookielib�urlparse�13urlunparse)�SupportsKeysAndGetItem)�PreparedRequestc���\rSrSr%SrS\S'SSjrSSjrSSjrSSjr	SS	jr14SS15jrSSjrSSS
jjr
SSjrSSjrSSjr\SSj5r\SSj5r\SSj5rSrg)�MockRequest�a�Wraps a `requests.PreparedRequest` to mimic a `urllib2.Request`.16 17The code in `http.cookiejar.CookieJar` expects this interface in order to correctly18manage cookie policies, i.e., determine whether a cookie can be set, given the19domains of the request and the cookie.20 21The original request object is read-only. The client is responsible for collecting22the new headers via `get_new_headers()` and interpreting them appropriately. You23probably want `get_cookie_header`, defined below.24�str�typec��[U5(deXl0Ul[URR5R25Ulg�N)�_is_prepared�_r�_new_headersr�url�schemer)�self�requests  �VD:\code\apps\devtools\python\user_packages\Python313\site-packages\requests/cookies.py�__init__�MockRequest.__init__-s:���G�$�$�$�$���,.����T�W�W�[�[�)�0�0��	�c��UR$r)r�r"s r$�get_type�MockRequest.get_type3s���y�y�r'c�T�[URR5R$r)rrr �netlocr)s r$�get_host�MockRequest.get_host6s��������$�+�+�+r'c�"�UR5$r�r.r)s r$�get_origin_req_host�MockRequest.get_origin_req_host9s���}�}��r'c��URRRS5(dURR$[	URRSSS9n[URR5n[
URUURURURUR/5$)N�Hostzutf-8)�encoding)r�headers�getr rrrr!�path�params�query�fragment)r"�host�parseds   r$�get_full_url�MockRequest.get_full_url<s����w�w���"�"�6�*�*��7�7�;�;��������� 7�'�J���$�'�'�+�+�&����
�
������
�
�������

�	26�		27r'c��g�NT�r)s r$�is_unverifiable�MockRequest.is_unverifiablePs��r'c�\�XRR;=(d XR;$r)rr7r�r"�names  r$�28has_header�MockRequest.has_headerSs!���w�w���&�C�$�2C�2C�*C�Cr'Nc�~�URRRXRRX55$r)rr7r8r)r"rH�defaults   r$�29get_header�MockRequest.get_headerVs,���w�w���"�"�4�):�):�)>�)>�t�)M�N�Nr'c��[S5e)zMcookiejar has no legitimate use for this method; add it back if you find one.z=Cookie headers should be added with add_unredirected_header())�NotImplementedError)r"�key�vals   r$�30add_header�MockRequest.add_headerYs��!�K�31�	32r'c� �X RU'gr�r�r"rH�values   r$�add_unredirected_header�#MockRequest.add_unredirected_header_s��"'���$�r'c��UR$rrVr)s r$�get_new_headers�MockRequest.get_new_headersbs��� � � r'c�"�UR5$r)rDr)s r$�unverifiable�MockRequest.unverifiablees���#�#�%�%r'c�"�UR5$r)r2r)s r$�origin_req_host�MockRequest.origin_req_hostis���'�'�)�)r'c�"�UR5$rr1r)s r$r=�MockRequest.hostms���}�}��r')rrr)r#r�return�None)rfr�rf�bool)rHrrfrir)rHrrL�33str | Nonerfrj)rQrrRrrfrg)rHrrXrrfrg)rfzdict[str, str])�__name__�34__module__�__qualname__�__firstlineno__�__doc__�__annotations__r%r*r.r2r?rDrIrMrSrYr\�propertyr_rbr=�__static_attributes__rCr'r$rrs���	��I�1��,��35�(�D�O�36�(�!��&��&��*��*����r'rc�6�\rSrSrSrSSjrS	SjrS37SjrSrg)�MockResponse�rz�Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.38 39...what? Basically, expose the parsed HTTP headers from the server response40the way `http.cookiejar` expects to see them.41c��Xlg)zvMake a MockResponse for `cookiejar` to read.42 43:param headers: a httplib.HTTPMessage or analogous carrying the headers44N��_headers)r"r7s  r$r%�MockResponse.__init__ys	��45 �
r'c��UR$rrwr)s r$�info�MockResponse.info�s���}�}�r'c�:�URRU5 gr)rx�46getheadersrGs  r$r~�MockResponse.getheaders�s���
�
� � ��&r'rwN)r7r47rfrg)rfr48)rHrrfr49)	rkrlrmrnror%r{r~rrrCr'r$rtrtrs��� ��'r'rtc���[US5(aUR(dg[U5n[URR5nURXC5 g)z�Extract the cookies from the response into a CookieJar.50 51:param jar: http.cookiejar.CookieJar (not necessarily a RequestsCookieJar)52:param request: our own requests.Request object53:param response: urllib3.HTTPResponse object54�_original_responseN)�hasattrr�rrt�msg�extract_cookies)�jarr#�response�req�ress     r$�extract_cookies_to_jarr��sK��
�H�2�3�3��8S�8S��55�g�56�C�57�x�2�2�6�6�587�C�����!r'c�x�[U5nURU5 UR5RS5$)z^59Produce an appropriate Cookie header string to be sent with `request`, or None.60 61:rtype: str62r)r�add_cookie_headerr\r8)r�r#�rs   r$�get_cookie_headerr��s6��	�G��A����!������"�"�8�,�,r'c�.�/nUHonURU:waMUbX%R:waM)UbX5R:waM=URURURUR45 Mq UHup#nUR	X#U5 M g)zcUnsets a cookie by name, by default over all domains and paths.63 64Wraps CookieJar.clear(), is O(n).65N)rH�domainr9�append�clear)�	cookiejarrHr�r9�66clearables�cookies      r$�remove_cookie_by_namer��s���.0�J����;�;�$�����&�M�M�"9������� 3�����6�=�=�&�+�+�v�{�{�C�D��)���d�����d�+�)r'c��\rSrSrSrSrg)�CookieConflictError�z�There are two cookies that meet the criteria specified in the cookie jar.67Use .get and .set and include domain and path args in order to be more specific.68rCN)rkrlrmrnrorrrCr'r$r�r��s��r'r�c�^�\rSrSr%SrS\S'SS SjjrS!SjrS"SjrS#Sjr	S$S	jr69S%S70jrS&SjrS'Sjr
S#S
jrS#SjrS(SjrS)S*SjjrS+U4SjjrS,U4SjjrS-SjrS.SjrS/SjrS0U4SjjrS1U4SjjrS)S2SjjrS)S3SjjrS4SjrS5SjrS6SjrS7SjrSrU=r $)8�RequestsCookieJar�a�Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict71interface.72 73This is the CookieJar we create by default for requests and sessions that74don't specify one, since some clients may expect response.cookies and75session.cookies to support dict operations.76 77Requests does not use the dict interface internally; it's just for78compatibility with external client code. All requests code should work79out of the box with externally provided instances of ``CookieJar``, e.g.80``LWPCookieJar`` and ``FileCookieJar``.81 82Unlike a regular CookieJar, this class is pickleable.83 84.. warning:: dictionary operations that are normally O(1) may be O(n).85r�_policyc�L�URXU5$![a Us$f=f)z�Dict-like get() that also supports optional domain and path args in86order to resolve naming collisions from using one cookie jar over87multiple domains.88 89.. warning:: operation is O(n), not O(1).90)�_find_no_duplicates�KeyError)r"rHrLr�r9s     r$r8�RequestsCookieJar.get�s.��	��+�+�D�$�?�?���	��N�	�s��#�#c���Uc*[XURS5URS5S9 g[U[5(a[	U5nO[X40UD6nUR
U5 U$)z�Dict-like set() that also supports optional domain and path args in91order to resolve naming collisions from using one cookie jar over92multiple domains.93Nr�r9)r�r9)r�r8�94isinstancer�morsel_to_cookie�
create_cookie�95set_cookie)r"rHrX�kwargs�cs     r$�set�RequestsCookieJar.set�sf���=�!��6�:�:�h�#7�f�j�j��>P�
�
��e�V�$�$� ��'�A��d�4�V�4�A�������r'c#�L# �[U5HnURv� M g7f)z|Dict-like iterkeys() that returns an iterator of names of cookies96from the jar.97 98.. seealso:: itervalues() and iteritems().99N)�iterrH�r"r�s  r$�iterkeys�RequestsCookieJar.iterkeys�s����4�j�F��+�+��!���"$c�4�[UR55$)zkDict-like keys() that returns a list of names of cookies from the100jar.101 102.. seealso:: values() and items().103)�listr�r)s r$�keys�RequestsCookieJar.keyss���D�M�M�O�$�$r'c#�L# �[U5HnURv� M g7f)z}Dict-like itervalues() that returns an iterator of values of cookies104from the jar.105 106.. seealso:: iterkeys() and iteritems().107N)r�rXr�s  r$�108itervalues�RequestsCookieJar.itervaluess����4�j�F��,�,��!�r�c�4�[UR55$)zlDict-like values() that returns a list of values of cookies from the109jar.110 111.. seealso:: keys() and items().112)r�r�r)s r$�values�RequestsCookieJar.valuess���D�O�O�%�&�&r'c#�d# �[U5HnURUR4v� M g7f)z}Dict-like iteritems() that returns an iterator of name-value tuples113from the jar.114 115.. seealso:: iterkeys() and itervalues().116N)r�rHrXr�s  r$�	iteritems�RequestsCookieJar.iteritemss(����4�j�F��+�+�v�|�|�+�+�!�s�.0c�4�[UR55$)z�Dict-like items() that returns a list of name-value tuples from the117jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a118vanilla python dict of key value pairs.119 120.. seealso:: keys() and values().121)r�r�r)s r$�items�RequestsCookieJar.items%s���D�N�N�$�%�%r'c��/n[U5H0nURU;dMURUR5 M2 U$)z2Utility method to list all the domains in the jar.�r�r�r��r"�domainsr�s   r$�list_domains�RequestsCookieJar.list_domains.s8�����4�j�F��}�}�G�+����v�}�}�-�!��r'c��/n[U5H0nURU;dMURUR5 M2 U$)z0Utility method to list all the paths in the jar.)r�r9r�)r"�pathsr�s   r$�122list_paths�RequestsCookieJar.list_paths6s8�����4�j�F��{�{�%�'����V�[�[�)�!��r'c��/n[U5H=nURbURU;a gURUR5 M? g)z^Returns True if there are multiple domains in the jar.123Returns False otherwise.124 125:rtype: bool126TFr�r�s   r$�multiple_domains�"RequestsCookieJar.multiple_domains>sD�� ���4�j�F��}�}�(�V�]�]�g�-E���N�N�6�=�=�)�!�r'c��0n[U5HEnUbURU:XdMUbURU:XdM-URX4R'MG U$)z�Takes as an argument an optional domain and path and returns a plain127old Python dict of name-value pairs of cookies that meet the128requirements.129 130:rtype: dict131)r�r�r9rXrH)r"r�r9�132dictionaryr�s     r$�get_dict�RequestsCookieJar.get_dictKsO��-/�133��4�j�F���&�-�-�6�"9������t� 3�*0�,�,�134�;�;�'�	!�135�r'c� >�[TU]5$)zDRequestCookieJar's __iter__ comes from CookieJar not MutableMapping.)�super�__iter__)r"�	__class__s �r$r��RequestsCookieJar.__iter__\s����w��!�!r'c�D>�[TU]U5$![a gf=frB)r��__contains__r�)r"rHr�s  �r$r��RequestsCookieJar.__contains__`s*���	��7�'��-�-��"�	��	�s��136�c�$�URU5$)z�Dict-like __getitem__() for compatibility with client code. Throws137exception if there are more than one cookie with name. In that case,138use the more explicit get() method instead.139 140.. warning:: operation is O(n), not O(1).141)r�rGs  r$�__getitem__�RequestsCookieJar.__getitem__fs���'�'��-�-r'c�&�URX5 g)z�Dict-like __setitem__ for compatibility with client code. Throws142exception if there is already a cookie of that name in the jar. In that143case, use the more explicit set() method instead.144N)r�rWs   r$�__setitem__�RequestsCookieJar.__setitem__os��	
����r'c��[X5 g)zaDeletes a cookie given a name. Wraps ``http.cookiejar.CookieJar``'s145``remove_cookie_by_name()``.146N)r�rGs  r$�__delitem__�RequestsCookieJar.__delitem__xs��	�d�)r'c��>�UR=nbCURS5(a-URS5(aURSS5Ul[TU]"U/UQ70UD6$)N�"z\"�)rX�147startswith�endswith�replacer�r�)r"r��argsr�rXr�s     �r$r��RequestsCookieJar.set_cookie~s^����l�l�
"�U�/�� � ��%�%����s�#�#� �=�=���3�F�L��w�!�&�:�4�:�6�:�:r'c��>�[U[R5(a/UH(nUR[R"U55 M* g[148TU]U5 g)zAUpdates this jar with cookies from another CookieJar or dict-likeN)r�rrr��copyr��update)r"�otherr�r�s   �r$r��RequestsCookieJar.update�sE����e�Y�0�0�1�1�������	�	�&� 1�2� �
�G�N�5�!r'c���[U5HKnURU:XdMUbURU:XdM*UbURU:XdM?URs $ [SU<SU<SU<35e)a�Requests uses this method internally to get cookie values.149 150If there are conflicting cookies, _find arbitrarily chooses one.151See _find_no_duplicates if you want an exception thrown if there are152conflicting cookies.153 154:param name: a string containing name of cookie155:param domain: (optional) string containing domain of cookie156:param path: (optional) string containing path of cookie157:return: cookie.value158�name=�	, domain=�, path=)r�rHr�r9rXr�)r"rHr�r9r�s     r$�_find�RequestsCookieJar._find�sh���4�j�F��{�{�d�"��>�V�]�]�f�%<��|�v�{�{�d�':�%�|�|�+�	!���t�h�i��z����I�J�Jr'c��Sn[U5H]nURU:XdMUbURU:XdM*UbURU:XdM?Ub[	SU<35eUR159nM_ UbU$[
SU<SU<SU<35e)a�Both ``__get_item__`` and ``get`` call this function: it's never160used elsewhere in Requests.161 162:param name: a string containing name of cookie163:param domain: (optional) string containing domain of cookie164:param path: (optional) string containing path of cookie165:raises KeyError: if cookie is not found166:raises CookieConflictError: if there are multiple cookies167    that match name and optionally domain and path168:return: cookie.value169Nz&There are multiple cookies with name, r�r�r�)r�rHr�r9r�rXr�)r"rHr�r9�toReturnr�s      r$r��%RequestsCookieJar._find_no_duplicates�s������4�j�F��{�{�d�"��>�V�]�]�f�%<��|�v�{�{�d�':�#�/�"5�"H��� Q�#��$*�<�<��!����O���t�h�i��z����I�J�Jr'c�\�URR5nURS5 U$)�4Unlike a normal CookieJar, this class is pickleable.�
_cookies_lock)�__dict__r��pop�r"�states  r$�__getstate__�RequestsCookieJar.__getstate__�s%���
�
�"�"�$��
�	�	�/�"��r'c��URRU5 SUR;a[R"5Ulgg)r�r�N)r�r��	threading�RLockr�r�s  r$�__setstate__�RequestsCookieJar.__setstate__�s4���
�
���U�#��$�-�-�/�!*���!2�D��0r'c�z�[5nURUR55 URU5 U$)z(Return a copy of this RequestsCookieJar.)r��170set_policy�171get_policyr�)r"�new_cjs  r$r��RequestsCookieJar.copy�s0��"�$�����$�/�/�+�,��
�
�d���
r'c��UR$)z&Return the CookiePolicy instance used.)r�r)s r$r�RequestsCookieJar.get_policy�s���|�|�r')r�)NNN)172rHrrLrjr�rjr9rjrfrj)rHrrX�#str | Morsel[dict[str, str]] | Noner�r173rfz
Cookie | None)rfz
Iterator[str])rfz	list[str])rfzIterator[str | None])rfzlist[str | None])rfz Iterator[tuple[str, str | None]])rfzlist[tuple[str, str | None]]rh�NN)r�rjr9rjrfzdict[str, str | None])rfzIterator[Cookie])rH�objectrfri)rHrrfrj)rHrrXr
rfrg)rHrrfrg)r�rr�r174r�r175rfrg)r�z,CookieJar | SupportsKeysAndGetItem[str, str]rfrg)rHrr�rjr9rjrfrj)rHrr�rjr9rjrfr)rf�dict[str, Any])r�rrfrg)rfr�)rfr)!rkrlrmrnrorpr8r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rrr�
__classcell__)r�s@r$r�r��s�����"��176#�!��������	�177��178�
�$��� C��OR��	��*�%��'�,�&����=A�� ��/9��	��""��.���� C��	
��*�;�"�A�"�	
�"�HL�K��K�!+�K�:D�K�	�K�.HL�K��K�!+�K�:D�K�	�K�>�3���r'r�c���Ucg[USS5=n(aU"5$[R"U5nUR5 UH(nUR[R"U55 M* U$)Nr�)�getattrr�r�r�)r��copy_method�new_jarr�s    r$�_copy_cookie_jarr�sb��179�{���c�6�4�0�0�{�0��}���i�i��n�G��M�M�O������4�9�9�V�,�-���Nr'c�r�SUUSSSSSSSSSS0SS.
n[U5[U5-180nU(a[S	[U535eURU5 [	US1815US'[	US5US
'USRS5US'[	US5US'[R"S0UD6$)z�Make a cookie from underspecified parameters.182 183By default, the pair of `name` and `value` will be set for the domain ''184and sent on every request (this is sometimes called a "supercookie").185rNr��/FT�HttpOnly)
�versionrHrX�portr�r9�secure�expires�discard�comment�comment_url�rest�rfc2109z2create_cookie() got unexpected keyword arguments: r�port_specifiedr��domain_specified�.�domain_initial_dotr9�path_specifiedrC)r��	TypeErrorr�r�rir�rr)rHrXr��result�badargss     r$r�r��s���������������T�"���F� �&�k�C��K�'�G���@��g���P�186�	187��M�M�&��#�F�6�N�3�F���!%�f�X�&6�!7�F���#)�(�#3�#>�#>�s�#C�F�� �#�F�6�N�3�F������%�f�%�%r'c���SnUS(a/[[R"5[US5-5nO:US(a0Sn[R188"[R"USU55n[US[US5SUS	UURUS189SSUS0S[US
5URUS=(d SS9
$![a [SUSS35ef=f)zBConvert a Morsel object into a Cookie containing the one k/v pair.Nzmax-agez	max-age: z must be integerrz%a, %d-%b-%Y %H:%M:%S GMTrFr�r9r�httponlyrrr)
rr rr�rrHr9rr!r"rrXr)�int�time�190ValueErrorr(�calendar�timegm�strptimer�rirQrX)�morselr�
time_templates   r$r�r�s���G�
�i��	M��$�)�)�+��F�9�,=�(>�>�?�G�191�	�	�3�
��/�/�$�-�-��y�0A�=�"Q�R����y�!���	�*�+���h���
�Z�Z�
�F�^�
��&��,�
-���F�8�$�%��l�l��y�!�&�Q�����	M��i��y�(9�':�:J�K�L�L�	M�s�-C�C.�_CookieJarT)�boundc��grrC��cookie_dictr��	overwrites   r$�cookiejar_from_dictr;3s��192r'c��grrCr8s   r$r;r;;s��193r'c���Uc194[5nUbOUVs/sHo3RPM nnUH.nU(dXT;dMUR[XPU55 M0 U$s snf)a+Returns a CookieJar from a key/value dictionary.195 196:param cookie_dict: Dict of key/values to insert into CookieJar.197:param cookiejar: (optional) A cookiejar to add the cookies to.198:param overwrite: (optional) If False, will not replace cookies199    already in the jar with new ones.200:rtype: CookieJar201)r�rHr�r�)r9r�r:r��names_from_jarrHs      r$r;r;Cse����%�'�	���4=�>�I�&�+�+�I��>��D��T�7��$�$�]�4�T�9J�%K�L� ����?s�A"c�J�[U[R5(d[S5e[U[5(a[XSS9nU$[U[R5(a8[
USS5=n(a202U"U5 U$UHnURU5 M U$)z�Add cookies to cookiejar and returns a merged CookieJar.203 204:param cookiejar: CookieJar object to add the cookies to.205:param cookies: Dictionary or CookieJar object to be added.206:rtype: CookieJar207z!You can only merge into CookieJarF)r�r:r�N)r�rrr/�dictr;rr�)r��cookies�
update_method�
cookie_in_jars    r$�
merge_cookiesrD\s����i��!4�!4�5�5��<�=�=��'�4� � �'��PU�V�	���208�G�Y�0�0�	1�	1�#�I�x��>�>�=�>��'�"�209��")�
��$�$�]�3�")��r')r�rr#rr�r210rfrg)r�rr#rrfrjr)211r�rrHrr�rjr9rjrfrg)r��CookieJar | NonerfrE)rHrrXrr�r212rfr)r3zMorsel[Any]rfrrB)r9�dict[str, str] | Noner�rgr:rirfr�)T)r9rFr�r5r:rirfr5)r9rFr�rEr:rirfr)r�rrAz!dict[str, str] | CookieJar | Nonerfr)0ro�213__future__rr0r�r.�collections.abcrr�http.cookiejarrrr�typingr	r214rr�_internal_utilsr�_typesrr�compatrrrr�	_typeshedr�modelsrrrrtr�r�r��RuntimeErrorr�rr�rr�r�r5r;rDrCr'r$�<module>rQs����#����4�:�:�8�8�-�/�;�;��0�'��P�P�f'�'�*"�	�"�,�"�8;�"�	�"�$-�TX�,��,� #�,�-7�,�FP�,�	�,�*�,��]�	�>�#�s�T�z�/�#B�]�@	�"&�J�:�m�9�5��215����&�������	�216��217���&�������	�218��#'���&�������	�2���#D���r'
codekingpro/portable-devtools · Team Ai