b.l.ImportReplacer(ScopeReplacer) : class documentation

Part of bzrlib.lazy_import View In Hierarchy

Known subclasses: bzrlib.tests.test_lazy_import.InstrumentedImportReplacer

This is designed to replace only a portion of an import list.

It will replace itself with a module, and then make children entries also ImportReplacer objects.

At present, this only supports 'import foo.bar.baz' syntax.

Method __init__ Upon request import 'module_path' as the name 'module_name'.
Method _import Undocumented

Inherited from ScopeReplacer:

Method __getattribute__ Undocumented
Method __setattr__ Undocumented
Method __call__ Undocumented
Method _replace Actually replace self with other in the given scope
Method _cleanup Stop holding on to all the extra stuff
def __init__(self, scope, name, module_path, member=None, children={}):

Upon request import 'module_path' as the name 'module_name'. When imported, prepare children to also be imported.


import foo => name='foo' module_path='foo',
              member=None, children={}
import foo.bar => name='foo' module_path='foo', member=None,
                  children={'bar':(['foo', 'bar'], None, {}}
from foo import bar => name='bar' module_path='foo', member='bar'
from foo import bar, baz would get translated into 2 import
requests. On for 'name=bar' and one for 'name=baz'
ParametersscopeThe scope that objects should be imported into. Typically this is globals()
nameThe variable name. Often this is the same as the module_path. 'bzrlib'
module_pathA list for the fully specified module path ['bzrlib', 'foo', 'bar']
memberThe member inside the module to import, often this is None, indicating the module is being imported.

Children entries to be imported later. This should be a map of children specifications.

{'foo':(['bzrlib', 'foo'], None,
    {'bar':(['bzrlib', 'foo', 'bar'], None {})})
def _import(self, scope, name):
API Documentation for Bazaar, generated by pydoctor at 2020-09-30 01:08:52.