76
76
return LocalTransport(self.base)
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)
78
return LocalTransport(self.abspath(offset))
86
80
def _abspath(self, relative_reference):
87
81
"""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
class LocalRelpathServer(Server):
478
"""A pretend server for local transports, using relpaths."""
481
"""See Transport.Server.get_url."""
485
class LocalAbspathServer(Server):
486
"""A pretend server for local transports, using absolute paths."""
489
"""See Transport.Server.get_url."""
490
return os.path.abspath("")
515
493
class LocalURLServer(Server):
516
"""A pretend server for local transports, using file:// urls.
518
Of course no actual server is required to access the local filesystem, so
519
this just exists to tell the test code how to get to it.
494
"""A pretend server for local transports, using file:// urls."""
522
496
def get_url(self):
523
497
"""See Transport.Server.get_url."""
527
501
def get_test_permutations():
528
502
"""Return the permutations to be used in testing."""
503
return [(LocalTransport, LocalRelpathServer),
504
(LocalTransport, LocalAbspathServer),
530
505
(LocalTransport, LocalURLServer),