• Home
  • Raw
  • Download

Lines Matching +full:is +full:- +full:module

13 warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2)
16 # note: avoid importing non-builtin modules
66 # so let's just load the OS-related facilities.
70 # This is the Importer that we use for grabbing stuff from the
72 if fs_imp is None:
78 # The default will import dynamic-load modules first, followed by
87 """Python calls this hook to locate and import a module."""
94 # if there is a parent, then its importer should manage this import
96 module = parent.__importer__._do_import(parent, parts, fromlist)
97 if module:
98 return module
100 # has the top module already been imported?
105 # look for the topmost module
108 # the topmost module wasn't found at all.
109 raise ImportError, 'No module named ' + fqname
111 # fast-path simple imports
117 # __ispkg__ isn't defined (the module was not imported by us),
118 # or it is zero.
120 # In the former case, there is no way that we could import
121 # sub-modules that occur in the fromlist (but we can't raise an
125 # In the latter case (__ispkg__ == 0), there can't be any sub-
128 # In both cases, since len(parts) == 1, the top_module is also
129 # the "bottom" which is the defined return when a fromlist
145 # importer means that something else imported the module, and we have
146 # no knowledge of how to get sub-modules out of the thing.
147 raise ImportError, 'No module named ' + fqname
150 """Returns the context in which a module should be imported.
152 The context could be a loaded (package) module and the imported module
154 meaning there is no context -- the module should be looked for as a
155 "top-level" module.
160 # implies there is no relative import context (as far as we are
164 # The globals refer to a module or package of ours. It will define
165 # the context of the new import. Get the module/package fqname.
168 # if a package is performing the import, then return itself (imports
172 assert globals is parent.__dict__
177 # a module outside of a package has no particular import context
178 if i == -1:
181 # if a module in a package is performing the import, then return the
190 # the module, or an Importer object that can import the module.
193 module = self.fs_imp.import_from_dir(item, name)
195 module = item.import_top(name)
196 if module:
197 return module
200 def _reload_hook(self, module): argument
201 "Python calls this hook to reload a module."
203 # reloading of a module may or may not be possible (depending on the
205 importer = module.__dict__.get('__importer__')
210 # okay. it is using the imputil system, and we must delegate it, but
212 ### we should blast the module dict and do another get_code(). need to
221 "Import a top-level module."
230 # below the top-level module.
233 # if the form is "import a.b.c", then return "a"
238 # the top module was imported by self.
240 # this means that the bottom module was also imported by self (just
243 # since we imported/handled the bottom module, this means that we can
246 # if the bottom node is a package, then (potentially) import some
249 # note: if it is not a package, then "fromlist" refers to names in
250 # the bottom module rather than modules.
253 # the package module. Python will pick up all fromlist names
254 # from the bottom (package) module; some will be modules that
260 # if the form is "from a.b import c, d" then return "b"
264 "Import a single module."
266 # has the module already been imported?
272 # load the module's code, or fetch the module itself
274 if result is None:
277 module = self._process_result(result, fqname)
279 # insert the module into its parent
281 setattr(parent, modname, module)
282 return module
286 # did get_code() return an actual module? (rather than a code object)
289 # use the returned module, or create a new one to exec code into
291 module = code
293 module = imp.new_module(fqname)
296 module.__importer__ = self
297 module.__ispkg__ = ispkg
299 # insert additional values into the module (before executing the code)
300 module.__dict__.update(values)
302 # the module is almost ready... make it visible
303 sys.modules[fqname] = module
305 # execute the code within the module's namespace
308 exec code in module.__dict__
314 # fetch from sys.modules instead of returning module directly.
315 # also make module's __name__ agree with fqname, in case
316 # the "exec code in module.__dict__" played games on us.
317 module = sys.modules[fqname]
318 module.__name__ = fqname
319 return module
322 """Import the rest of the modules, down from the top-level module.
324 Returns the last module in the dotted list of modules.
330 raise ImportError, "No module named " + fqname
334 'Import any sub-modules in the "from" list.'
336 # if '*' is present in the fromlist, then look for the '__all__'
343 # if the name is already present, then don't try to import it (it
344 # might not be a module!).
352 """Attempt to import the module relative to parent.
354 This method is used when the import context specifies that <self>
355 imported the parent module.
361 # this importer and parent could not find the module (relatively)
371 """Find and retrieve the code for the given module.
373 parent specifies a parent module to define a context for importing. It
376 modname specifies a single module (not dotted) within the parent.
378 fqname specifies the fully-qualified module name. This is a
379 (potentially) dotted name from the "root" of the module namespace
381 If there is no parent, then modname==fqname.
383 This method should return None, or a 3-tuple.
385 * If the module was not found, then None should be returned.
387 * The first item of the 2- or 3-tuple should be the integer 0 or 1,
388 specifying whether the module that was found is a package or not.
390 * The second item is the code object for the module (it will be
391 executed within the new module's namespace). This item can also
392 be a fully-loaded module object (e.g. loaded from a shared lib).
394 * The third item is a dictionary of name/value pairs that will be
395 inserted into new module before the code object is executed. This
396 is provided in case the module's code expects certain values (such
397 as where the module was found). When the second item is a module
398 object, then these names/values will be inserted *after* the module
409 # byte-compiled file suffix character
412 # byte-compiled file suffix
418 The file specified by <pathname> is compiled to a code object and
426 if codestring and codestring[-1] != '\n':
448 "Set up 'os' module replacement functions for use during import bootstrap."
466 raise ImportError, 'no os specific module found'
468 if join is None:
472 lastchar = a[-1:]
510 # look for the module
520 module = imp.load_module(modname, None, modname, ('', '', type))
521 return 0, module, { }
543 # This importer is never used with an empty parent. Its existence is
545 # import_from_dir() method to import top-level modules/packages.
546 # This method is only used when we look for a module within a package.
551 if code is not None:
579 # SUFFIX-BASED IMPORTERS
583 file = filename[:-3] + _suffix
588 if t_pyc is not None and t_pyc >= t_py:
595 if code is None:
607 module = imp.load_module(fqname, fp, filename, self.desc)
608 module.__file__ = filename
609 return 0, module, { }
617 for name, module in items:
618 if module:
619 print name, module.__dict__.get('__importer__', '-- no importer')
621 print name, '-- non-existent module'
633 # type(sys) is not a module in Jython. what to use instead?
634 # imp.C_EXTENSION is not in Jython. same for get_suffixes and new_module
640 # ---- standard import mechanism
643 # <module 'sys' (built-in)>
645 # ---- revamped import mechanism
650 # <module 'foo' from 'foo.py'>
654 # should BuiltinImporter exist in sys.path or hard-wired in ImportManager?
659 # query mechanism needed: is a specific Importer installed?
663 # module->file location mapper to speed FS-based imports
668 # push MAL's mapper into sys.path[0] as a cache (hard-coded for apps)
672 # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy
673 # watch out for sys.modules[...] is None
675 # checking for a relative module)
677 # note: reload does NOT blast module dict
685 # any special handling to do for importing a module with a SyntaxError?
687 # implement "domain" for path-type functionality using pkg namespace
688 # (rather than FS-names like __path__)
700 # class. If you register a new importer class, the cache is zapped.
701 # The cache is independent from sys.path (but maintained per
703 # right thing. If a path is dropped from sys.path the corresponding
704 # cache entry is simply no longer used.
710 # > 1) implementing policy in ImportManager assists in single-point policy
712 # > 2) implementing policy in Importer assists in package-private policy
721 # there is actually not so much policy but a *necessity* to get things