Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
importlib.test.source.test_abc_loader.PyPycLoaderMock Class Reference
Inheritance diagram for importlib.test.source.test_abc_loader.PyPycLoaderMock:
Inheritance graph
[legend]
Collaboration diagram for importlib.test.source.test_abc_loader.PyPycLoaderMock:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def compile_bc
def source_mtime
def bytecode_path
def write_bytecode
def get_data
def is_package
def get_code
def get_filename
def source_path
def path_mtime
def set_data
def get_source
def get_source
def load_module
def load_module
def load_module
def __new__
def __new__
def register
def register
def __instancecheck__
def __instancecheck__
def __subclasscheck__
def __subclasscheck__
def source_path
def get_filename
def path_mtime
def set_data
def get_source
def get_source
def load_module
def load_module
def load_module
def __new__
def __new__
def register
def register
def __instancecheck__
def __instancecheck__
def __subclasscheck__
def __subclasscheck__

Public Attributes

 module_bytecode
 path_to_bytecode
 bytecode_to_path
 module_paths
 path_to_module

Static Public Attributes

int default_mtime = 1
tuple source

Detailed Description

Definition at line 127 of file test_abc_loader.py.


Constructor & Destructor Documentation

def importlib.test.source.test_abc_loader.PyPycLoaderMock.__init__ (   self,
  source,
  bc = {} 
)
Initialize mock.

'bc' is a dict keyed on a module's name. The value is dict with
possible keys of 'path', 'mtime', 'magic', and 'bc'. Except for 'path',
each of those keys control if any part of created bytecode is to
deviate from default values.

Definition at line 131 of file test_abc_loader.py.

00131 
00132     def __init__(self, source, bc={}):
00133         """Initialize mock.
00134 
00135         'bc' is a dict keyed on a module's name. The value is dict with
00136         possible keys of 'path', 'mtime', 'magic', and 'bc'. Except for 'path',
00137         each of those keys control if any part of created bytecode is to
00138         deviate from default values.
00139 
00140         """
00141         super().__init__(source)
00142         self.module_bytecode = {}
00143         self.path_to_bytecode = {}
00144         self.bytecode_to_path = {}
00145         for name, data in bc.items():
00146             self.path_to_bytecode[data['path']] = name
00147             self.bytecode_to_path[name] = data['path']
00148             magic = data.get('magic', imp.get_magic())
00149             mtime = importlib._w_long(data.get('mtime', self.default_mtime))
00150             if 'bc' in data:
00151                 bc = data['bc']
00152             else:
00153                 bc = self.compile_bc(name)
00154             self.module_bytecode[name] = magic + mtime + bc

Here is the caller graph for this function:


Member Function Documentation

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

Abstract method. Accepts a str filename and returns the str pathname
to the bytecode for the module.

Reimplemented from importlib.abc.PyPycLoader.

Definition at line 168 of file test_abc_loader.py.

00168 
00169     def bytecode_path(self, name):
00170         try:
00171             return self.bytecode_to_path[name]
00172         except KeyError:
00173             if name in self.module_paths:
00174                 return None
00175             else:
00176                 raise ImportError

Definition at line 155 of file test_abc_loader.py.

00155 
00156     def compile_bc(self, name):
00157         source_path = self.module_paths.get(name, '<test>') or '<test>'
00158         code = compile(self.source, source_path, 'exec')
00159         return marshal.dumps(code)

Here is the call graph for this function:

Get a code object from source or bytecode.

Reimplemented from importlib.abc.PyPycLoader.

Definition at line 196 of file test_abc_loader.py.

00196 
00197     def get_code(self, name):
00198         with warnings.catch_warnings(record=True) as w:
00199             warnings.simplefilter("always")
00200             code_object = super().get_code(name)
00201             assert len(w) == 1
00202             assert issubclass(w[0].category, PendingDeprecationWarning)
00203             return code_object

Here is the call graph for this function:

Here is the caller graph for this function:

Abstract method which when implemented should return the bytes for
the specified path.  The path must be a str.

Reimplemented from importlib.test.source.test_abc_loader.PyLoaderMock.

Definition at line 181 of file test_abc_loader.py.

