관리-도구
편집 파일: models.cpython-39.pyc
a ��Rel� � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddl m Z ddlmZm Z mZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZmZmZ dd lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? ddl3m@ZA ddlBmCZC eCjDeCjEeCjFeCjGeCjHfZIdZJdZKdZLG dd� deM�ZNG dd� deM�ZOG dd� deO�ZPG dd� deNeO�ZQG dd� deM�ZRdS ) z` requests.models ~~~~~~~~~~~~~~~ This module contains the primary objects that power Requests. � N)�RequestField)�encode_multipart_formdata)� parse_url)�DecodeError�ReadTimeoutError� ProtocolError�LocationParseError)�UnsupportedOperation� )� default_hooks)�CaseInsensitiveDict)� HTTPBasicAuth)�cookiejar_from_dict�get_cookie_header�_copy_cookie_jar)� HTTPError� MissingSchema� InvalidURL�ChunkedEncodingError�ContentDecodingError�ConnectionError�StreamConsumedError�InvalidJSONError)�to_native_string�unicode_is_ascii) �guess_filename�get_auth_from_url�requote_uri�stream_decode_response_unicode�to_key_val_list�parse_header_links�iter_slices�guess_json_utf� super_len�check_header_validity)�Callable�Mapping� cookielib� urlunparse�urlsplit� urlencode�str�bytes�is_py2�chardet�builtin_str� basestring)�json)�codes� i ( i c @ s0 e Zd Zedd� �Zedd� �Zedd� �ZdS )�RequestEncodingMixinc C sN g }t | j�}|j}|sd}|�|� |j}|rD|�d� |�|� d�|�S )zBuild the path URL to use.�/�?� )r) �url�path�append�query�join)�selfr8 �pr9 r; � r? ��/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/requests/models.py�path_url= s zRequestEncodingMixin.path_urlc C s� t | ttf�r| S t| d�r | S t| d�r�g }t| �D ]j\}}t |t�sRt|d�sX|g}|D ]B}|dur\|�t |t�r�|�d�n|t |t�r�|�d�n|f� q\q6t|dd�S | S dS )z�Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. �read�__iter__N�utf-8T)�doseq) � isinstancer+ r, �hasattrr r0 r: �encoder* )�data�result�k�vs�vr? r? r@ �_encode_paramsR s$ ��z#RequestEncodingMixin._encode_paramsc C s� | st d��nt|t�r t d��g }t|p,i �}t| p8i �} |D ]|\}}t|t�s\t|d�sb|g}|D ]T}|durft|t�s�t|�}|�t|t�r�|�d�n|t|t�r�|� d�n|f� qfq@| D ]�\}}d}d} t|t tf��r t|�dkr�|\} }n&t|�dk�r|\} }}n|\} }}} nt |��p,|} |}t|tttf��rJ|}n(t|d��r`|�� }n|du �rnq�n|}t||| | d �} | j|d � |�| � q�t|�\}}||fS )a� Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype) or 4-tuples (filename, fileobj, contentype, custom_headers). zFiles must be provided.zData must not be a string.rC NrD � � rB )�namerI �filename�headers)�content_type)� ValueErrorrF r0 r rG r, r+ r: �decoderH �tuple�list�lenr � bytearrayrB r �make_multipartr )�filesrI � new_fields�fields�field�valrM rK �ft�fh�fn�fp�fdata�rf�bodyrT r? r? r@ � _encode_filesm sT �� z"RequestEncodingMixin._encode_filesN)�__name__� __module__�__qualname__�propertyrA �staticmethodrN rh r? r? r? r@ r4 <