/usr/lib/python2.6/site-packages/requests
NameSizeModeActions
packages/-0755rm
adapters.py168100644editdlrm
adapters.pyc158050644editdlrm
adapters.pyo158050644editdlrm
api.py52800644editdlrm
api.pyc60350644editdlrm
api.pyo60350644editdlrm
auth.py67100644editdlrm
auth.pyc75850644editdlrm
auth.pyo75850644editdlrm
cacert.pem3084340644editdlrm
certs.py6490644editdlrm
certs.pyc9010644editdlrm
certs.pyo9010644editdlrm
compat.py15490644editdlrm
compat.pyc17000644editdlrm
compat.pyo17000644editdlrm
cookies.py167910644editdlrm
cookies.pyc204060644editdlrm
cookies.pyo204060644editdlrm
exceptions.py25170644editdlrm
exceptions.pyc52880644editdlrm
exceptions.pyo52880644editdlrm
hooks.py8200644editdlrm
hooks.pyc10660644editdlrm
hooks.pyo10660644editdlrm
models.py281560644editdlrm
models.pyc251620644editdlrm
models.pyo251620644editdlrm
sessions.py244760644editdlrm
sessions.pyc200580644editdlrm
sessions.pyo200580644editdlrm
status_codes.py32000644editdlrm
status_codes.pyc44700644editdlrm
status_codes.pyo44700644editdlrm
structures.py29770644editdlrm
structures.pyc51500644editdlrm
structures.pyo51500644editdlrm
utils.py213340644editdlrm
utils.pyc206770644editdlrm
utils.pyo206770644editdlrm
__init__.py18610644editdlrm
__init__.pyc25190644editdlrm
__init__.pyo25190644editdlrm
Edit: /usr/lib/python2.6/site-packages/requests/utils.pyc (20677B)
4Tc@sdZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk l Z ddk lZddklZddklZlZlZlZlZlZlZlZlZlZlZlZddklZl Z dd k!l"Z"dd k#l$Z$efZ%d4Z&ei'Z(d Z)dZ*dZ+dZ,dZ-dZ.dZ/dZ0e1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9e:ddZ;dZ<d Z=d!Z>d"Z?d#Z@d$ZAd%ZBd&ZCd'd(ZDd)ZEd*ZFd+iGd,ZHeHd-ZIeHd.ZJd/ZKd0ZLd1ZMd,d2ZNd3ZOdS(5s requests.utils ~~~~~~~~~~~~~~ This module provides utility functions that are used within Requests that are also useful for external consumption. iNi(t __version__(tcerts(tparse_http_list( tquoteturlparsetbyteststrt OrderedDicttunquotetis_py2t builtin_strt getproxiest proxy_bypasst urlunparset basestring(tRequestsCookieJartcookiejar_from_dict(tCaseInsensitiveDict(t InvalidURLs.netrct_netrccCs$t|do|i}n|S(s/Returns an internal sequence dictionary update.titems(thasattrR(td((s2/usr/lib/python2.6/site-packages/requests/utils.pytdict_to_sequence)scCst|do t|St|do|iSt|do=y|i}Wntij oqXti|iSnt|dot|iSdS(Nt__len__tlentfilenotgetvalue( RRRtiotUnsupportedOperationtostfstattst_sizeR(toR((s2/usr/lib/python2.6/site-packages/requests/utils.pyt super_len2s c Cs@y ddkl}l}d}xbtD]Z}ytiidi|}Wntj odSXtii |o |}Pq&q&W|djodSt |}|i i dd}yK||i |}|o+|dodnd} || |dfSWn|tfj onXWnttfj onXdS( s;Returns the Requests tuple auth for a given url from netrc.i(tnetrctNetrcParseErrors~/{0}Nt:iii(R#R$tNonet NETRC_FILESRtpatht expandusertformattKeyErrortexistsRtnetloctsplittauthenticatorstIOErrort ImportErrortAttributeError( turlR#R$t netrc_pathtftloctrithostRtlogin_i((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_netrc_authFs2    cCs`t|dd}|oCt|to3|ddjo"|ddjotii|SdS(s0Tries to guess the filename of the given object.tnameitN(tgetattrR&t isinstanceRRR(tbasename(tobjR;((s2/usr/lib/python2.6/site-packages/requests/utils.pytguess_filenamets(cCsH|djodSt|ttttfotdnt|S(sTake 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&R?RRtbooltintt ValueErrorR(tvalue((s2/usr/lib/python2.6/site-packages/requests/utils.pytfrom_key_val_list|s  cCsk|djodSt|ttttfotdnt|tio|i }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&R?RRRCRDREt collectionstMappingRtlist(RF((s2/usr/lib/python2.6/site-packages/requests/utils.pytto_key_val_lists cCskg}x^t|D]P}|d |djo djnot|dd!}n|i|qW|S(sParse 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` iit"(t_parse_list_headertunquote_header_valuetappend(RFtresulttitem((s2/usr/lib/python2.6/site-packages/requests/utils.pytparse_list_headers &cCsh}xt|D]}d|jod||>> 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=iiRLN(RMR&R.RN(RFRPRQR;((s2/usr/lib/python2.6/site-packages/requests/utils.pytparse_dict_headers   &cCsx|om|d|djo djnoG|dd!}| p|d djo|iddiddSn|S( sUnquotes 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. iiRLiis\\s\s\"(treplace(RFt is_filename((s2/usr/lib/python2.6/site-packages/requests/utils.pyRNs - !cCs+h}x|D]}|i||i]tflagss+]s$^<\?xml.*?encoding=["\']*(.+?)["\'>](twarningstwarntDeprecationWarningtretcompiletItfindall(tcontentt charset_ret pragma_retxml_re((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_encodings_from_content scCse|id}|pdSti|\}}d|jo|didSd|jodSdS(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((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_encoding_from_headers4s  ccs|idjox|D] }|VqWdSti|idd}x-|D]%}|i|}|o |VqMqMW|iddt}|o |VndS(sStream decodes a iterator.NterrorsRUttfinal(tencodingR&tcodecstgetincrementaldecodertdecodetTrue(titeratortrRQtdecodertchunktrv((s2/usr/lib/python2.6/site-packages/requests/utils.pytstream_decode_response_unicodeHs  ccs?d}x2|t|jo||||!V||7}q WdS(s Iterate over slices of a string.iN(R(tstringt slice_lengthtpos((s2/usr/lib/python2.6/site-packages/requests/utils.pyt iter_slicesZs c Cstidtg}t|i}|o;yt|i|SWqgtj o|i|qgXnyt|i|ddSWnt j o |iSXdS(sReturns the requested content back in unicode. :param r: Response object to get unicode content from. Tried: 1. charset from content-type 2. fall back and replace all unicode characters sIn requests 3.0, get_unicode_from_response will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)RuRUN( R_R`RaRtRqRRft UnicodeErrorROt TypeError(R~ttried_encodingsRx((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_unicode_from_responsebs t4ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzs0123456789-._~c Cs|id}xtdt|D]}||dd!}t|djo|io|ytt|d}Wn#tj otd|nX|tjo|||d||dA}titid|S(st Converts mask from /xx format to xxx.xxx.xxx.xxx Example: if mask is 24 function returns 255.255.255.0 Iii s>I(Rt inet_ntoaRtpack(tmaskR((s2/usr/lib/python2.6/site-packages/requests/utils.pyRscCs/yti|Wntij otSXtS(N(RRterrortFalseR|(t string_ip((s2/usr/lib/python2.6/site-packages/requests/utils.pytis_ipv4_addresss c Cs|iddjoyt|idd}Wntj otSX|djp |djotSyti|iddWqtij otSXntStS(s9Very simple check of the cidr format in no_proxy variableRii i( tcountRDR.RERRRRR|(tstring_networkR((s2/usr/lib/python2.6/site-packages/requests/utils.pyt is_valid_cidrs cCs-d}|d}t|i}|o|iddid}|idd}t|o;x{|D],}t|ot||otSqmqmWqxD|D]8}|i|p|iddi|otSqWnyt |}Wn"t t i fj o t }nX|otSt S(s: Returns whether we should bypass proxies or not. cSs)tii|ptii|iS((RtenvironRmtupper(tk((s2/usr/lib/python2.6/site-packages/requests/utils.pytstno_proxyt Rvt,R%i(RR-RUR.RRRR|tendswithR RRtgaierrorR(R3t get_proxyRR-Rtproxy_ipR8tbypass((s2/usr/lib/python2.6/site-packages/requests/utils.pytshould_bypass_proxiess.    -  cCst|ohStSdS(s%Return a dict of environment proxies.N(RR (R3((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_environ_proxiess spython-requestsc CsCti}|djoti}n|djo[dtiitiitiif}tiidjodi |tiig}qnA|djoti}n$|djoti}nd}yti }ti }Wnt j od}d}nXd i d |t fd ||fd ||fgS( s4Return a string representing the default user agent.tCPythontPyPys%s.%s.%sRwRvtJythont IronPythontUnknownRs%s/%s(tplatformtpython_implementationtpython_versiontsystpypy_version_infotmajortminortmicrot releaselevelRtsystemtreleaseR0R(R;t_implementationt_implementation_versiontp_systemt p_release((s2/usr/lib/python2.6/site-packages/requests/utils.pytdefault_user_agents.     #     cCs2thtd6did d6dd6dd 6S( Ns User-Agents, tgziptdeflatesAccept-Encodings*/*tAccepts keep-alivet Connection(RR(RRR(((s2/usr/lib/python2.6/site-packages/requests/utils.pytdefault_headers;s  c Csg}d}xtid|D]}y|idd\}}Wn tj o|d}}nXh}|id|d; rel=front; type="image/jpeg",; rel=back;type="image/jpeg" s '"s, * '"R3RS(RbR.RERpRO( RFtlinkst replace_charstvalR3Rstlinktparamtkey((s2/usr/lib/python2.6/site-packages/requests/utils.pytparse_header_linksDs& ttasciiiicCs|d }|titifjodS|d tijodS|d titifjodS|it}|djodS|djoB|dddtjod S|d ddtjod Sn|djo0|d t jod S|d t jod SndS(Nisutf-32is utf-8-sigisutf-16isutf-8s utf-16-beis utf-16-les utf-32-bes utf-32-le( Ryt BOM_UTF32_LEtBOM32_BEtBOM_UTF8t BOM_UTF16_LEt BOM_UTF16_BERt_nullt_null2t_null3R&(tdatatsamplet nullcount((s2/usr/lib/python2.6/site-packages/requests/utils.pytguess_json_utfls*      cCsUt||\}}}}}}|p||}}nt||||||fS(sGiven 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 (R3t new_schemetschemeR-R(Rstquerytfragment((s2/usr/lib/python2.6/site-packages/requests/utils.pytprepend_scheme_if_neededs!cCsTt|}y"t|it|if}Wnttfj o d}nX|S(s_Given a url with authentication components, extract them into a tuple of username,password.Rv(RvRv(RRtusernametpasswordR2R(R3tparsedtauth((s2/usr/lib/python2.6/site-packages/requests/utils.pytget_auth_from_urls  " cCsMd}t|to |}n*to|i|}n|i|}|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&R?R R tencodeR{(RRxtout((s2/usr/lib/python2.6/site-packages/requests/utils.pytto_native_strings cCsht|\}}}}}}|p||}}n|iddd}t|||||dfS(sE Given a url remove the fragment and the authentication part t@iiRv(RtrsplitR (R3RR-R(RsRR((s2/usr/lib/python2.6/site-packages/requests/utils.pyt urldefragauths (s.netrcs_netrc(Pt__doc__RnRyRHRRRRbRRRR_RvRRtcompatRRMRRRRRRR R R R R RtcookiesRRt structuresRt exceptionsRt_hush_pyflakesR'twheretDEFAULT_CA_BUNDLE_PATHRR"R:RBRGRKRRRTRRNRZR]RjRtRRRt frozensetRRRRRRRRRRRRRRRRRRRRR(((s2/usr/lib/python2.6/site-packages/requests/utils.pyt sv           R    .     "       $      -   #