File indexing completed on 2024-04-28 15:53:57

0001 #!/usr/bin/env python2.7
0002 # -*- coding: utf-8 -*-
0003 """:synopsis: Access the implementation of the import statement.
0004 
0005 
0006 """
0007 """
0008 The module was found as a source file.
0009 
0010 
0011 """
0012 PY_SOURCE = None
0013 """
0014 The module was found as a compiled code object file.
0015 
0016 
0017 """
0018 PY_COMPILED = None
0019 """
0020 The module was found as dynamically loadable shared library.
0021 
0022 
0023 """
0024 C_EXTENSION = None
0025 """
0026 The module was found as a package directory.
0027 
0028 
0029 """
0030 PKG_DIRECTORY = None
0031 """
0032 The module was found as a built-in module.
0033 
0034 
0035 """
0036 C_BUILTIN = None
0037 """
0038 The module was found as a frozen module (see :func:`init_frozen`).
0039 
0040 The following constant and functions are obsolete; their functionality is
0041 available through :func:`find_module` or :func:`load_module`. They are kept
0042 around for backward compatibility:
0043 
0044 
0045 """
0046 PY_FROZEN = None
0047 """
0048 Unused.
0049 
0050 
0051 """
0052 SEARCH_ERROR = None
0053 def get_magic():
0054     """
0055     """
0056     pass
0057     
0058 def get_suffixes():
0059     """
0060     Return a list of 3-element tuples, each describing a particular type of
0061     module. Each triple has the form ``(suffix, mode, type)``, where *suffix* is
0062     a string to be appended to the module name to form the filename to search
0063     for, *mode* is the mode string to pass to the built-in :func:`open` function
0064     to open the file (this can be ``'r'`` for text files or ``'rb'`` for binary
0065     files), and *type* is the file type, which has one of the values
0066     :const:`PY_SOURCE`, :const:`PY_COMPILED`, or :const:`C_EXTENSION`, described
0067     below.
0068     
0069     
0070     """
0071     pass
0072     
0073 def find_module(name,path):
0074     """
0075     Try to find the module *name*.  If *path* is omitted or ``None``, the list of
0076     directory names given by ``sys.path`` is searched, but first a few special
0077     places are searched: the function tries to find a built-in module with the
0078     given name (:const:`C_BUILTIN`), then a frozen module (:const:`PY_FROZEN`),
0079     and on some systems some other places are looked in as well (on Windows, it
0080     looks in the registry which may point to a specific file).
0081     
0082     Otherwise, *path* must be a list of directory names; each directory is
0083     searched for files with any of the suffixes returned by :func:`get_suffixes`
0084     above.  Invalid names in the list are silently ignored (but all list items
0085     must be strings).
0086     
0087     If search is successful, the return value is a 3-element tuple ``(file,
0088     pathname, description)``:
0089     
0090     *file* is an open file object positioned at the beginning, *pathname* is the
0091     pathname of the file found, and *description* is a 3-element tuple as
0092     contained in the list returned by :func:`get_suffixes` describing the kind of
0093     module found.
0094     
0095     If the module does not live in a file, the returned *file* is ``None``,
0096     *pathname* is the empty string, and the *description* tuple contains empty
0097     strings for its suffix and mode; the module type is indicated as given in
0098     parentheses above.  If the search is unsuccessful, :exc:`ImportError` is
0099     raised.  Other exceptions indicate problems with the arguments or
0100     environment.
0101     
0102     If the module is a package, *file* is ``None``, *pathname* is the package
0103     path and the last item in the *description* tuple is :const:`PKG_DIRECTORY`.
0104     
0105     This function does not handle hierarchical module names (names containing
0106     dots).  In order to find *P*.*M*, that is, submodule *M* of package *P*, use
0107     :func:`find_module` and :func:`load_module` to find and load package *P*, and
0108     then use :func:`find_module` with the *path* argument set to ``P.__path__``.
0109     When *P* itself has a dotted name, apply this recipe recursively.
0110     
0111     
0112     """
0113     pass
0114     
0115 def load_module(name,file,pathname,description):
0116     """
0117     """
0118     pass
0119     
0120 def new_module(name):
0121     """
0122     Return a new empty module object called *name*.  This object is *not* inserted
0123     in ``sys.modules``.
0124     
0125     
0126     """
0127     pass
0128     
0129 def lock_held():
0130     """
0131     Return ``True`` if the import lock is currently held, else ``False``. On
0132     platforms without threads, always return ``False``.
0133     
0134     On platforms with threads, a thread executing an import holds an internal lock
0135     until the import is complete. This lock blocks other threads from doing an
0136     import until the original import completes, which in turn prevents other threads
0137     from seeing incomplete module objects constructed by the original thread while
0138     in the process of completing its import (and the imports, if any, triggered by
0139     that).
0140     
0141     
0142     """
0143     pass
0144     
0145 def acquire_lock():
0146     """
0147     Acquire the interpreter's import lock for the current thread.  This lock should
0148     be used by import hooks to ensure thread-safety when importing modules.
0149     
0150     Once a thread has acquired the import lock, the same thread may acquire it
0151     again without blocking; the thread must release it once for each time it has
0152     acquired it.
0153     
0154     On platforms without threads, this function does nothing.
0155     
0156     """
0157     pass
0158     
0159 def release_lock():
0160     """
0161     Release the interpreter's import lock. On platforms without threads, this
0162     function does nothing.
0163     
0164     """
0165     pass
0166     
0167 def init_builtin(name):
0168     """
0169     Initialize the built-in module called *name* and return its module object along
0170     with storing it in ``sys.modules``.  If the module was already initialized, it
0171     will be initialized *again*.  Re-initialization involves the copying of the
0172     built-in module's ``__dict__`` from the cached module over the module's entry in
0173     ``sys.modules``.  If there is no built-in module called *name*, ``None`` is
0174     returned.
0175     
0176     
0177     """
0178     pass
0179     
0180 def init_frozen(name):
0181     """
0182     Initialize the frozen module called *name* and return its module object.  If
0183     the module was already initialized, it will be initialized *again*.  If there
0184     is no frozen module called *name*, ``None`` is returned.  (Frozen modules are
0185     modules written in Python whose compiled byte-code object is incorporated
0186     into a custom-built Python interpreter by Python's :program:`freeze`
0187     utility. See :file:`Tools/freeze/` for now.)
0188     
0189     
0190     """
0191     pass
0192     
0193 def is_builtin(name):
0194     """
0195     Return ``1`` if there is a built-in module called *name* which can be
0196     initialized again.  Return ``-1`` if there is a built-in module called *name*
0197     which cannot be initialized again (see :func:`init_builtin`).  Return ``0`` if
0198     there is no built-in module called *name*.
0199     
0200     
0201     """
0202     pass
0203     
0204 def is_frozen(name):
0205     """
0206     Return ``True`` if there is a frozen module (see :func:`init_frozen`) called
0207     *name*, or ``False`` if there is no such module.
0208     
0209     
0210     """
0211     pass
0212     
0213 def load_compiled(name,pathname,file):
0214     """
0215     """
0216     pass
0217     
0218 def load_dynamic(name,pathname,file):
0219     """
0220     Load and initialize a module implemented as a dynamically loadable shared
0221     library and return its module object.  If the module was already initialized, it
0222     will be initialized *again*. Re-initialization involves copying the ``__dict__``
0223     attribute of the cached instance of the module over the value used in the module
0224     cached in ``sys.modules``.  The *pathname* argument must point to the shared
0225     library.  The *name* argument is used to construct the name of the
0226     initialization function: an external C function called ``initname()`` in the
0227     shared library is called.  The optional *file* argument is ignored.  (Note:
0228     using shared libraries is highly system dependent, and not all systems support
0229     it.)
0230     
0231     
0232     """
0233     pass
0234     
0235 def load_source(name,pathname,file):
0236     """
0237     Load and initialize a module implemented as a Python source file and return its
0238     module object.  If the module was already initialized, it will be initialized
0239     *again*.  The *name* argument is used to create or access a module object.  The
0240     *pathname* argument points to the source file.  The *file* argument is the
0241     source file, open for reading as text, from the beginning. It must currently be
0242     a real file object, not a user-defined class emulating a file.  Note that if a
0243     properly matching byte-compiled file (with suffix :file:`.pyc` or :file:`.pyo`)
0244     exists, it will be used instead of parsing the given source file.
0245     
0246     
0247     """
0248     pass
0249     
0250 class NullImporter:
0251 
0252 
0253     """
0254     The :class:`NullImporter` type is a :pep:`302` import hook that handles
0255     non-directory path strings by failing to find any modules.  Calling this type
0256     with an existing directory or empty string raises :exc:`ImportError`.
0257     Otherwise, a :class:`NullImporter` instance is returned.
0258     
0259     Python adds instances of this type to ``sys.path_importer_cache`` for any path
0260     entries that are not directories and are not handled by any other path hooks on
0261     ``sys.path_hooks``.  Instances have only one method:
0262     
0263     
0264     """
0265     
0266     
0267     def __init__(self, ):
0268         pass
0269     
0270     def find_module(self, fullname,path):
0271         """
0272         This method always returns ``None``, indicating that the requested module could
0273         not be found.
0274         
0275         """
0276         pass
0277         
0278     
0279 
0280