%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/
Upload File :
Create Path :
Current File : //opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyc

�
�wMVc@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZmZmZmZmZmZmZmZmZmZmZddlmZmZdd	lm Z dd
l!m"Z"efZ#d3Z$e
j%�Z&d
�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.e/d�Z0d�Z1d�Z2d�Z3d�Z4d�Z5d�Z6d�Z7e8dd�Z9d�Z:d �Z;d!�Z<d"�Z=d#�Z>d$�Z?d%�Z@d&�ZAd'd(�ZBd)�ZCd*�ZDd+jEd,�ZFeFd-ZGeFd.ZHd/�ZId0�ZJd1�ZKd,d2�ZLdS(4s�
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.

i����Ni(t__version__(tcerts(tparse_http_list(tquoteturlparsetbyteststrtOrderedDicttunquotetis_py2tbuiltin_strt
getproxiestproxy_bypasst
urlunparse(tRequestsCookieJartcookiejar_from_dict(tCaseInsensitiveDict(t
InvalidURLs.netrct_netrccCs"t|d�r|j�}n|S(s/Returns an internal sequence dictionary update.titems(thasattrR(td((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytdict_to_sequence'scCs�t|d�rt|�St|d�r/|jSt|d�rxy|j�}Wntjk
rdqxXtj|�jSnt|d�r�t|j��SdS(Nt__len__tlentfilenotgetvalue(	RRRtiotUnsupportedOperationtostfstattst_sizeR(toR((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyt	super_len0s
c
Cs2yddlm}m}d}x^tD]V}ytjjdj|��}Wntk
r_dSXtjj	|�r&|}Pq&q&W|dkr�dSt
|�}|jjd�d}yG||�j
|�}|r�|dr�dnd}	||	|dfSWn|tfk
rnXWnttfk
r-nXdS(	s;Returns the Requests tuple auth for a given url from netrc.i����(tnetrctNetrcParseErrors~/{0}Nt:iii(R"R#tNonetNETRC_FILESRtpatht
expandusertformattKeyErrortexistsRtnetloctsplittauthenticatorstIOErrortImportErrortAttributeError(
turlR"R#t
netrc_pathtftloctrithostRtlogin_i((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_netrc_authDs0

cCsLt|dd�}|rH|ddkrH|ddkrHtjj|�SdS(s0Tries to guess the filename of the given object.tnameit<i����t>N(tgetattrR%RR'tbasename(tobjR:((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytguess_filenamers&cCsD|dkrdSt|ttttf�r:td��nt|�S(s�Take an object and test to see if it can be represented as a
    dictionary. Unless it can not be represented as such, return an
    OrderedDict, e.g.,

    ::

        >>> from_key_val_list([('key', 'val')])
        OrderedDict([('key', 'val')])
        >>> from_key_val_list('string')
        ValueError: need more than 1 value to unpack
        >>> from_key_val_list({'key': 'val'})
        OrderedDict([('key', 'val')])
    s+cannot encode objects that are not 2-tuplesN(R%t
isinstanceRRtbooltintt
ValueErrorR(tvalue((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytfrom_key_val_listys
cCse|dkrdSt|ttttf�r:td��nt|tj�r[|j	�}nt
|�S(szTake an object and test to see if it can be represented as a
    dictionary. If it can be, return a list of tuples, e.g.,

    ::

        >>> to_key_val_list([('key', 'val')])
        [('key', 'val')]
        >>> to_key_val_list({'key': 'val'})
        [('key', 'val')]
        >>> to_key_val_list('string')
        ValueError: cannot encode objects that are not 2-tuples.
    s+cannot encode objects that are not 2-tuplesN(R%RARRRBRCRDtcollectionstMappingRtlist(RE((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytto_key_val_list�s
cCshg}x[t|�D]M}|d |dko8dknrSt|dd!�}n|j|�qW|S(s�Parse lists as described by RFC 2068 Section 2.

    In particular, parse comma-separated lists where the elements of
    the list may include quoted-strings.  A quoted-string could
    contain a comma.  A non-quoted string could have quotes in the
    middle.  Quotes are removed automatically after parsing.

    It basically works like :func:`parse_set_header` just that items
    may appear multiple times and case sensitivity is preserved.

    The return value is a standard :class:`list`:

    >>> parse_list_header('token, "quoted value"')
    ['token', 'quoted value']

    To create a header from the :class:`list` again, use the
    :func:`dump_header` function.

    :param value: a string with a list header.
    :return: :class:`list`
    ii����t"(t_parse_list_headertunquote_header_valuetappend(REtresulttitem((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytparse_list_header�s$cCs�i}x�t|�D]~}d|kr5d||<qn|jdd�\}}|d |dkoldknr�t|dd!�}n|||<qW|S(sMParse lists of key, value pairs as described by RFC 2068 Section 2 and
    convert them into a python dict:

    >>> d = parse_dict_header('foo="is a fish", bar="as well"')
    >>> type(d) is dict
    True
    >>> sorted(d.items())
    [('bar', 'as well'), ('foo', 'is a fish')]

    If there is no value for a key it will be `None`:

    >>> parse_dict_header('key_without_value')
    {'key_without_value': None}

    To create a header from the :class:`dict` again, use the
    :func:`dump_header` function.

    :param value: a string with a dict header.
    :return: :class:`dict`
    t=ii����RKN(RLR%R-RM(RERORPR:((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytparse_dict_header�s
$cCsq|rm|d|dko%dknrm|dd!}|sN|d dkrm|jdd�jdd�Sn|S(	s�Unquotes a header value.  (Reversal of :func:`quote_header_value`).
    This does not use the real unquoting but what browsers are actually
    using for quoting.

    :param value: the header value to unquote.
    ii����RKiis\\s\s\"(treplace(REtis_filename((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyRM�s
*
cCs+i}x|D]}|j||j<q
W|S(soReturns a key/value dictionary from a CookieJar.

    :param cj: CookieJar object to extract cookies from.
    (RER:(tcjtcookie_dicttcookie((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytdict_from_cookiejars
cCst|�}|j|�|S(s�Returns a CookieJar from a key/value dictionary.

    :param cj: CookieJar to insert cookies into.
    :param cookie_dict: Dict of key/values to insert into CookieJar.
    (Rtupdate(RVRWtcj2((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytadd_dict_to_cookiejars
cCsftjddtj�}tjddtj�}tjd�}|j|�|j|�|j|�S(slReturns encodings from given content string.

    :param content: bytestring to extract encodings from.
    s!<meta.*?charset=["\']*(.+?)["\'>]tflagss+<meta.*?content=["\']*;?charset=(.+?)["\'>]s$^<\?xml.*?encoding=["\']*(.+?)["\'>](tretcompiletItfindall(tcontentt
charset_ret	pragma_retxml_re((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_encodings_from_contents
cCs_|jd�}|sdStj|�\}}d|krK|djd�Sd|kr[dSdS(smReturns encodings from given HTTP Header Dict.

    :param headers: dictionary to extract encoding from.
    scontent-typetcharsets'"ttexts
ISO-8859-1N(tgetR%tcgitparse_headertstrip(theaderstcontent_typetparams((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_encoding_from_headers,sccs�|jdkr)x|D]}|VqWdStj|j�dd�}x+|D]#}|j|�}|rK|VqKqKW|jddt�}|r�|VndS(sStream decodes a iterator.NterrorsRTttfinal(tencodingR%tcodecstgetincrementaldecodertdecodetTrue(titeratortrRPtdecodertchunktrv((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytstream_decode_response_unicode@s
	
ccs=d}x0|t|�kr8||||!V||7}q	WdS(s Iterate over slices of a string.iN(R(tstringtslice_lengthtpos((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytiter_slicesRscCs�g}t|j�}|rSyt|j|�SWqStk
rO|j|�qSXnyt|j|dd�SWntk
r�|jSXdS(sReturns the requested content back in unicode.

    :param r: Response object to get unicode content from.

    Tried:

    1. charset from content-type

    2. every encodings from ``<meta ... charset=XXX>``

    3. fall back and replace all unicode characters

    RqRTN(RpRmRRbtUnicodeErrorRNt	TypeError(Rzttried_encodingsRt((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_unicode_from_responseZs

t4ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzs0123456789-._~cCs�|jd�}x�tdt|��D]�}||dd!}t|�dkr�|j�r�ytt|d��}Wn!tk
r�td|��nX|tkr�|||d||<q�d||||<q%d||||<q%Wdj	|�S(s�Un-escape any percent-escape sequences in a URI that are unreserved
    characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
    t%iiiis%Invalid percent-escape sequence: '%s'Rr(
R-trangeRtisalnumtchrRCRDRtUNRESERVED_SETtjoin(turitpartstithtc((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytunquote_unreserved�s
cCstt|�dd�S(s�Re-quote the given URI.

    This function passes the given URI through an unquote/quote cycle to
    ensure that it is fully and consistently quoted.
    tsafes!#$%&'()*+,/:;=?@[]~(RR�(R�((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytrequote_uri�s	cCs�tjdtj|��d}|jd�\}}tjdtjtt|����d}tjdtj|��d|@}||@||@kS(s�
    This function allows you to check if on IP belongs to a network subnet
    Example: returns True if ip = 192.168.1.1 and net = 192.168.1.0/24
             returns False if ip = 192.168.1.1 and net = 192.168.100.0/24
    s=Lit/(tstructtunpacktsockett	inet_atonR-tdotted_netmaskRC(tiptnettipaddrtnetaddrtbitstnetmasktnetwork((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytaddress_in_network�s
+#cCs/ddd|>dA}tjtjd|��S(st
    Converts mask from /xx format to xxx.xxx.xxx.xxx
    Example: if mask is 24 function returns 255.255.255.0
    I����ii s>I(R�t	inet_ntoaR�tpack(tmaskR�((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyR��scCs-ytj|�Wntjk
r(tSXtS(N(R�R�terrortFalseRx(t	string_ip((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytis_ipv4_address�s
cCs�|jd�dkr�yt|jd�d�}Wntk
rFtSX|dks_|dkrctSytj|jd�d�Wq�tjk
r�tSXntStS(s9Very simple check of the cidr format in no_proxy variableR�ii i(	tcountRCR-RDR�R�R�R�Rx(tstring_networkR�((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyt
is_valid_cidr�s
cCsd�}|d�}t|�j}|r�|jdd�jd�}|jd�d}t|�r�xs|D](}t|�rkt||�r�tSqkqkWq�x@|D]5}|j|�s�|jd�dj|�r�tSq�Wnyt	|�}Wn t
tjfk
rt
}nX|rtSt
S(s:
    Returns whether we should bypass proxies or not.
    cSs(tjj|�p'tjj|j��S(N(RtenvironRitupper(tk((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyt<lambda>�stno_proxyt Rrt,R$i(RR,RTR-R�R�R�RxtendswithRR�R�tgaierrorR�(R2t	get_proxyR�R,R�tproxy_ipR7tbypass((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytshould_bypass_proxies�s*	

+
cCst|�riSt�SdS(s%Return a dict of environment proxies.N(R�R(R2((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_environ_proxiessspython-requestscCs7tj�}|dkr'tj�}n�|dkr�dtjjtjjtjjf}tjjdkr�dj	|tjjg�}q�n<|dkr�tj�}n!|dkr�tj�}nd}ytj
�}tj�}Wntk
rd}d}nXd	j	d
|t
fd
||fd
||fg�S(s4Return a string representing the default user agent.tCPythontPyPys%s.%s.%sRsRrtJythont
IronPythontUnknownR�s%s/%s(tplatformtpython_implementationtpython_versiontsystpypy_version_infotmajortminortmicrotreleaselevelR�tsystemtreleaseR/R(R:t_implementationt_implementation_versiontp_systemt	p_release((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytdefault_user_agent
s.	!


cCs+tit�d6djd�d6dd6�S(	Ns
User-Agents, tgziptdeflatesAccept-Encodings*/*tAccept(R�R�(RR�R�(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytdefault_headers)s
c	Cs�g}d}x�|jd�D]�}y|jdd�\}}Wntk
r^|d}}nXi}|jd�|d<xa|jd�D]P}y|jd�\}}Wntk
r�PnX|j|�||j|�<q�W|j|�qW|S(	s�Return a dict of parsed link headers proxies.

    i.e. Link: <http:/.../front.jpeg>; rel=front; type="image/jpeg",<http://.../back.jpeg>; rel=back;type="image/jpeg"

    s '"R�t;iRrs<> '"R2RR(R-RDRlRN(	REtlinkst
replace_charstvalR2Rotlinktparamtkey((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytparse_header_links1s"

 ttasciiiicCs|d }|tjtjfkr&dS|d tjkr=dS|d tjtjfkr]dS|jt�}|dkr|dS|dkr�|ddd�tkr�d	S|d
dd�tkr�dSn|dkr�|d t	kr�dS|d
t	kr�d
SndS(Nisutf-32is	utf-8-sigisutf-16isutf-8s	utf-16-beis	utf-16-les	utf-32-bes	utf-32-le(RutBOM_UTF32_LEtBOM32_BEtBOM_UTF8tBOM_UTF16_LEtBOM_UTF16_BER�t_nullt_null2t_null3R%(tdatatsamplet	nullcount((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytguess_json_utfYs*
cCsSt||�\}}}}}}|s7||}}nt||||||f�S(s�Given a URL that may or may not have a scheme, prepend the given scheme.
    Does not replace a present scheme with the one provided as an argument.(RR
(R2t
new_schemetschemeR,R'Rotquerytfragment((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytprepend_scheme_if_neededvs!cCsRt|�}y"t|j�t|j�f}Wnttfk
rMd}nX|S(s_Given a url with authentication components, extract them into a tuple of
    username,password.Rr(RrRr(RRtusernametpasswordR1R�(R2tparsedtauth((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytget_auth_from_url�s"
cCsId}t|t�r|}n'tr6|j|�}n|j|�}|S(s�
    Given a string object, regardless of type, returns a representation of that
    string in the native string type, encoding and decoding where necessary.
    This assumes ASCII unless told otherwise.
    N(R%RAR
R	tencodeRw(RRttout((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pytto_native_string�s	(s.netrcs_netrc(Mt__doc__RjRuRGRRR�R^R�R�R�RrRRtcompatRRLRRRRRRR	R
RRR
tcookiesRRt
structuresRt
exceptionsRt_hush_pyflakesR&twheretDEFAULT_CA_BUNDLE_PATHRR!R9R@RFRJRQRSR�RMRYR\RfRpR~R�R�t	frozensetR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sK/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/requests/utils.pyt<module>
srL					.					"							"
			
					-			#

			

Zerion Mini Shell 1.0