76
76
return LocalTransport(self.base)
78
return LocalTransport(self.abspath(offset))
78
abspath = self.abspath(offset)
79
if abspath == 'file://':
80
# fix upwalk for UNC path
81
# when clone from //HOST/path updir recursively
82
# we should stop at least at //HOST part
84
return LocalTransport(abspath)
80
86
def _abspath(self, relative_reference):
81
87
"""Return a path for use in os calls.
483
class EmulatedWin32LocalTransport(LocalTransport):
484
"""Special transport for testing Win32 [UNC] paths on non-windows"""
486
def __init__(self, base):
489
super(LocalTransport, self).__init__(base)
490
self._local_base = urlutils._win32_local_path_from_url(base)
492
def abspath(self, relpath):
493
assert isinstance(relpath, basestring), (type(relpath), relpath)
494
path = osutils.normpath(osutils.pathjoin(
495
self._local_base, urlutils.unescape(relpath)))
496
return urlutils._win32_local_path_to_url(path)
498
def clone(self, offset=None):
499
"""Return a new LocalTransport with root at self.base + offset
500
Because the local filesystem does not require a connection,
501
we can just return a new object.
504
return EmulatedWin32LocalTransport(self.base)
506
abspath = self.abspath(offset)
507
if abspath == 'file://':
508
# fix upwalk for UNC path
509
# when clone from //HOST/path updir recursively
510
# we should stop at least at //HOST part
512
return EmulatedWin32LocalTransport(abspath)
477
515
class LocalURLServer(Server):
478
516
"""A pretend server for local transports, using file:// urls.
481
519
this just exists to tell the test code how to get to it.
523
"""Setup the server to service requests.
525
:param decorated_transport: ignored by this implementation.
484
528
def get_url(self):
485
529
"""See Transport.Server.get_url."""
486
530
return urlutils.local_path_to_url('')