~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_import.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-11 19:55:18 UTC
  • mto: This revision was merged to the branch mainline in revision 2004.
  • Revision ID: john@arbash-meinel.com-20060911195518-1a2bc78a3ab51ba9
Change how parameters are passed to support 'import root1.mod1 as mod1'

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
            Typically this is globals()
94
94
        :param name: The variable name. Often this is the same as the 
95
95
            module_path. 'bzrlib'
96
 
        :param module_path: The fully specified dotted path to the module.
97
 
            'bzrlib.foo.bar'
 
96
        :param module_path: A list for the fully specified module path
 
97
            ['bzrlib', 'foo', 'bar']
98
98
        :param member: The member inside the module to import, often this is
99
99
            None, indicating the module is being imported.
100
100
        :param children: Children entries to be imported later.
128
128
        children = object.__getattribute__(self, '_import_replacer_children')
129
129
        member = object.__getattribute__(self, '_member')
130
130
        module_path = object.__getattribute__(self, '_module_path')
 
131
        module_python_path = '.'.join(module_path)
131
132
        if member is not None:
132
 
            module = __import__(module_path, scope, scope, [member])
 
133
            module = __import__(module_python_path, scope, scope, [member])
133
134
            return getattr(module, member)
134
135
        else:
135
 
            module = __import__(module_path, scope, scope, [])
 
136
            module = __import__(module_python_path, scope, scope, [])
 
137
            for path in module_path[1:]:
 
138
                module = getattr(module, path)
136
139
 
137
140
        # Prepare the children to be imported
138
141
        for child_name, child_path, grandchildren in children: