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

All Samples(105)  |  Call(90)  |  Derive(0)  |  Import(15)
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/p/y/python-tvrage-HEAD/tvrage/quickinfo.py   python-tvrage(Download)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
 
from urllib2 import urlopen, URLError, quote
from util import _fetch
from exceptions import ShowNotFound
 
BASE_URL = 'http://services.tvrage.com/tools/quickinfo.php'
 
 
def fetch(show, exact=False, ep=None):
    query_string = '?show=' + quote(show)
def fetch(show, exact=False, ep=None):
    query_string = '?show=' + quote(show)
    if exact:
        query_string = query_string + '&exact=1'
    if ep:
        query_string = query_string + '&ep=' + quote(ep)
    resp = _fetch(BASE_URL + query_string).read()

src/p/y/python-ship-HEAD/endicia.py   python-ship(Download)
import re
from urllib2 import Request, urlopen, URLError, quote
import base64
import xml.etree.ElementTree as etree
 
def _normalize_country(country):
    country_lookup = {
        try:
            url_base = u'https://www.envmgr.com/LabelService/EwsLabelService.asmx' if self.debug else u'https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx'
            full_url = u'%s/%s' % (url_base, self.url)
            data = '%s=%s' % (self.api, quote(request_text))
            request = Request(full_url, data)
            response_text = urlopen(request).read()
            response = self.__parse_response(response_text)
        try:
            url_base = u'https://www.envmgr.com/LabelService/EwsLabelService.asmx' if self.debug else u'https://LabelServer.Endicia.com/LabelService/EwsLabelService.asmx'
            full_url = u'%s?method=RefundRequest' % url_base
            data = 'XMLInput=%s' % quote(request_text)
            request = Request(full_url, data)
            response_text = urlopen(request).read()
            response = self.__parse_response(response_text)

src/p/y/python-ship-HEAD/USPS/USPS.py   python-ship(Download)
from urllib2 import Request, urlopen, URLError, quote
import base64
import xml.etree.ElementTree as etree
 
def indent(elem, level=0):
    """Indents an etree element so printing that element is actually human-readable"""
    i = "\n" + level*"  "
    def Send(self):
        root = self._get_xml()
        request_text = etree.tostring(root)
 
        try:
            full_url = '%s%s' % (self.url, quote(request_text))
            request = Request(full_url)

src/p/y/python-amazon-product-api-gae-HEAD/amazonproduct.py   python-amazon-product-api-gae(Download)
import socket
from time import strftime, gmtime
from urlparse import urlsplit
from urllib2 import quote, urlopen, HTTPError
from BeautifulSoup import BeautifulSoup
 
LOCALES = {
 
        # create signature
        keys = sorted(qargs.keys())
        args = '&'.join('%s=%s' % (key, quote(str(qargs[key]))) 
                        for key in keys)
 
        msg = 'GET'
        msg += '\n' + self.host
        msg += '\n' + self.path
        msg += '\n' + args.encode('utf-8')
 
        signature = quote(
            b64encode(hmac.new(self.secret_key, msg, sha256).digest()))

src/m/o/motools-HEAD/myspace-serv/trunk/src/helpers/create_countries_dict.py   motools(Download)
 
store in a pickle to be used by myspace2rdf.py
'''
from urllib2 import urlopen, quote
from xml.dom import minidom
import cPickle as pickle
 
GEO_WS = 'http://ws.geonames.org/search?'
GEO_URI_BASE = 'http://sws.geonames.org/'
 
def queryGeonames(country):
    resp = urlopen(GEO_WS+'q=%s&maxRows=1' % quote(country))

src/w/e/WebService-Amazon-ProductAdvertising-HEAD/lib/webservice/amazon.py   WebService-Amazon-ProductAdvertising(Download)
from base64 import b64encode
import hmac
from time import strftime, gmtime
from urllib2 import quote, urlopen
from xml2obj import Xml2Obj
 
try:
    args['AWSAccessKeyId'] = self.getLicenseKey()
 
    keys = sorted(args.keys())
    return '&'.join('%s=%s' % (key, quote(str(args[key]))) for key in keys)
 
  def makeSignature(self, args):
    param = self.makeParam(args)
    msg = 'GET'
    msg += '\n' + LOCALE_DOMAINS[self.getLocale()]
    msg += '\n' + "/onca/xml"
    msg += '\n' + param.encode('utf-8')
    return quote(b64encode(hmac.new(self.getSecretLicenseKey(), msg, sha256).digest()))

src/p/y/python-tvrage-HEAD/tvrage/feeds.py   python-tvrage(Download)
# POSSIBILITY OF SUCH DAMAGE.
 
from util import _fetch
from urllib2 import quote
 
try:
    import xml.etree.cElementTree as et
def search(show, node=None):
    return _fetch_xml(BASE_URL % ('search','show', quote(show)), node)
 
def full_search(show, node=None):
    return _fetch_xml(BASE_URL % ('full_search','show', quote(show)), node)
 
def showinfo(sid, node=None):

src/m/o/motools-HEAD/myspace-serv/trunk/src/myspace/myspace2rdf.py   motools(Download)
from scraping import scrapePage, scrapePageWhile
import mopy
import re
from urllib2 import quote
from xml.dom import minidom
import os
from BeautifulSoup import BeautifulSoup as BS
        genres = []
        for gnum in genreNums:
            try:
                genre = mopy.mo.Genre(uris.myspaceOntology+quote(uris.genreDict[int(gnum)]))
            except KeyError:
                pass
            else:

src/m/e/Mezzanine-0.8.4/mezzanine/twitter/models.py   Mezzanine(Download)
 
import re
from datetime import datetime, timedelta
from time import timezone
from urllib2 import urlopen, quote
 
from django.db import models
                "=true" % self.value.lstrip("@").replace("/", "/lists/"))
        elif self.type == "search":
            url = ("http://search.twitter.com/search.json?q=%s" %
                quote(self.value))
        else:
            return
        try:

src/p/y/python-wow-HEAD/wow/fetch.py   python-wow(Download)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
 
from urllib2 import urlopen, URLError, quote, Request
 
try:
    import xml.etree.cElementTree as et

  1 | 2  Next