00181 
00182     def get_data(self, path):
00183         if path in self.path_to_module:
00184             return super().get_data(path)
00185         elif path in self.path_to_bytecode:
00186             name = self.path_to_bytecode[path]
00187             return self.module_bytecode[name]
00188         else:
00189             raise IOError

Here is the caller graph for this function:

Silence deprecation warning.

Reimplemented from importlib.abc.PyLoader.

Reimplemented in importlib.test.source.test_abc_loader.PyLoaderCompatMock.

Definition at line 99 of file test_abc_loader.py.

00099 
00100     def get_filename(self, name):
00101         """Silence deprecation warning."""
00102         with warnings.catch_warnings(record=True) as w:
00103             warnings.simplefilter("always")
00104             path = super().get_filename(name)
00105             assert len(w) == 1
00106             assert issubclass(w[0].category, PendingDeprecationWarning)
00107             return path
00108 

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib.abc.PyPycLoader.get_filename (   self,
  fullname 
) [inherited]
Return the source or bytecode file path.

Reimplemented from importlib.abc.PyLoader.

Definition at line 220 of file abc.py.

00220 
00221     def get_filename(self, fullname):
00222         """Return the source or bytecode file path."""
00223         path = self.source_path(fullname)
00224         if path is not None:
00225             return path
00226         path = self.bytecode_path(fullname)
00227         if path is not None:
00228             return path
00229         raise ImportError("no source or bytecode path available for "
00230                             "{0!r}".format(fullname))

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib.abc.InspectLoader.get_source (   self,
  fullname 
) [inherited]
Abstract method which should return the source code for the
module.  The fullname is a str.  Returns a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.InspectLoader.

Definition at line 82 of file abc.py.

00082 
00083     def get_source(self, fullname):
00084         """Abstract method which should return the source code for the
00085         module.  The fullname is a str.  Returns a str."""
00086         raise NotImplementedError
00087 
00088 InspectLoader.register(machinery.BuiltinImporter)
00089 InspectLoader.register(machinery.FrozenImporter)
00090 

Here is the caller graph for this function:

def importlib.abc.InspectLoader.get_source (   self,
  fullname 
) [inherited]
Abstract method which should return the source code for the
module.  The fullname is a str.  Returns a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.InspectLoader.

Definition at line 82 of file abc.py.

00082 
00083     def get_source(self, fullname):
00084         """Abstract method which should return the source code for the
00085         module.  The fullname is a str.  Returns a str."""
00086         raise NotImplementedError
00087 
00088 InspectLoader.register(machinery.BuiltinImporter)
00089 InspectLoader.register(machinery.FrozenImporter)
00090 

Here is the caller graph for this function:

def importlib._bootstrap.SourceLoader.get_source (   self,
  fullname 
) [inherited]
Concrete implementation of InspectLoader.get_source.

Definition at line 366 of file _bootstrap.py.

00366 
00367     def get_source(self, fullname):
00368         """Concrete implementation of InspectLoader.get_source."""
00369         import tokenize
00370         path = self.get_filename(fullname)
00371         try:
00372             source_bytes = self.get_data(path)
00373         except IOError:
00374             raise ImportError("source not available through get_data()")
00375         encoding = tokenize.detect_encoding(_io.BytesIO(source_bytes).readline)
00376         newline_decoder = _io.IncrementalNewlineDecoder(None, True)
00377         return newline_decoder.decode(source_bytes.decode(encoding[0]))

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib._bootstrap.SourceLoader.get_source (   self,
  fullname 
) [inherited]
Concrete implementation of InspectLoader.get_source.

Definition at line 366 of file _bootstrap.py.

00366 
00367     def get_source(self, fullname):
00368         """Concrete implementation of InspectLoader.get_source."""
00369         import tokenize
00370         path = self.get_filename(fullname)
00371         try:
00372             source_bytes = self.get_data(path)
00373         except IOError:
00374             raise ImportError("source not available through get_data()")
00375         encoding = tokenize.detect_encoding(_io.BytesIO(source_bytes).readline)
00376         newline_decoder = _io.IncrementalNewlineDecoder(None, True)
00377         return newline_decoder.decode(source_bytes.decode(encoding[0]))

Here is the call graph for this function:

Here is the caller graph for this function:

