~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/stub_sftp.py

  • Committer: Martin Pool
  • Date: 2006-01-12 06:37:23 UTC
  • mfrom: (1534.1.6 integration)
  • Revision ID: mbp@sourcefrog.net-20060112063723-4ec91b5ff30f0830
[merge] robertc-integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
 
61
61
class StubSFTPServer (SFTPServerInterface):
62
 
    def __init__(self, server, root):
 
62
    def __init__(self, server, root, home=None):
63
63
        SFTPServerInterface.__init__(self, server)
64
64
        self.root = root
65
 
        
 
65
        if home is None:
 
66
            self.home = self.root
 
67
        else:
 
68
            self.home = home[len(self.root):]
 
69
        if (len(self.home) > 0) and (self.home[0] == '/'):
 
70
            self.home = self.home[1:]
 
71
 
66
72
    def _realpath(self, path):
67
73
        return self.root + self.canonicalize(path)
68
74
 
 
75
    def canonicalize(self, path):
 
76
        if os.path.isabs(path):
 
77
            return os.path.normpath(path)
 
78
        else:
 
79
            return os.path.normpath('/' + os.path.join(self.home, path))
 
80
 
69
81
    def chattr(self, path, attr):
70
82
        try:
71
83
            SFTPServer.set_file_attr(path, attr)