~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Martin Pool
  • Date: 2006-11-02 10:20:19 UTC
  • mfrom: (2114 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2119.
  • Revision ID: mbp@sourcefrog.net-20061102102019-9a5a02f485dff6f6
merge bzr.dev and reconcile several changes, also some test fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Bazaar -- distributed version control
2
2
#
3
 
# Copyright (C) 2006 by Canonical Ltd
 
3
# Copyright (C) 2006 Canonical Ltd
4
4
#
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
19
19
"""A collection of function for handling URL operations."""
20
20
 
21
21
import os
22
 
from posixpath import split as _posix_split, normpath as _posix_normpath
23
22
import re
24
23
import sys
 
24
 
 
25
from bzrlib.lazy_import import lazy_import
 
26
lazy_import(globals(), """
 
27
from posixpath import split as _posix_split, normpath as _posix_normpath
25
28
import urllib
26
29
 
27
 
import bzrlib.errors as errors
28
 
import bzrlib.osutils
 
30
from bzrlib import (
 
31
    errors,
 
32
    osutils,
 
33
    )
 
34
""")
29
35
 
30
36
 
31
37
def basename(url, exclude_trailing_slash=True):
75
81
 
76
82
    base = local_path_from_url(base)
77
83
    path = local_path_from_url(path)
78
 
    return escape(bzrlib.osutils.relpath(base, path))
 
84
    return escape(osutils.relpath(base, path))
79
85
 
80
86
 
81
87
def _find_scheme_and_separator(url):
168
174
    # importing directly from posixpath allows us to test this 
169
175
    # on non-posix platforms
170
176
    return 'file://' + escape(_posix_normpath(
171
 
        bzrlib.osutils._posix_abspath(path)))
 
177
        osutils._posix_abspath(path)))
172
178
 
173
179
 
174
180
def _win32_local_path_from_url(url):
197
203
    #       which actually strips trailing space characters.
198
204
    #       The worst part is that under linux ntpath.abspath has different
199
205
    #       semantics, since 'nt' is not an available module.
200
 
    win32_path = bzrlib.osutils._nt_normpath(
201
 
        bzrlib.osutils._win32_abspath(path)).replace('\\', '/')
 
206
    win32_path = osutils._nt_normpath(
 
207
        osutils._win32_abspath(path)).replace('\\', '/')
202
208
    return 'file:///' + win32_path[0].upper() + ':' + escape(win32_path[2:])
203
209
 
204
210