Concrete implementation of InspectLoader.is_package by checking if
the path returned by get_filename has a filename of '__init__.py'.

Reimplemented from importlib.test.source.test_abc_loader.PyLoaderMock.

Definition at line 190 of file test_abc_loader.py.

00190 
00191     def is_package(self, name):
00192         try:
00193             return super().is_package(name)
00194         except TypeError:
00195             return '__init__' in self.bytecode_to_path[name]

def importlib.abc.Loader.load_module (   self,
  fullname 
) [inherited]
Abstract method which when implemented should load a module.
The fullname is a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.Loader.

Definition at line 21 of file abc.py.

00021 
00022     def load_module(self, fullname):
00023         """Abstract method which when implemented should load a module.
00024         The fullname is a str."""
00025         raise NotImplementedError
00026 

Here is the caller graph for this function:

def importlib.abc.Loader.load_module (   self,
  fullname 
) [inherited]
Abstract method which when implemented should load a module.
The fullname is a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.Loader.

Definition at line 21 of file abc.py.

00021 
00022     def load_module(self, fullname):
00023         """Abstract method which when implemented should load a module.
00024         The fullname is a str."""
00025         raise NotImplementedError
00026 

Here is the caller graph for this function:

def importlib.abc.Loader.load_module (   self,
  fullname 
) [inherited]
Abstract method which when implemented should load a module.
The fullname is a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.Loader.

Definition at line 21 of file abc.py.

00021 
00022     def load_module(self, fullname):
00023         """Abstract method which when implemented should load a module.
00024         The fullname is a str."""
00025         raise NotImplementedError
00026 

Here is the caller graph for this function:

def importlib.abc.Loader.load_module (   self,
  fullname 
) [inherited]
Abstract method which when implemented should load a module.
The fullname is a str.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.Loader.

Definition at line 21 of file abc.py.

00021 
00022     def load_module(self, fullname):
00023         """Abstract method which when implemented should load a module.
00024         The fullname is a str."""
00025         raise NotImplementedError
00026 

Here is the caller graph for this function:

def importlib._bootstrap.SourceLoader.load_module (   self,
  fullname 
) [inherited]
Concrete implementation of Loader.load_module.

Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
implemented to load source code. Use of bytecode is dictated by whether
get_code uses/writes bytecode.

Definition at line 428 of file _bootstrap.py.

00428 
00429     def load_module(self, fullname):
00430         """Concrete implementation of Loader.load_module.
00431 
00432         Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
00433         implemented to load source code. Use of bytecode is dictated by whether
00434         get_code uses/writes bytecode.
00435 
00436         """
00437         return self._load_module(fullname)
00438 

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib._bootstrap.SourceLoader.load_module (   self,
  fullname 
) [inherited]
Concrete implementation of Loader.load_module.

Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
implemented to load source code. Use of bytecode is dictated by whether
get_code uses/writes bytecode.

Definition at line 428 of file _bootstrap.py.

00428 
00429     def load_module(self, fullname):
00430         """Concrete implementation of Loader.load_module.
00431 
00432         Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
00433         implemented to load source code. Use of bytecode is dictated by whether
00434         get_code uses/writes bytecode.
00435 
00436         """
00437         return self._load_module(fullname)
00438 

Here is the call graph for this function:

Here is the caller graph for this function:

def importlib.abc.SourceLoader.path_mtime (   self,
  path 
) [inherited]
Return the (int) modification time for the path (str).

Reimplemented from importlib._bootstrap.SourceLoader.

Reimplemented in importlib.test.source.test_abc_loader.SourceLoaderMock.

Definition at line 124 of file abc.py.

00124 
00125     def path_mtime(self, path):
00126         """Return the (int) modification time for the path (str)."""
00127         raise NotImplementedError

def importlib.abc.SourceLoader.path_mtime (   self,
  path 
) [inherited]
Return the (int) modification time for the path (str).

Reimplemented from importlib._bootstrap.SourceLoader.

Reimplemented in importlib.test.source.test_abc_loader.SourceLoaderMock.

Definition at line 124 of file abc.py.

00124 
00125     def path_mtime(self, path):
00126         """Return the (int) modification time for the path (str)."""
00127         raise NotImplementedError

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def importlib.abc.SourceLoader.set_data (   self,
  path,
  data 
) [inherited]
Write the bytes to the path (if possible).

