~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Vincent Ladeuil
  • Date: 2007-06-10 11:07:10 UTC
  • mfrom: (2485.9.2 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070610110710-2xi9ditvln347qpj
merge after bzr bind (why did I have to do that ?)

Show diffs side-by-side

added added

removed removed

Lines of Context:
608
608
                # Otherwise take the url decoded one
609
609
                res[i] = decoded
610
610
    return u'/'.join(res)
 
611
 
 
612
 
 
613
def derive_to_location(from_location):
 
614
    """Derive a TO_LOCATION given a FROM_LOCATION.
 
615
 
 
616
    The normal case is a FROM_LOCATION of http://foo/bar => bar.
 
617
    The Right Thing for some logical destinations may differ though
 
618
    because no / may be present at all. In that case, the result is
 
619
    the full name without the scheme indicator, e.g. lp:foo-bar => foo-bar.
 
620
    This latter case also applies when a Windows drive
 
621
    is used without a path, e.g. c:foo-bar => foo-bar.
 
622
    If no /, path separator or : is found, the from_location is returned.
 
623
    """
 
624
    if from_location.find("/") >= 0 or from_location.find(os.sep) >= 0:
 
625
        return os.path.basename(from_location.rstrip("/\\"))
 
626
    else:
 
627
        sep = from_location.find(":")
 
628
        if sep > 0:
 
629
            return from_location[sep+1:]
 
630
        else:
 
631
            return from_location