All Samples(153) | Call(143) | Derive(0) | Import(10)
Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.
def urljoin(base, url, allow_fragments=True):
"""Join a base URL and a possibly relative URL to form an absolute
interpretation of the latter."""
if not base:
return url
if not url:
return base
bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
urlparse(base, '', allow_fragments)
scheme, netloc, path, params, query, fragment = \
urlparse(url, bscheme, allow_fragments)
if scheme != bscheme or scheme not in uses_relative:
return url
if scheme in uses_netloc:
if netloc:
return urlunparse((scheme, netloc, path,
params, query, fragment))
netloc = bnetloc
if path[:1] == '/':
return urlunparse((scheme, netloc, path,
params, query, fragment))
if not path:
path = bpath
if not params:
params = bparams
else:
path = path[:-1]
return urlunparse((scheme, netloc, path,
params, query, fragment))
if not query:
query = bquery
return urlunparse((scheme, netloc, path,
params, query, fragment))
segments = bpath.split('/')[:-1] + path.split('/')
# XXX The stuff below is bogus in various ways...
if segments[-1] == '.':
segments[-1] = ''
while '.' in segments:
segments.remove('.')
while 1:
i = 1
n = len(segments) - 1
while i < n:
if (segments[i] == '..'
and segments[i-1] not in ('', '..')):
del segments[i-1:i+1]
break
i = i+1
else:
break
if segments == ['', '..']:
segments[-1] = ''
elif len(segments) >= 2 and segments[-1] == '..':
segments[-2:] = ['']
return urlunparse((scheme, netloc, '/'.join(segments),
params, query, fragment))
## 4) definitely evil tags which denote a region, we strip the entire region from PassSGMLParser import PassSGMLParser from urllib import basejoin import string, sys import neo_cgi
pass
else:
if self._base and name in ["action", "href", "src", "lowsrc", "background"]:
value = basejoin (self._base, value)
if name in ["action", "href", "src", "lowsrc", "background"]:
value = 'http://www.google.com/url?sa=D&q=%s' % (neo_cgi.urlEscape(value))
if self._new_window and tag == "a" and name == "target": continue
src/n/o/notmm-0.4.1/examples/lib/satchmo_store/settings.py notmm(Download)
# this is an extremely simple Satchmo standalone store. from store.settings import * import logging from urllib import basejoin import os, os.path
src/n/o/notmm-0.4.1/examples/satchmo_store/local_settings.py notmm(Download)
# this is an extremely simple Satchmo standalone store. from store.settings import * import logging from urllib import basejoin import os, os.path
src/p/y/pyhjb-0.5.1/hjb/hjbclient.py pyhjb(Download)
""" Defines classes and functions for accessing the messaging services of a JMS Provider via a HJB server. """ from httplib import HTTPConnection from urllib import urlencode, basejoin, quote from copy import deepcopy
def compose_url(start, *parts):
"""Compose a url from its component parts"""
if not parts: return start
if start[-1] != '/': start = start + '/'
next = parts[0]
if next[0] == '/': next = next[1:]
return compose_url(basejoin(start, next), *parts[1:])
src/p/i/pida-0.6.2/pida/services/plugins/downloader.py pida(Download)
# license gpl2 or later import re import urllib2 from . import metadata from urllib import basejoin import logging
def find_plugin_versions(url):
for href, name in find_plugins(url):
yield name, find_versions(basejoin(url, href))
def find_versions(url):
versions = {}
for href, name in find_urls(url):
if version not in versions:
versions[version] = {}
#XXX: might break for absolute url's
versions[version][ext] = basejoin(url, href)
return versions
src/c/h/cherry-blossom-HEAD/plugins/Rss.py cherry-blossom(Download)
import re, os, time import cherrypy as cpy from urllib import basejoin as urljoin from FileCabinet import get_most_recent, get_entries_by_meta from utils import config, run_callback #regex to strip HTML
#because <style> messed me up, I'm going to stop stripping
#HTML out of my description. The RSS spec sucks.
es.desc = e.text
es.link = urljoin(config('base_url'), e.relpath + '.html')
es.relpath = e.relpath
es.time = time.strftime('%Y-%m-%dT%H:%M:%SZ', e.time_tuple)
es.text = e.text
src/c/h/cherry-blossom-HEAD/plugins/Comments.py cherry-blossom(Download)
import re, os, time import cherrypy as cpy from urllib import basejoin as urljoin from utils import config class CommentStruct(object):
def comment_form(self, story):
url = urljoin(config('base_url'), '/Comments/add')
return ('comment_form', {'url': url, 'story':story})
def cb_admin_navbar(self):
return [('ls_comments', 'List Comments')]
src/c/h/cherry-blossom-HEAD/plugins/Atom.py cherry-blossom(Download)
import cherrypy as cpy import time from cgi import escape from urllib import basejoin as urljoin from FileCabinet import get_most_recent, get_entries_by_meta from utils import config, run_callback
es.text = fulltext
es.time = time.strftime('%Y-%m-%dT%H:%M:%SZ', e.time_tuple)
if not last_updated: last_updated = es.time
es.link = urljoin(config('base_url'), e.relpath + '.html')
entry_structs.append(es)
ns['last_updated'] = last_updated
ns['entries'] = entry_structs
src/j/a/jaraco.net-1.2/jaraco/net/whois.py jaraco.net(Download)
from formatter import NullFormatter, DumbWriter, AbstractFormatter from jaraco.net.http import PageGetter from jaraco.util.meta import LeafClassesMeta from urllib import basejoin import logging from StringIO import StringIO from BeautifulSoup import BeautifulSoup, UnicodeDammit
# Unfortunately, this page returns 'available' or 'not available'
# If it's not available, we need to know who owns it.
if re.search('Dominio %s registrado' % self._query, self._response):
getter.url = basejoin(getter.url, 'informacion.php')
self._response = getter.Fetch().read()
def ParseResponse(self, s_out):