~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_import.py

(jelmer) Reduce the number of connections made during "bzr branch
 --stacked". (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
to inherit from them).
42
42
"""
43
43
 
44
 
from __future__ import absolute_import
45
 
 
46
44
 
47
45
class ScopeReplacer(object):
48
46
    """A lazy object that will replace itself in the appropriate scope.
210
208
        module_path = object.__getattribute__(self, '_module_path')
211
209
        module_python_path = '.'.join(module_path)
212
210
        if member is not None:
213
 
            module = __import__(module_python_path, scope, scope, [member], level=0)
 
211
            module = __import__(module_python_path, scope, scope, [member])
214
212
            return getattr(module, member)
215
213
        else:
216
 
            module = __import__(module_python_path, scope, scope, [], level=0)
 
214
            module = __import__(module_python_path, scope, scope, [])
217
215
            for path in module_path[1:]:
218
216
                module = getattr(module, path)
219
217