Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)

        def relative_url(source, target):
    su=urlparse.urlparse(source)
    tu=urlparse.urlparse(target)
    junk=tu[3:]
    if su[0]!=tu[0] or su[1]!=tu[1]:
        #scheme (http) or netloc (www.heise.de) are different
        #return absolut path of target
        return target
    su=re.split("/", su[2])
    tu=re.split("/", tu[2])
    su.reverse()
    tu.reverse()

    #remove parts which are equal   (['a', 'b'] ['a', 'c'] --> ['c'])
    while len(su)>0 and len(tu)>0 and su[-1]==tu[-1]:
        su.pop()
        last_pop=tu.pop()
    if len(su)==0 and len(tu)==0:
        #Special case: link to itself (http://foo/a http://foo/a -> a)
        tu.append(last_pop)
    if len(su)==1 and su[0]=="" and len(tu)==0:
        #Special case: (http://foo/a/ http://foo/a -> ../a)
        su.append(last_pop)
        tu.append(last_pop)
    tu.reverse()
    relative_url=[]
    for i in range(len(su)-1): 
        relative_url.append("..")
    rel_url=string.join(relative_url + tu, "/")
    rel_url=urlparse.urlunparse(["", "", rel_url, junk[0], junk[1], junk[2]])
    return rel_url
        


src/t/r/transmogrify.siteanalyser-1.3/transmogrify/siteanalyser/relinker.py   transmogrify.siteanalyser(Download)
import lxml
from urlparse import urljoin
from external.relative_url import relative_url
from collective.transmogrifier.utils import Expression
import logging
    if linked:
        linkedurl = item['_site_url'] + linked['_path']
        newlink = swapfragment(relative_url(newbase, linkedurl), fragment)[0]
        counter.counter += 1
    else:
        if link not in bad and link.startswith(item['_site_url']):
            missing.add(link)
        newlink = swapfragment(relative_url(newbase, link), fragment)[0]

src/t/r/transmogrify.siteanalyser-HEAD/transmogrify/siteanalyser/relinker.py   transmogrify.siteanalyser(Download)
import lxml
from urlparse import urljoin
from external.relative_url import relative_url
from collective.transmogrifier.utils import Expression
import logging
    if linked:
        linkedurl = item['_site_url'] + linked['_path']
        newlink = swapfragment(relative_url(newbase, linkedurl), fragment)[0]
        counter.counter += 1
    else:
        if link not in bad and link.startswith(item['_site_url']):
            missing.add(link)
        newlink = swapfragment(relative_url(newbase, link), fragment)[0]