/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/lazy_import.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:
170
170
            from foo import bar, baz would get translated into 2 import
171
171
            requests. On for 'name=bar' and one for 'name=baz'
172
172
        """
173
 
        if member is not None:
174
 
            assert not children, \
175
 
                'Cannot supply both a member and children'
 
173
        if (member is not None) and children:
 
174
            raise ValueError('Cannot supply both a member and children')
176
175
 
177
176
        object.__setattr__(self, '_import_replacer_children', children)
178
177
        object.__setattr__(self, '_member', member)
260
259
 
261
260
        :param import_str: The import string to process
262
261
        """
263
 
        assert import_str.startswith('import ')
 
262
        if not import_str.startswith('import '):
 
263
            raise ValueError('bad import string %r'
 
264
                % (import_str,))
264
265
        import_str = import_str[len('import '):]
265
266
 
266
267
        for path in import_str.split(','):
305
306
 
306
307
        :param from_str: The import string to process
307
308
        """
308
 
        assert from_str.startswith('from ')
 
309
        if not from_str.startswith('from '):
 
310
            raise ValueError('bad from/import %r' % from_str)
309
311
        from_str = from_str[len('from '):]
310
312
 
311
313
        from_module, import_list = from_str.split(' import ')