• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(4566)  |  Call(3898)  |  Derive(0)  |  Import(668)
quote('abc def') -> 'abc%20def'

Each part of a URL, e.g. the path info, the query, etc., has a
different set of reserved characters that must be quoted.

RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
the following reserved characters.

reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
              "$" | ","

Each of these characters is reserved in some component of a URL,
but not necessarily in all of them.

By default, the quote function is intended for quoting the path
section of a URL.  Thus, it will not encode '/'.  This character
is reserved, but in typical usage the quote function is being
called on a path where the existing slash characters are used as
reserved characters.

        def quote(s, safe='/'):
    """quote('abc def') -> 'abc%20def'

    Each part of a URL, e.g. the path info, the query, etc., has a
    different set of reserved characters that must be quoted.

    RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
    the following reserved characters.

    reserved    = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
                  "$" | ","

    Each of these characters is reserved in some component of a URL,
    but not necessarily in all of them.

    By default, the quote function is intended for quoting the path
    section of a URL.  Thus, it will not encode '/'.  This character
    is reserved, but in typical usage the quote function is being
    called on a path where the existing slash characters are used as
    reserved characters.
    """
    # fastpath
    if not s:
        return s
    cachekey = (safe, always_safe)
    try:
        (quoter, safe) = _safe_quoters[cachekey]
    except KeyError:
        safe_map = _safe_map.copy()
        safe_map.update([(c, c) for c in safe])
        quoter = safe_map.__getitem__
        safe = always_safe + safe
        _safe_quoters[cachekey] = (quoter, safe)
    if not s.rstrip(safe):
        return s
    return ''.join(map(quoter, s))
        


src/q/u/querychinesesto-HEAD/prog/gbk-encode-example.py   querychinesesto(Download)
u'²âÊÔ'.encode('gbk')
 
#=========
from urllib import quote, quote_plus, unquote, urlencode
 
value = unicode('²âÊÔ','cp936')
 
quote(value.encode('utf-8'), '/')

src/f/r/freebase-1.0.6/examples/freebase-images-appengine/freebase/api/session.py   freebase(Download)
    except ImportError:
        raise Exception("unable to import simplejson")
try:
    from urllib import quote as urlquote
except ImportError:
    from urlib_stub import quote as urlquote
import pprint

src/v/e/velocikit-HEAD/trunk/src/velocikit/examples/rssreader/rssutils.py   velocikit(Download)
 
import urllib2
from urllib import quote
from xml.dom import minidom
import StringIO
 
 

src/v/e/velocikit-HEAD/src/velocikit/examples/rssreader/rssutils.py   velocikit(Download)
 
import urllib2
from urllib import quote
from xml.dom import minidom
import StringIO
 
 

src/g/o/google-app-engine-HEAD/lib/django/django/http/__init__.py   google-app-engine(Download)
import os
from Cookie import SimpleCookie
from pprint import pformat
from urllib import urlencode, quote
from django.utils.datastructures import MultiValueDict
 
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
    def __init__(self, redirect_to):
        HttpResponse.__init__(self)
        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
        self.status_code = 302
 
class HttpResponsePermanentRedirect(HttpResponse):
    def __init__(self, redirect_to):
        HttpResponse.__init__(self)
        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)

src/g/o/google_appengine-HEAD/lib/django/django/http/__init__.py   google_appengine(Download)
import os
from Cookie import SimpleCookie
from pprint import pformat
from urllib import urlencode, quote
from django.utils.datastructures import MultiValueDict
 
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
    def __init__(self, redirect_to):
        HttpResponse.__init__(self)
        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
        self.status_code = 302
 
class HttpResponsePermanentRedirect(HttpResponse):
    def __init__(self, redirect_to):
        HttpResponse.__init__(self)
        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)

src/t/w/twotp-0.7/examples/rabbitmq-webui.py   twotp(Download)
"""
 
import sys
from urllib import quote
 
from Cheetah.Template import Template
 

src/c/u/cubicweb-3.9.8/req.py   cubicweb(Download)
 
from warnings import warn
from urlparse import urlsplit, urlunsplit
from urllib import quote as urlquote, unquote as urlunquote
from datetime import time, datetime, timedelta
from cgi import parse_qs, parse_qsl
 
    def url_quote(self, value, safe=''):
        """urllib.quote is not unicode safe, use this method to do the
        necessary encoding / decoding. Also it's designed to quote each
        part of a url path and so the '/' character will be encoded as well.
        """
        if isinstance(value, unicode):
            quoted = urlquote(value.encode(self.encoding), safe=safe)
            return unicode(quoted, self.encoding)
        return urlquote(str(value), safe=safe)

src/s/o/sonicbot-HEAD/SonicMail/bbcode.py   sonicbot(Download)
__version__ = "1.1.0"
 
import re
from urllib import quote, unquote, quote_plus
from urlparse import urlparse, urlunparse
 
pygments_available = True
 
        #Quote the url
        #self.url="http:"+urlunparse( map(quote, (u"",)+url_parsed[1:]) )
        self.url= unicode( urlunparse([quote(component, safe='/=&?:+') for component in url_parsed]) )
 
        if not self.url:
            return u""

src/p/4/p4a.videoembed-1.1/p4a/videoembed/utils.py   p4a.videoembed(Download)
import urllib2
from xml.dom import minidom
from xml.sax import saxutils
from urlparse import urlsplit
from urllib import quote
from p4a.videoembed._cache import BufferCache
 
    """
    # Splits and encodes the url, and breaks the query string into a dict
    proto, host, path, query, fragment = urlsplit(url)
    path = quote(path)
    query = quote(query, safe='&=')
    fragment = quote(fragment, safe='')
    query_elems = {}

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next