~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-06-02 18:48:54 UTC
  • mfrom: (2495.5.1 check-docs)
  • Revision ID: pqm@pqm.ubuntu.com-20070602184854-kwqaduxs0b19r76n
(Andrew Bennetts) 'make check' builds docs as well

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