Did I find the right examples for you? yes no

All Samples(34)  |  Call(27)  |  Derive(0)  |  Import(7)
Encode a sequence of two-element tuples or dictionary into a URL query string.

If any values in the query arg are sequences and doseq is true, each
sequence element is converted to a separate parameter.

If the query arg is a sequence of two-element tuples, the order of the
parameters in the output will match the order of parameters in the
input.

        def urlencode(query, doseq=0):
    """Encode a sequence of two-element tuples or dictionary into a URL query string.

    If any values in the query arg are sequences and doseq is true, each
    sequence element is converted to a separate parameter.

    If the query arg is a sequence of two-element tuples, the order of the
    parameters in the output will match the order of parameters in the
    input.
    """

    if hasattr(query,"items"):
        # mapping objects
        query = query.items()
    else:
        # it's a bother at times that strings and string-like objects are
        # sequences...
        try:
            # non-sequence items should not work with len()
            # non-empty strings will fail this
            if len(query) and not isinstance(query[0], tuple):
                raise TypeError
            # zero-length sequences of all types will get here and succeed,
            # but that's a minor nit - since the original implementation
            # allowed empty dicts that type of behavior probably should be
            # preserved for consistency
        except TypeError:
            ty,va,tb = sys.exc_info()
            raise TypeError, "not a valid non-string sequence or mapping object", tb

    l = []
    if not doseq:
        # preserve old behavior
        for k, v in query:
            k = quote_plus(str(k))
            v = quote_plus(str(v))
            l.append(k + '=' + v)
    else:
        for k, v in query:
            k = quote_plus(str(k))
            if isinstance(v, str):
                v = quote_plus(v)
                l.append(k + '=' + v)
            elif _is_unicode(v):
                # is there a reasonable way to convert to ASCII?
                # encode generates a string, but "replace" or "ignore"
                # lose information and "strict" can raise UnicodeError
                v = quote_plus(v.encode("ASCII","replace"))
                l.append(k + '=' + v)
            else:
                try:
                    # is this a sufficient test for sequence-ness?
                    len(v)
                except TypeError:
                    # not a sequence
                    v = quote_plus(str(v))
                    l.append(k + '=' + v)
                else:
                    # loop over the sequence
                    for elt in v:
                        l.append(k + '=' + quote_plus(str(elt)))
    return '&'.join(l)
        


src/b/u/bulbs-0.3.29-20140417/bulbs/rest.py   bulbs(Download)
import bulbs
from bulbs.base import Response
from .utils import json, get_logger, quote, urlencode, encode_dict
 
 
        if params and method is GET:
            params = encode_dict(params)
            uri = "%s?%s" % (uri, urlencode(params))
            content_type = "%s ; charset=utf-8" % self.content_type
            get_headers = {'Content-Type': content_type}

