143
134
register_netloc=False):
144
135
transport_list_registry.register_transport(prefix, help)
145
136
if register_netloc:
146
assert prefix.endswith('://')
137
if not prefix.endswith('://'):
138
raise ValueError(prefix)
147
139
register_urlparse_netloc_protocol(prefix[:-3])
187
179
transport_list_registry.remove(scheme)
191
@deprecated_function(zero_ninety)
193
# TODO: jam 20060606 urls should only be ascii, or they should raise InvalidURL
194
if isinstance(url, unicode):
195
url = url.encode('utf-8')
196
(scheme, netloc, path, params,
197
query, fragment) = urlparse.urlparse(url, allow_fragments=False)
198
username = password = host = port = None
200
username, host = netloc.split('@', 1)
202
username, password = username.split(':', 1)
203
password = urllib.unquote(password)
204
username = urllib.unquote(username)
209
host, port = host.rsplit(':', 1)
213
# TODO: Should this be ConnectionError?
214
raise errors.TransportError(
215
'invalid port number %s in url:\n%s' % (port, url))
216
host = urllib.unquote(host)
218
path = urllib.unquote(path)
220
return (scheme, username, password, host, port, path)
223
182
class _CoalescedOffset(object):
224
183
"""A data container for keeping track of coalesced offsets."""
334
293
_bytes_to_read_before_seek = 0
336
295
def __init__(self, base):
337
super(Transport, self).__init__()
296
super(Transport, self).__init__(base=base)
340
299
def _translate_error(self, e, path, raise_generic=True):
412
371
object or string to another one.
413
372
This just gives them something easy to call.
415
assert not isinstance(from_file, basestring), \
416
'_pump should only be called on files not %s' % (type(from_file,))
417
374
return osutils.pumpfile(from_file, to_file)
419
376
def _get_total(self, multi):
1007
966
:returns: the length of relpath before the content was written to it.
1009
assert isinstance(bytes, str), \
1010
'bytes must be a plain string, not %s' % type(bytes)
968
if not isinstance(bytes, str):
970
'bytes must be a plain string, not %s' % type(bytes))
1011
971
return self.append_file(relpath, StringIO(bytes), mode=mode)
1013
973
def append_multi(self, files, pb=None):
1546
1506
return transport
1549
@deprecated_function(zero_ninety)
1550
def urlescape(relpath):
1551
urlutils.escape(relpath)
1554
@deprecated_function(zero_ninety)
1555
def urlunescape(url):
1556
urlutils.unescape(url)
1558
1509
# We try to recognize an url lazily (ignoring user, password, etc)
1559
1510
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
1610
1561
transport, last_err = _try_transport_factories(base, factory_list)
1612
1563
if possible_transports is not None:
1613
assert transport not in possible_transports
1564
if transport in possible_transports:
1565
raise AssertionError()
1614
1566
possible_transports.append(transport)
1615
1567
return transport
1804
1756
'bzrlib.transport.fakevfat',
1805
1757
'FakeVFATTransportDecorator')
1759
register_transport_proto('nosmart+')
1760
register_lazy_transport('nosmart+', 'bzrlib.transport.nosmart',
1761
'NoSmartTransportDecorator')
1807
1763
# These two schemes were registered, but don't seem to have an actual transport
1808
1764
# protocol registered
1809
1765
for scheme in ['ssh', 'bzr+loopback']: