~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
    __slots__ = ['path', 'lock_path', 'lock_file', 'transport']
112
112
 
113
113
    def __init__(self, path, transport):
114
 
        assert isinstance(transport, SFTPTransport)
115
 
 
116
114
        self.lock_file = None
117
115
        self.path = path
118
116
        self.lock_path = path + '.write-lock'
164
162
    _max_request_size = 32768
165
163
 
166
164
    def __init__(self, base, _from_transport=None):
167
 
        assert base.startswith('sftp://')
168
165
        super(SFTPTransport, self).__init__(base,
169
166
                                            _from_transport=_from_transport)
170
167
 
346
343
 
347
344
            if cur_data_len < cur_coalesced.length:
348
345
                continue
349
 
            assert cur_data_len == cur_coalesced.length, \
350
 
                "Somehow we read too much: %s != %s" % (cur_data_len,
351
 
                                                        cur_coalesced.length)
 
346
            if cur_data_len != cur_coalesced.length:
 
347
                raise AssertionError(
 
348
                    "Somehow we read too much: %s != %s" 
 
349
                    % (cur_data_len, cur_coalesced.length))
352
350
            all_data = ''.join(cur_data)
353
351
            cur_data = []
354
352
            cur_data_len = 0
948
946
    def setUp(self, backing_server=None):
949
947
        # XXX: TODO: make sftpserver back onto backing_server rather than local
950
948
        # disk.
951
 
        assert (backing_server is None or
952
 
                isinstance(backing_server, local.LocalURLServer)), (
953
 
            "backing_server should not be %r, because this can only serve the "
954
 
            "local current working directory." % (backing_server,))
 
949
        if not (backing_server is None or
 
950
                isinstance(backing_server, local.LocalURLServer)):
 
951
            raise AssertionError(
 
952
                "backing_server should not be %r, because this can only serve the "
 
953
                "local current working directory." % (backing_server,))
955
954
        self._original_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
956
955
        ssh._ssh_vendor_manager._cached_ssh_vendor = self._vendor
957
956
        if sys.platform == 'win32':