All Samples(445) | Call(353) | Derive(0) | Import(92)
Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The data argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).
def urlunsplit(data):
"""Combine the elements of a tuple as returned by urlsplit() into a
complete URL as a string. The data argument can be any five-item iterable.
This may result in a slightly different, but equivalent URL, if the URL that
was parsed originally had unnecessary delimiters (for example, a ? with an
empty query; the RFC states that these are equivalent)."""
scheme, netloc, url, query, fragment = data
if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
if url and url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
if scheme:
url = scheme + ':' + url
if query:
url = url + '?' + query
if fragment:
url = url + '#' + fragment
return url
from optparse import OptionParser import sys from urllib import urlencode, quote_plus from urlparse import urljoin, urlunsplit from httplib2 import Http
else:
url += '.json'
query = urlencode(filter(lambda x: x in ('screen_name', 'user_id'), kwargs))
url = urlunsplit((None, None, url, query, None))
return cls.get(urljoin(Twitter.endpoint, url), http=http)
def get_messages(cls, http=None, **kwargs):
url = '/direct_messages.json'
query = urlencode(filter(lambda x: x in ('since_id', 'page'), kwargs))
url = urlunsplit((None, None, url, query, None))
return cls.get(urljoin(Twitter.endpoint, url), http=http)
@classmethod
def get_sent_messages(cls, http=None, **kwargs):
url = '/direct_messages/sent.json'
query = urlencode(filter(lambda x: x in ('since_id', 'page'), kwargs))
url = urlunsplit((None, None, url, query, None))
else:
url += '.json'
query = urlencode(filter(lambda x: x in ('screen_name', 'user_id', 'page'), kwargs))
url = urlunsplit((None, None, url, query, None))
return cls.get(urljoin(Twitter.endpoint, url), http=http)
def friends(cls, http=None, **kwargs):
query = urlencode(filter(lambda x: x in ('since_id', 'max_id', 'count', 'page'), kwargs))
url = urlunsplit((None, None, '/statuses/friends_timeline.json', query, None))
return cls.get(urljoin(Twitter.endpoint, url), http=http)
@classmethod
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))
url = urlunsplit((None, None, url, query, None))
def mentions(cls, http=None, **kwargs):
query = urlencode(filter(lambda x: x in ('since_id', 'max_id', 'page'), kwargs))
url = urlunsplit((None, None, '/statuses/mentions.json', query, None))
return cls.get(urljoin(Twitter.endpoint, url), http=http)
class Twitter(Http):
src/t/w/twitstream-HEAD/examples/warehouse.py twitstream(Download)
#!/usr/bin/env python import sys import twitstream from urlparse import urlunsplit, urlsplit from binascii import unhexlify, hexlify
def __init__(self, location=None, port=None, path=''):
lp = list([location or 'localhost', port or 5984])
lp[1] = str(lp[1])
dburl = urlunsplit(('http', ':'.join(lp), '', '', ''))
self.conn = self.Server(dburl)
if not path:
path = 'test'
src/g/o/googletransitdatafeed-HEAD/python/examples/google_random_queries.py googletransitdatafeed(Download)
"dirflg": "r",
"ie": "UTF8",
"oe": "UTF8"}
url = urlparse.urlunsplit(("http", "maps.google.com", "/maps",
urllib.urlencode(params), ""))
return url
src/n/o/notmm-0.4.1/examples/lib/satchmo_store/shop/config.py notmm(Download)
SHOP_GROUP = ConfigurationGroup('SHOP', _('Satchmo Shop Settings'), ordering=0)
default_icon_url = urlparse.urlunsplit(
('file',
'',
os.path.join(settings.MEDIA_ROOT, 'images/sample-logo.bmp'),
'',
src/p/y/python-typepad-api-HEAD/typepad/tpclient.py python-typepad-api(Download)
# The URI is already signed. Don't do anything.
return
uri = urlparse.urlunsplit((self.http.default_scheme, self.host) + partial_uri[2:])
req = self.signed_request(uri, method)
headers.update(req.to_header())
def add_credentials(self, name, password, domain=""):
endparts = urlparse.urlsplit(self.endpoint)
if domain == '':
domain = endparts[1]
if isinstance(name, oauth.OAuthConsumer) and domain == endparts[1]:
# We're adding TypePad credentials, so upgrade to HTTPS.
self.endpoint = urlparse.urlunsplit(('https',) + endparts[1:])
super(TypePadClient, self).add_credentials(name, password, domain)
def clear_credentials(self):
super(TypePadClient, self).clear_credentials()
# We cleared our TypePad credentials too, so downgrade to HTTP.
endparts = urlparse.urlsplit(self.endpoint)
self.endpoint = urlparse.urlunsplit(('http',) + endparts[1:])
src/t/y/typepad-2.0/typepad/tpclient.py typepad(Download)
# The URI is already signed. Don't do anything.
return
uri = urlparse.urlunsplit((self.http.default_scheme, self.host) + partial_uri[2:])
req = self.signed_request(uri, method)
headers.update(req.to_header())
def add_credentials(self, name, password, domain=""):
endparts = urlparse.urlsplit(self.endpoint)
if domain == '':
domain = endparts[1]
if isinstance(name, oauth.OAuthConsumer) and domain == endparts[1]:
# We're adding TypePad credentials, so upgrade to HTTPS.
self.endpoint = urlparse.urlunsplit(('https',) + endparts[1:])
super(TypePadClient, self).add_credentials(name, password, domain)
def clear_credentials(self):
super(TypePadClient, self).clear_credentials()
# We cleared our TypePad credentials too, so downgrade to HTTP.
endparts = urlparse.urlsplit(self.endpoint)
self.endpoint = urlparse.urlunsplit(('http',) + endparts[1:])
src/d/j/django-faces-0.2.1/django_faces/models.py django-faces(Download)
if pos != -1:
path = path[:pos+1]
urls_to_try = (
urlparse.urlunsplit((protocol, host, path + 'pavatar.png', '', '')),
urlparse.urlunsplit((protocol, host, 'pavatar.png', '', '')),
)
for url in urls_to_try:
path = path[:pos+1]
urls_to_try = (
urlparse.urlunsplit((protocol, host, path + 'favicon.png', '', '')),
urlparse.urlunsplit((protocol, host, path + 'favicon.ico', '', '')),
urlparse.urlunsplit((protocol, host, 'favicon.png', '', '')),
urlparse.urlunsplit((protocol, host, 'favicon.ico', '', '')),
src/s/c/scrapy-HEAD/scrapy/utils/url.py scrapy(Download)
path += '/'
else:
path = '/'
return urlparse.urlunsplit((scheme, netloc, path, query, ''))
def is_url(text):
return text.partition("://")[0] in ('file', 'http', 'https')
src/e/n/enpraxis.educommons-3.2.1-final/enpraxis/educommons/extras/html2captioned.py enpraxis.educommons(Download)
from Products.CMFCore.utils import getToolByName import re from cgi import escape from urlparse import urlsplit, urljoin, urlunsplit from urllib import unquote_plus, quote_plus from Acquisition import aq_base from htmlentitydefs import name2codepoint
scheme, netloc, path, query, fragment = urlsplit(absurl)
path = path.strip('/')
tail = urlunsplit(('','','',query,fragment))
absurl = urlunsplit((scheme,netloc,path,'',''))
if 'resolveuid/' in absurl:
pathparts.pop(0)
return '/'.join(pathparts), urlunsplit(('','','',query,fragment))
def htmlchanges(data, changes):
out = []
src/p/r/Products.kupu-1.4.16/Products/kupu/plone/html2captioned.py Products.kupu(Download)
from Products.CMFCore.utils import getToolByName import re from cgi import escape from urlparse import urlsplit, urljoin, urlunsplit from urllib import unquote_plus, quote_plus from Acquisition import aq_base from htmlentitydefs import name2codepoint
scheme, netloc, path, query, fragment = urlsplit(absurl)
path = path.strip('/')
tail = urlunsplit(('','','',query,fragment))
absurl = urlunsplit((scheme,netloc,path,'',''))
if 'resolveuid/' in absurl:
pathparts.pop(0)
return '/'.join(pathparts), urlunsplit(('','','',query,fragment))
def htmlchanges(data, changes):
out = []
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next