관리-도구
편집 파일: models.cpython-36.pyc
3 �Re� � @ 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# ddl$m%Z%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl2m?Z@ ddlAmBZB eBjCeBjDeBjEeBjFeBjGfZHdZId!ZJdZKG dd� deL�ZMG dd� deL�ZNG dd� deN�ZOG dd� deMeN�ZPG dd � d eL�ZQdS )"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)�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|� |j}|rD|jd� |j|� dj|�S )zBuild the path URL to use.�/�?� )r( �url�path�append�query�join)�selfr8 �pr9 r; � r? ��/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/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 }x|t| �D ]p\}}t |t�sVt|d� r\|g}xJ|D ]B}|dk rb|jt |t�r�|jd�n|t |t�r�|jd�n|f� qbW q8W t|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__Nzutf-8T)�doseq) � isinstancer* r+ �hasattrr r/ 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 �} x�|D ]�\}}t|t�s`t|d� rf|g}x\|D ]T}|dk rlt|t�s�t|�}|jt|t�r�|jd�n|t|t�r�|j d�n|f� qlW qBW x�| D ]�\}}d}d} t|t tf��r.t|�dk�r|\} }n&t|�dk�r |\} }}n|\} }}} nt |��p:|} |}t|tttf��rX|}n(t|d��rn|j� }n|dk�r|q�n|}t||| | d �} | j|d � |j| � q�W 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 Nzutf-8� � rB )�namerH �filename�headers)�content_type)� ValueErrorrE r/ r rF r+ r* r: �decoderG �tuple�list�lenr � bytearrayrB r �make_multipartr )�filesrH � new_fields�fields�field�valrL rJ �ft�fh�fn�fp�fdata�rf�bodyrS r? r? r@ � _encode_filesm sP $ z"RequestEncodingMixin._encode_filesN)�__name__� __module__�__qualname__�propertyrA �staticmethodrM rg r? r? r? r@ r4 <