src/m/i/mitmproxy-0.10.1/libmproxy/flow.py   mitmproxy(Download)
        # url-encoded form, leave it alone.
        self.headers["Content-Type"] = [HDR_FORM_URLENCODED]
        self.content = utils.urlencode(odict.lst)
 
    def get_path_components(self):
        """
        scheme, netloc, path, params, _, fragment = urlparse.urlparse(self.get_url())
        query = utils.urlencode(odict.lst)
        self.set_url(urlparse.urlunparse([scheme, netloc, path, params, query, fragment]))
 

src/b/u/bulbs-HEAD/bulbs/rest.py   bulbs(Download)
import bulbs
from bulbs.base import Response
from .utils import json, get_logger, quote, urlencode, encode_dict
 
 
        if params and method is GET:
            params = encode_dict(params)
            uri = "%s?%s" % (uri, urlencode(params))
            content_type = "%s ; charset=utf-8" % self.content_type
            get_headers = {'Content-Type': content_type}

src/p/u/pumblr-0.1.2dev/pumblr/api.py   pumblr(Download)
            password=self._password,
        )
        text = self._check_status_code(url, utils.urlencode(query))
        self._check_we_ll_be_back(text)
        self._authenticated = True
            type=type
        )
        return ApiRead.parse(self._read_json_data(url, utils.urlencode(query)))
 
    def read(self, name, start=0, num=20, type=None, id=None, search=None, tagged=None):
            )
        url = ("http://%s/api/read/json?%s" %
               ((name if '.' in name else '%s.tumblr.com' % name), utils.urlencode(query)))
        # url = "http://%s.tumblr.com/api/read/json?%s" % (name, utils.urlencode(query))
        return ApiRead.parse(self._read_json_data(url))
            'reblog-key':reblog_key
        }
        self._check_status_code(url, utils.urlencode(query))
 
    @_auth_check
            'as':reblog_as,
        }
        self._check_status_code(url, utils.urlencode(query))
 
    @_auth_check

src/p/u/pumblr-HEAD/pumblr/api.py   pumblr(Download)
            password=self._password,
        )
        text = self._check_status_code(url, utils.urlencode(query))
        self._check_we_ll_be_back(text)
        self._authenticated = True
            type=type
        )
        return ApiRead.parse(self._read_json_data(url, utils.urlencode(query)))
 
    def read(self, name, start=0, num=20, type=None, id=None, search=None, tagged=None):
            )
        url = ("http://%s/api/read/json?%s" %
               ((name if '.' in name else '%s.tumblr.com' % name), utils.urlencode(query)))
        # url = "http://%s.tumblr.com/api/read/json?%s" % (name, utils.urlencode(query))
        return ApiRead.parse(self._read_json_data(url))
            'reblog-key':reblog_key
        }
        self._check_status_code(url, utils.urlencode(query))
 
    @_auth_check
            'as':reblog_as,
        }
        self._check_status_code(url, utils.urlencode(query))
 
    @_auth_check

src/p/y/py-oauth2-0.0.8/pyoauth2/libs/connection.py   py-oauth2(Download)
# -*- coding: utf-8 -*-
from .utils import urlencode
 
 
class Connection(object):
    def build_url(cls, url, path='', params={}):
        params = urlencode(params)
        params = '?%s' % params if params else ''
        url = path if path.startswith(('http://', 'https://')) else '%s%s' % (url, path)
        return '%s%s' % (url, params)

src/p/y/py-oauth2-HEAD/pyoauth2/libs/connection.py   py-oauth2(Download)
# -*- coding: utf-8 -*-
from .utils import urlencode
 
 
class Connection(object):
    def build_url(cls, url, path='', params={}):
        params = urlencode(params)
        params = '?%s' % params if params else ''
        url = path if path.startswith(('http://', 'https://')) else '%s%s' % (url, path)
        return '%s%s' % (url, params)

src/d/j/django-paypal-express-checkout-1.7/paypal_express_checkout/forms.py   django-paypal-express-checkout(Download)
)
from .settings import API_URL, LOGIN_URL
from .utils import urlencode
 
 
 
        """
        data = urlencode(post_data)
        try:
            response = urllib2.urlopen(api_url, data=data)
            # we have to do urlencode here to make the post data more readable
            # in the error log
            post_data_encoded = urlencode(post_data)
            self.log_error(
                parsed_response, api_url, request_data=post_data_encoded,
            return LOGIN_URL + token
        elif parsed_response.get('ACK')[0] == 'Failure':
            post_data_encoded = urlencode(post_data)
            self.log_error(
                parsed_response, api_url=api_url,

src/d/j/django-paypal-express-checkout-HEAD/paypal_express_checkout/forms.py   django-paypal-express-checkout(Download)
)
from .settings import API_URL, LOGIN_URL
from .utils import urlencode
 
 
 
        """
        data = urlencode(post_data)
        try:
            response = urllib2.urlopen(api_url, data=data)
            # we have to do urlencode here to make the post data more readable
            # in the error log
            post_data_encoded = urlencode(post_data)
            self.log_error(
                parsed_response, api_url, request_data=post_data_encoded,
            return LOGIN_URL + token
        elif parsed_response.get('ACK')[0] == 'Failure':
            post_data_encoded = urlencode(post_data)
            self.log_error(
                parsed_response, api_url=api_url,

src/d/a/data-gov-in-HEAD/index.py   data-gov-in(Download)
def set_jenv_filters(jenv):
	"""import these python functions as jinja filters"""
	from utils import urlencode
	jenv.filters["urlencode"] = urlencode