관리-도구
편집 파일: utils.cpython-36.pyc
3 �8�dVu � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlmZ ddl mZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" dd l#m$Z$ dd l%m&Z& ddl'm(Z(m)Z)m*Z*m+Z+ djZ,ej-� Z.ddd�Z/ej0dk�r2dd� Z1dd� Zdd� Z2dd� Z3dkdd�Z4dd� Z5dd � Z6d!d"� Z7d#d$� Z8d%d&� Z9d'd(� Z:dld)d*�Z;d+d,� Z<d-d.� Z=d/d0� Z>d1d2� Z?d3d4� Z@d5d6� ZAd7d8� ZBd9d:� ZCeDdm�ZEd=d>� ZFd?d@� ZGdAdB� ZHdCdD� ZIdEdF� ZJdGdH� ZKejLdIdJ� �ZMdKdL� ZNdndMdN�ZOdOdP� ZPdodRdS�ZQdTdU� ZRdVdW� ZSdXjTdY�ZUeUdZ ZVeUd[ ZWd\d]� ZXd^d_� ZYd`da� ZZej[db�Z\ej[dc�Z]ddde� Z^dfdg� Z_dhdi� Z`dS )pz� requests.utils ~~~~~~~~~~~~~~ This module provides utility functions that are used within Requests that are also useful for external consumption. � N� )�__version__)�certs)�to_native_string)�parse_http_list)�quote�urlparse�bytes�str�OrderedDict�unquote� getproxies�proxy_bypass� urlunparse� basestring� integer_types�is_py3�proxy_bypass_environment�getproxies_environment�Mapping)�cookiejar_from_dict)�CaseInsensitiveDict)� InvalidURL� InvalidHeader�FileModeWarning�UnrewindableBodyError�.netrc�_netrc�P i� )ZhttpZhttpsZwin32c C s� yt rdd l}ndd l}W n tk r. dS X y6|j|jd�}t|j|d�d �}|j|d�d }W n tk rz dS X | s�| r�dS |j d�}xX|D ]P}|dkr�d| kr�d S |j dd �}|j dd�}|j d d�}tj|| tj �r�d S q�W dS )Nr Fz;Software\Microsoft\Windows\CurrentVersion\Internet SettingsZProxyEnableZ ProxyOverride�;z<local>�.Tz\.�*z.*�?)r �winreg�_winreg�ImportError�OpenKey�HKEY_CURRENT_USER�intZQueryValueEx�OSError�split�replace�re�match�I)�hostr# ZinternetSettingsZproxyEnableZ proxyOverrideZtest� r0 �/usr/lib/python3.6/utils.py�proxy_bypass_registry/ s8 r2 c C s t � rt| �S t| �S dS )z�Return True, if the host should be bypassed. Checks proxy settings gathered from the environment, if specified, or the registry. N)r r r2 )r/ r0 r0 r1 r V s r c C s t | d�r| j� } | S )z/Returns an internal sequence dictionary update.�items)�hasattrr3 )�dr0 r0 r1 �dict_to_sequenceb s r6 c C s2 d }d}t | d�rt| �}nbt | d�r.| j}nPt | d�r~y| j� }W n tjk rZ Y n$X tj|�j}d| jkr~t j dt� t | d��ry| j� }W n$ t tfk r� |d k r�|}Y n\X t | d�o�|d k�ry&| jdd � | j� }| j|p�d� W n t tfk �r d}Y nX |d k�r$d}td|| �S ) Nr �__len__�len�fileno�ba% Requests has determined the content-length for this request using the binary size of the file: however, the file has been opened in text mode (i.e. without the 'b' flag in the mode). This may lead to an incorrect content-length. In Requests 3.0, support will be removed for files in text mode.�tell�seek� )r4 r8 r9 �io�UnsupportedOperation�os�fstat�st_size�mode�warnings�warnr r; r) �IOErrorr<