~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

[merge] Hermann Kraus: updates to Bundle exceptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Bazaar -- distributed version control
2
2
#
3
 
# Copyright (C) 2006 Canonical Ltd
 
3
# Copyright (C) 2006 by 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
22
23
import re
23
24
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
28
25
import urllib
29
26
 
30
 
from bzrlib import (
31
 
    errors,
32
 
    osutils,
33
 
    )
34
 
""")
 
27
import bzrlib.errors as errors
 
28
import bzrlib.osutils
35
29
 
36
30
 
37
31
def basename(url, exclude_trailing_slash=True):
81
75
 
82
76
    base = local_path_from_url(base)
83
77
    path = local_path_from_url(path)
84
 
    return escape(osutils.relpath(base, path))
 
78
    return escape(bzrlib.osutils.relpath(base, path))
85
79
 
86
80
 
87
81
def _find_scheme_and_separator(url):
135
129
        if m:
136
130
            # Absolute URL
137
131
            scheme = m.group('scheme')
138
 
            # this skips .. normalisation, making http://host/../../..
139
 
            # be rather strange.
140
132
            path = m.group('path').split('/')
141
133
        else:
142
134
            for chunk in arg.split('/'):
174
166
    # importing directly from posixpath allows us to test this 
175
167
    # on non-posix platforms
176
168
    return 'file://' + escape(_posix_normpath(
177
 
        osutils._posix_abspath(path)))
 
169
        bzrlib.osutils._posix_abspath(path)))
178
170
 
179
171
 
180
172
def _win32_local_path_from_url(url):
203
195
    #       which actually strips trailing space characters.
204
196
    #       The worst part is that under linux ntpath.abspath has different
205
197
    #       semantics, since 'nt' is not an available module.
206
 
    win32_path = osutils._nt_normpath(
207
 
        osutils._win32_abspath(path)).replace('\\', '/')
 
198
    win32_path = bzrlib.osutils._nt_normpath(
 
199
        bzrlib.osutils._win32_abspath(path)).replace('\\', '/')
208
200
    return 'file:///' + win32_path[0].upper() + ':' + escape(win32_path[2:])
209
201
 
210
202