Accepts a str path and data as bytes.

Any needed intermediary directories are to be created. If for some
reason the file cannot be written because of permissions, fail
silently.

Reimplemented from importlib._bootstrap.SourceLoader.

Reimplemented in importlib.test.source.test_abc_loader.SourceLoaderMock.

Definition at line 128 of file abc.py.

00128 
00129     def set_data(self, path, data):
00130         """Write the bytes to the path (if possible).
00131 
00132         Accepts a str path and data as bytes.
00133 
00134         Any needed intermediary directories are to be created. If for some
00135         reason the file cannot be written because of permissions, fail
00136         silently.
00137 
00138         """
00139         raise NotImplementedError
00140 

def importlib.abc.SourceLoader.set_data (   self,
  path,
  data 
) [inherited]
Write the bytes to the path (if possible).

Accepts a str path and data as bytes.

Any needed intermediary directories are to be created. If for some
reason the file cannot be written because of permissions, fail
silently.

Reimplemented from importlib._bootstrap.SourceLoader.

Reimplemented in importlib.test.source.test_abc_loader.SourceLoaderMock.

Definition at line 128 of file abc.py.

00128 
00129     def set_data(self, path, data):
00130         """Write the bytes to the path (if possible).
00131 
00132         Accepts a str path and data as bytes.
00133 
00134         Any needed intermediary directories are to be created. If for some
00135         reason the file cannot be written because of permissions, fail
00136         silently.
00137 
00138         """
00139         raise NotImplementedError
00140 

Abstract method. Accepts a str filename and returns an int
modification time for the source of the module.

Reimplemented from importlib.abc.PyPycLoader.

Definition at line 160 of file test_abc_loader.py.

00160 
00161     def source_mtime(self, name):
00162         if name in self.module_paths:
00163             return self.default_mtime
00164         elif name in self.module_bytecode:
00165             return None
00166         else:
00167             raise ImportError

def importlib.test.source.test_abc_loader.PyLoaderMock.source_path (   self,
  fullname 
) [inherited]
Abstract method.  Accepts a str module name and returns the path to
the source code for the module.

Reimplemented from importlib.abc.PyLoader.

Reimplemented in importlib.test.source.test_abc_loader.PyLoaderCompatMock.

Definition at line 93 of file test_abc_loader.py.

00093 
00094     def source_path(self, name):
00095         try:
00096             return self.module_paths[name]
00097         except KeyError:
00098             raise ImportError

def importlib.abc.PyLoader.source_path (   self,
  fullname 
) [inherited]
Abstract method.  Accepts a str module name and returns the path to
the source code for the module.

Reimplemented in importlib.test.source.test_abc_loader.AbstractMethodImplTests.PyLoader, importlib.test.source.test_abc_loader.PyLoaderCompatMock, and importlib.test.source.test_abc_loader.PyLoaderMock.

Definition at line 179 of file abc.py.

00179 
00180     def source_path(self, fullname):
00181         """Abstract method.  Accepts a str module name and returns the path to
00182         the source code for the module."""
00183         raise NotImplementedError

Here is the caller graph for this function:

def importlib.test.source.test_abc_loader.PyPycLoaderMock.write_bytecode (   self,
  fullname,
  bytecode 
)
Abstract method.  Accepts a str filename and bytes object
representing the bytecode for the module.  Returns a boolean
representing whether the bytecode was written or not.

Reimplemented from importlib.abc.PyPycLoader.

Definition at line 177 of file test_abc_loader.py.

00177 
00178     def write_bytecode(self, name, bytecode):
00179         self.module_bytecode[name] = bytecode
00180         return True


Member Data Documentation

Definition at line 143 of file test_abc_loader.py.

Definition at line 129 of file test_abc_loader.py.

Definition at line 141 of file test_abc_loader.py.

Definition at line 81 of file test_abc_loader.py.

Definition at line 142 of file test_abc_loader.py.

Definition at line 82 of file test_abc_loader.py.

Initial value:
(b"_ = '::'.join([__name__, __file__, __package__, "
              b"repr(__loader__)])")

Definition at line 71 of file test_abc_loader.py.


The documentation for this class was generated from the following file: