/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: 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:
135
135
                             register_netloc=False):
136
136
    transport_list_registry.register_transport(prefix, help)
137
137
    if register_netloc:
138
 
        assert prefix.endswith('://')
 
138
        if not prefix.endswith('://'):
 
139
            raise ValueError(prefix)
139
140
        register_urlparse_netloc_protocol(prefix[:-3])
140
141
 
141
142
 
404
405
        object or string to another one.
405
406
        This just gives them something easy to call.
406
407
        """
407
 
        assert not isinstance(from_file, basestring), \
408
 
            '_pump should only be called on files not %s' % (type(from_file,))
409
408
        return osutils.pumpfile(from_file, to_file)
410
409
 
411
410
    def _get_total(self, multi):
1000
999
 
1001
1000
        :returns: the length of relpath before the content was written to it.
1002
1001
        """
1003
 
        assert isinstance(bytes, str), \
1004
 
            'bytes must be a plain string, not %s' % type(bytes)
 
1002
        if not isinstance(bytes, str):
 
1003
            raise TypeError(
 
1004
                'bytes must be a plain string, not %s' % type(bytes))
1005
1005
        return self.append_file(relpath, StringIO(bytes), mode=mode)
1006
1006
 
1007
1007
    def append_multi(self, files, pb=None):
1604
1604
            transport, last_err = _try_transport_factories(base, factory_list)
1605
1605
            if transport:
1606
1606
                if possible_transports is not None:
1607
 
                    assert transport not in possible_transports
 
1607
                    if transport in possible_transports:
 
1608
                        raise AssertionError()
1608
1609
                    possible_transports.append(transport)
1609
1610
                return transport
1610
1611