354
354
# which has a lookup of None
355
355
return _protocol_handlers[None](base)
357
# Local transport should always be initialized
358
import bzrlib.transport.local
360
358
def urlescape(relpath):
361
359
"""Escape relpath to be a valid url."""
364
362
return urllib.quote(relpath)
367
def register_builtin_transports():
368
"""Register all builtin transport modules.
370
This happens as a sideeffect of importing the modules.
365
def register_lazy_transport(scheme, module, classname):
366
"""Register lazy-loaded transport class.
368
When opening a URL with the given scheme, load the module and then
369
instantiate the particular class.
372
import bzrlib.transport.local, \
373
bzrlib.transport.http, \
374
bzrlib.transport.sftp
372
mod = __import__(module, globals(), locals(), [classname])
373
klass = getattr(mod, classname)
375
register_transport(scheme, _loader)
378
# If nothing else matches, try the LocalTransport
379
register_lazy_transport(None, 'bzrlib.transport.local', 'LocalTransport')
380
register_lazy_transport('file://', 'bzrlib.transport.local', 'LocalTransport')
381
register_lazy_transport('sftp://', 'bzrlib.transport.sftp', 'SFTPTransport')
382
register_lazy_transport('http://', 'bzrlib.transport.http', 'HttpTransport')
383
register_lazy_transport('https://', 'bzrlib.transport.http', 'HttpTransport')