Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Functions | Variables
pip._vendor.requests.utils Namespace Reference

Functions

def dict_to_sequence
 
def super_len
 
def get_netrc_auth
 
def guess_filename
 
def from_key_val_list
 
def to_key_val_list
 
def parse_list_header
 
def parse_dict_header
 
def unquote_header_value
 
def dict_from_cookiejar
 
def add_dict_to_cookiejar
 
def get_encodings_from_content
 
def get_encoding_from_headers
 
def stream_decode_response_unicode
 
def iter_slices
 
def get_unicode_from_response
 
def unquote_unreserved
 
def requote_uri
 
def address_in_network
 
def dotted_netmask
 
def is_ipv4_address
 
def is_valid_cidr
 
def should_bypass_proxies
 
def get_environ_proxies
 
def default_user_agent
 
def default_headers
 
def parse_header_links
 
def guess_json_utf
 
def prepend_scheme_if_needed
 
def get_auth_from_url
 
def to_native_string
 

Variables

tuple _hush_pyflakes = (RequestsCookieJar,)
 
tuple NETRC_FILES = ('.netrc', '_netrc')
 
tuple DEFAULT_CA_BUNDLE_PATH = certs.where()
 
tuple UNRESERVED_SET
 
string _null = '\x00'
 
int _null2 = _null*2
 
int _null3 = _null*3
 

Function Documentation

def pip._vendor.requests.utils.add_dict_to_cookiejar (   cj,
  cookie_dict 
)
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.
def pip._vendor.requests.utils.address_in_network (   ip,
  net 
)
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
def pip._vendor.requests.utils.default_headers ( )
def pip._vendor.requests.utils.default_user_agent (   name = "python-requests")
Return a string representing the default user agent.
def pip._vendor.requests.utils.dict_from_cookiejar (   cj)
Returns a key/value dictionary from a CookieJar.

:param cj: CookieJar object to extract cookies from.
def pip._vendor.requests.utils.dict_to_sequence (   d)
Returns an internal sequence dictionary update.
def pip._vendor.requests.utils.dotted_netmask (   mask)
Converts mask from /xx format to xxx.xxx.xxx.xxx
Example: if mask is 24 function returns 255.255.255.0
def pip._vendor.requests.utils.from_key_val_list (   value)
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')])
def pip._vendor.requests.utils.get_auth_from_url (   url)
Given a url with authentication components, extract them into a tuple of
username,password.
def pip._vendor.requests.utils.get_encoding_from_headers (   headers)
Returns encodings from given HTTP Header Dict.

:param headers: dictionary to extract encoding from.
def pip._vendor.requests.utils.get_encodings_from_content (   content)
Returns encodings from given content string.

:param content: bytestring to extract encodings from.
def pip._vendor.requests.utils.get_environ_proxies (   url)
Return a dict of environment proxies.
def pip._vendor.requests.utils.get_netrc_auth (   url)
Returns the Requests tuple auth for a given url from netrc.
def pip._vendor.requests.utils.get_unicode_from_response (   r)
Returns 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
def pip._vendor.requests.utils.guess_filename (   obj)
Tries to guess the filename of the given object.
def pip._vendor.requests.utils.guess_json_utf (   data)
def pip._vendor.requests.utils.is_ipv4_address (   string_ip)
def pip._vendor.requests.utils.is_valid_cidr (   string_network)
Very simple check of the cidr format in no_proxy variable
def pip._vendor.requests.utils.iter_slices (   string,
  slice_length 
)
Iterate over slices of a string.
def pip._vendor.requests.utils.parse_dict_header (   value)
Parse 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`
def pip._vendor.requests.utils.parse_header_links (   value)
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"
def pip._vendor.requests.utils.parse_list_header (   value)
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`
def pip._vendor.requests.utils.prepend_scheme_if_needed (   url,
  new_scheme 
)
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.
def pip._vendor.requests.utils.requote_uri (   uri)
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.
def pip._vendor.requests.utils.should_bypass_proxies (   url)
Returns whether we should bypass proxies or not.
def pip._vendor.requests.utils.stream_decode_response_unicode (   iterator,
  r 
)
Stream decodes a iterator.
def pip._vendor.requests.utils.super_len (   o)
def pip._vendor.requests.utils.to_key_val_list (   value)
Take 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.
def pip._vendor.requests.utils.to_native_string (   string,
  encoding = 'ascii' 
)
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.
def pip._vendor.requests.utils.unquote_header_value (   value,
  is_filename = False 
)
def pip._vendor.requests.utils.unquote_unreserved (   uri)
Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded.

Variable Documentation

tuple pip._vendor.requests.utils._hush_pyflakes = (RequestsCookieJar,)
string pip._vendor.requests.utils._null = '\x00'
int pip._vendor.requests.utils._null2 = _null*2
int pip._vendor.requests.utils._null3 = _null*3
tuple pip._vendor.requests.utils.DEFAULT_CA_BUNDLE_PATH = certs.where()
tuple pip._vendor.requests.utils.NETRC_FILES = ('.netrc', '_netrc')
tuple pip._vendor.requests.utils.UNRESERVED_SET
Initial value:
1 = frozenset(
2  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
3  + "0123456789-._~")

Copyright 2014 Google Inc. All rights reserved.