~ubuntu-branches/debian/experimental/nuitka/experimental

« back to all changes in this revision

Viewing changes to nuitka/nodes/ImportNodes.py

  • Committer: Package Import Robot
  • Author(s): Kay Hayen
  • Date: 2015-04-06 17:20:44 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20150406172044-grhy9sk7g0whu2ag
Tags: 0.5.12+ds-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
""" Nodes related to importing modules or names.
19
19
 
20
20
Normally imports are mostly relatively static, but Nuitka also attempts to
21
 
cover the uses of "__import__" builtin and other import techniques, that
 
21
cover the uses of "__import__" built-in and other import techniques, that
22
22
allow dynamic values.
23
23
 
24
24
If other optimizations make it possible to predict these, the compiler can go
25
25
deeper that what it normally could. The import expression node can recurse. An
26
 
"__import__" builtin may be converted to it, once the module name becomes a
 
26
"__import__" built-in may be converted to it, once the module name becomes a
27
27
compile time constant.
28
28
"""
29
29
 
30
30
from logging import warning
31
31
 
32
 
from nuitka import Importing, Utils
33
 
from nuitka.Importing import getModuleWhiteList
 
32
from nuitka.importing.Importing import findModule
 
33
from nuitka.importing.Recursion import decideRecursion, recurseTo
 
34
from nuitka.importing.Whitelisting import getModuleWhiteList
 
35
from nuitka.utils import Utils
34
36
 
35
37
from .ConstantRefNodes import ExpressionConstantRef
36
38
from .NodeBases import (
116
118
            module_name = None
117
119
 
118
120
        if module_kind is not None:
119
 
            from nuitka.tree import Recursion
120
 
 
121
 
            decision, reason = Recursion.decideRecursion(
 
121
            decision, reason = decideRecursion(
122
122
                module_filename = module_filename,
123
123
                module_name     = module_name,
124
124
                module_package  = module_package,
128
128
            if decision:
129
129
                module_relpath = Utils.relpath(module_filename)
130
130
 
131
 
                imported_module, added_flag = Recursion.recurseTo(
 
131
                imported_module, added_flag = recurseTo(
132
132
                    module_package  = module_package,
133
133
                    module_filename = module_filename,
134
134
                    module_relpath  = module_relpath,
176
176
        else:
177
177
            parent_package = self.getParentModule().getPackage()
178
178
 
179
 
        module_package, _module_name, module_filename = Importing.findModule(
 
179
        module_package, module_filename, _finding = findModule(
180
180
            source_ref     = self.source_ref,
181
181
            module_name    = self.getModuleName(),
182
182
            parent_package = parent_package,
184
184
            warn           = True
185
185
        )
186
186
 
187
 
        # That would be an illegal package name, catch it.
188
 
        assert module_package != ""
189
 
 
190
187
        if module_filename is not None:
191
188
            imported_module = self._consider(
192
189
                constraint_collection = constraint_collection,
202
199
 
203
200
                if import_list and imported_module.isPythonPackage():
204
201
                    for import_item in import_list:
 
202
                        if import_item == '*':
 
203
                            continue
205
204
 
206
 
                        module_package, _module_name, module_filename = \
207
 
                          Importing.findModule(
 
205
                        module_package, module_filename, _finding = findModule(
208
206
                            source_ref     = self.source_ref,
209
207
                            module_name    = import_item,
210
208
                            parent_package = imported_module.getFullName(),
334
332
        level = self.getLevel()
335
333
 
336
334
        # TODO: In fact, if the module is not a package, we don't have to insist
337
 
        # on the fromlist that much, but normally it's not used for anything but
338
 
        # packages, so it will be rare.
 
335
        # on the "fromlist" that much, but normally it's not used for anything
 
336
        # but packages, so it will be rare.
339
337
 
340
338
        if module_name.isExpressionConstantRef() and \
341
339
           fromlist.isExpressionConstantRef() and \