All Samples(1396) | Call(1238) | Derive(0) | Import(158)
Quote the query fragment of a URL; replacing ' ' with '+'
def quote_plus(s, safe=''):
"""Quote the query fragment of a URL; replacing ' ' with '+'"""
if ' ' in s:
s = quote(s, safe + ' ')
return s.replace(' ', '+')
return quote(s, safe)
u'²âÊÔ'.encode('gbk')
#=========
from urllib import quote, quote_plus, unquote, urlencode
value = unicode('²âÊÔ','cp936')
quote(value.encode('utf-8'), '/')
quote_plus(value.encode('utf-8'))
src/r/e/remoteobjects-1.1.1/examples/twitter.py remoteobjects(Download)
import httplib from optparse import OptionParser import sys from urllib import urlencode, quote_plus from urlparse import urljoin, urlunsplit from httplib2 import Http
def get_user(cls, http=None, **kwargs):
url = '/users/show'
if 'id' in kwargs:
url += '/%s.json' % quote_plus(kwargs['id'])
else:
url += '.json'
query = urlencode(filter(lambda x: x in ('screen_name', 'user_id'), kwargs))
def get_related(cls, relation, http=None, **kwargs):
url = '/statuses/%s' % relation
if 'id' in kwargs:
url += '/%s.json' % quote_plus(kwargs['id'])
else:
url += '.json'
query = urlencode(filter(lambda x: x in ('screen_name', 'user_id', 'page'), kwargs))
def user(cls, http=None, **kwargs):
url = '/statuses/user_timeline'
if 'id' in kwargs:
url += '/%s.json' % quote_plus(kwargs['id'])
else:
url += '.json'
query = urlencode(filter(lambda x: x in ('screen_name', 'user_id', 'since_id', 'max_id', 'page'), kwargs))
src/b/i/BigBlueButton-PythonExample-HEAD/api.py BigBlueButton-PythonExample(Download)
#! coding: utf-8 # pylint: disable-msg=W0311 from uuid import uuid4 from time import time from random import randint from hashlib import md5, sha1 from urllib import urlopen, quote_plus
def _create(name, meeting_id, attendee_pw, moderator_pw):
query = "name=%s&meetingID=%s&attendeePW=%s&moderatorPW=%s&logoutURL=%s" % \
(quote_plus(name), meeting_id, attendee_pw, moderator_pw, settings.logout_url)
api_uri = "create?%s" % query
uri = get_secure_uri(api_uri)
url = api_prefix + uri
return_code = xml2dict(urlopen(url).read()).get("returncode")
src/v/o/votv-HEAD/trunk/portable/xhtmltools.py votv(Download)
import xml.sax.saxutils import xml.dom import re from urllib import quote, quote_plus, unquote from HTMLParser import HTMLParser import types import random
def URLEncodeDict(orig):
output = []
for key in orig.keys():
if type(orig[key]) is types.ListType:
for value in orig[key]:
output.append('%s=%s' % (quote_plus(key), quote_plus(value)))
else:
output.append('%s=%s' % (quote_plus(key), quote_plus(orig[key])))
for key, value in postVars.items():
output.append('--%s\r\n' % boundary)
output.append('Content-Disposition: form-data; name="%s"\r\n\r\n' %
quote_plus(key))
if isinstance(value, unicode):
value = value.encode('utf8', 'xmlcharrefreplace')
output.append(value)
output.append('\r\n')
if files is not None:
for key in files.keys():
output.append('--%s\r\n' % boundary)
output.append('Content-Disposition: form-data; name="%s"; filename="%s"\r\n' %
(quote_plus(key),
quote_plus(files[key]['filename'])))
src/v/o/votv-HEAD/portable/xhtmltools.py votv(Download)
import xml.sax.saxutils import xml.dom import re from urllib import quote, quote_plus, unquote from HTMLParser import HTMLParser import types import random
def URLEncodeDict(orig):
output = []
for key in orig.keys():
if type(orig[key]) is types.ListType:
for value in orig[key]:
output.append('%s=%s' % (quote_plus(key), quote_plus(value)))
else:
output.append('%s=%s' % (quote_plus(key), quote_plus(orig[key])))
for key, value in postVars.items():
output.append('--%s\r\n' % boundary)
output.append('Content-Disposition: form-data; name="%s"\r\n\r\n' %
quote_plus(key))
if isinstance(value, unicode):
value = value.encode('utf8', 'xmlcharrefreplace')
output.append(value)
output.append('\r\n')
if files is not None:
for key in files.keys():
output.append('--%s\r\n' % boundary)
output.append('Content-Disposition: form-data; name="%s"; filename="%s"\r\n' %
(quote_plus(key),
quote_plus(files[key]['filename'])))
src/x/b/xbmc-HEAD/addons/script.recentlyadded/default.py xbmc(Download)
import xbmc from xbmcgui import Window from urllib import quote_plus, unquote_plus import re import sys import os import random
self.WINDOW.setProperty( "Database.Totals", "true" )
# sql statement for movie totals
sql_totals = "select count(1), count(playCount), movieview.* from movieview group by lastPlayed"
totals_xml = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sql_totals ), )
records = re.findall( "<record>(.+?)</record>", totals_xml, re.DOTALL )
# initialize our list
movies_totals = [ 0 ] * 7
movies_totals[ 6 ] = datetime.date( int( date[ 0 ] ), int( date[ 1 ] ), int( date[ 2 ] ) ).strftime( date_format ) # last played
# sql statement for music videos totals
sql_totals = "select count(1), count(playCount) from musicvideoview"
totals_xml = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sql_totals ), )
mvideos_totals = re.findall( "<field>(.+?)</field>", totals_xml, re.DOTALL )
# sql statement for tv shows/episodes totals
sql_totals = "SELECT tvshow.*, path.strPath AS strPath, counts.totalcount AS totalCount, counts.watchedcount AS watchedCount, counts.totalcount=counts.watchedcount AS watched FROM tvshow JOIN tvshowlinkpath ON tvshow.idShow=tvshowlinkpath.idShow JOIN path ON path.idpath=tvshowlinkpath.idPath LEFT OUTER join (SELECT tvshow.idShow AS idShow, count(1) AS totalCount, count(files.playCount) AS watchedCount FROM tvshow JOIN tvshowlinkepisode ON tvshow.idShow=tvshowlinkepisode.idShow JOIN episode ON episode.idEpisode=tvshowlinkepisode.idEpisode JOIN files ON files.idFile=episode.idFile GROUP BY tvshow.idShow) counts ON tvshow.idShow=counts.idShow"
totals_xml = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sql_totals ), )
# sql statement for tv albums/songs totals
sql_totals = "select count(1), count(distinct strAlbum), count(distinct strArtist) from songview"
totals_xml = xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_totals ), )
music_totals = re.findall( "<field>(.+?)</field>", totals_xml, re.DOTALL )
# set properties
# movies not finished
sql_movies = "select movieview.*, bookmark.timeInSeconds from movieview join bookmark on (movieview.idFile = bookmark.idFile) %sorder by movieview.c00 limit %d" % ( unplayed, self.LIMIT, )
# query the database
movies_xml = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sql_movies ), )
# separate the records
movies = re.findall( "<record>(.+?)</record>", movies_xml, re.DOTALL )
# enumerate thru our records and set our properties
# tv shows not finished
sql_episodes = "select episodeview.*, bookmark.timeInSeconds from episodeview join bookmark on (episodeview.idFile = bookmark.idFile) %sorder by episodeview.strTitle limit %d" % ( unplayed, self.LIMIT, )
# query the database
episodes_xml = xbmc.executehttpapi( "QueryVideoDatabase(%s)" % quote_plus( sql_episodes ), )
# separate the records
episodes = re.findall( "<record>(.+?)</record>", episodes_xml, re.DOTALL )
# enumerate thru our records and set our properties
def _fetch_music_info( self ):
# sql statement
if ( self.ALBUMS ):
sql_music = "select idAlbum from albumview order by idAlbum desc limit %d" % ( self.LIMIT, )
# query the database for recently added albums
music_xml = xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_music ), )
# separate the records
# enumerate thru albums and fetch info
for album in albums:
# query the database and add result to our string
music_xml += xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_music % ( album.replace( "<field>", "" ).replace( "</field>", "" ), ) ), )
else:
# set our unplayed query
unplayed = ( "", "where lastplayed isnull ", )[ self.UNPLAYED ]
# sql statement
sql_music = "select * from songview %sorder by idSong desc limit %d" % ( unplayed, self.LIMIT, )
# query the database
music_xml = xbmc.executehttpapi( "QueryMusicDatabase(%s)" % quote_plus( sql_music ), )
src/w/i/wikitools-1.1.1/wikitools/api.py wikitools(Download)
import re import time import sys from urllib import quote_plus, _is_unicode try: from poster.encode import multipart_encode canupload = True
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)
# 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("utf8","replace"))
l.append(k + '=' + v)
else:
try:
# is this a sufficient test for sequence-ness?
x = len(v)
except TypeError:
# not a sequence
v = quote_plus(str(v))
else:
# loop over the sequence
for elt in v:
l.append(k + '=' + quote_plus(str(elt)))
return '&'.join(l)
src/z/o/Zope2-2.12.12/src/DocumentTemplate/DT_Var.py Zope2(Download)
import string, re, sys from cgi import escape from urllib import quote, quote_plus, unquote, unquote_plus # for import by other modules, dont remove! from DocumentTemplate.html_quote import html_quote
def url_quote_plus(v, name='(Unknown name)', md={}):
if isinstance(v, unicode):
# quote_plus does not handle unicode. Encoding to a "safe"
# intermediate encoding before quoting, then unencoding the result.
return quote_plus(v.encode('utf-8')).decode('UTF-8')
return quote_plus(str(v))
src/p/y/pyallegro-HEAD/web/rest2web/rest2web/pythonutils/cgiutils.py pyallegro(Download)
def formencode(theform):
"""
A version that turns a cgi form into a single string.
It only handles single and list values, not multipart.
This allows the contents of a form requested to be encoded into a single value as part of another request.
"""
from urllib import urlencode, quote_plus
return quote_plus(urlencode(getall(theform)))
src/n/l/nltk-HEAD/trunk/nltk/nltk/wordnet/browser/util.py nltk(Download)
# For license information, see LICENSE.TXT from urllib import quote_plus, unquote_plus import itertools as it from nltk import defaultdict
descr = synset.pos
else:
descr = synset.pos[0]
s = '<li><a href="' + typ + quote_plus(word + '#' + synset_key + '#' + \
str(u_c)) + '">' + typ + ':</a>' + ' (' + descr + ') '
if isinstance(s_or_w, tuple): # It's a word
s += '<a href="M' + quote_plus(oppo + '#' + str(uniq_cntr())) + \
'">' + oppo + '</a> ' + form_str
for w in forms:
pos,offset,ind = w
w = dictionary.synset(pos, offset).words[ind]
w = w.replace('_', ' ')
s += '<a href="M' + quote_plus(w + '#' + str(uniq_cntr())) + \
if w.lower() == word:
s+= _bold(w) + ', '
else:
s += '<a href="M' + quote_plus(w + '#' + str(uniq_cntr())) + \
'">' + w + '</a>, '
s = s[:-2] + ' ('
# Format the gloss part
def _rel_ref(word, synset_keys, rel):
return '<a href="R%s"><i>%s</i></a>' % \
(quote_plus('#'.join((word, synset_keys, rel, str(uniq_cntr())))),
rel)
def _anto_or_similar_anto(synset):
anto = relations_2(synset, rel_name=ANTONYM, word_match=True)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next