/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

  • Committer: Robert Collins
  • Date: 2005-10-20 07:48:48 UTC
  • mfrom: (1475)
  • mto: This revision was merged to the branch mainline in revision 1477.
  • Revision ID: robertc@robertcollins.net-20051020074848-6dde0abbc59a1238
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
354
354
    # which has a lookup of None
355
355
    return _protocol_handlers[None](base)
356
356
 
357
 
# Local transport should always be initialized
358
 
import bzrlib.transport.local
 
357
 
 
358
def urlescape(relpath):
 
359
    """Escape relpath to be a valid url."""
 
360
    # TODO utf8 it first. utf8relpath = relpath.encode('utf8')
 
361
    import urllib
 
362
    return urllib.quote(relpath)
 
363
 
 
364
 
 
365
def register_lazy_transport(scheme, module, classname):
 
366
    """Register lazy-loaded transport class.
 
367
 
 
368
    When opening a URL with the given scheme, load the module and then
 
369
    instantiate the particular class.  
 
370
    """
 
371
    def _loader(base):
 
372
        mod = __import__(module, globals(), locals(), [classname])
 
373
        klass = getattr(mod, classname)
 
374
        return klass(base)
 
375
    register_transport(scheme, _loader)
 
376
 
 
377
 
 
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')