Package tdi :: Module factory_memoize :: Class MemoizedFactory
[frames] | no frames]

Class MemoizedFactory

source code

object --+
         |
        MemoizedFactory

Wrapper for providing template factory memoization keys
Instance Methods
 
__init__(self, factory)
Initialization
source code
Factory
replace(self, autoupdate=None, eventfilters=None, streamfilters=None, default_eventfilters=None, default_streamfilters=None, overlay_eventfilters=None, overlay_streamfilters=None, overlay_default_eventfilters=None, overlay_default_streamfilters=None, default_encoding=None, memoizer=None)
Create a new factory instance with replaced values
source code
Template
from_file(self, filename, encoding=None, key=None)
Build template from file
source code
Template
from_stream(self, stream, encoding=None, filename=None, mtime=None, opener=None, key=None)
Build template from stream
source code
Template
from_opener(self, opener, filename, encoding=None, key=None)
Build template from stream as returned by stream opener
source code
Template
from_string(self, data, encoding=None, filename=None, mtime=None, key=None)
Build template from from string
source code
Template
from_files(self, names, encoding=None, basedir=None, key=None)
Load templates from files and overlay them
source code
Template
from_streams(self, streams, encoding=None, streamopen=None, key=None)
Load templates from streams and overlay them
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, factory)
(Constructor)

source code 
Initialization
Parameters:
Overrides: object.__init__

replace(self, autoupdate=None, eventfilters=None, streamfilters=None, default_eventfilters=None, default_streamfilters=None, overlay_eventfilters=None, overlay_streamfilters=None, overlay_default_eventfilters=None, overlay_default_streamfilters=None, default_encoding=None, memoizer=None)

source code 
Create a new factory instance with replaced values
Parameters:
  • autoupdate (bool) - Should the templates be automatically updated when they change? If omitted or None, the current setting is applied.
  • eventfilters (iterable) - List of event filter factories ((BuildingListenerInterface, ...))
  • streamfilters (iterable) - List of stream filter factories ((file, ...))
  • default_eventfilters (bool) - Apply default eventfilters (before this list)?
  • default_streamfilters (bool) - Apply default streamfilters (before this list)?
  • overlay_eventfilters (iterable) - List of overlay event filter factories ((BuildingListenerInterface, ...))
  • overlay_streamfilters (iterable) - List of overlay stream filter factories ((file, ...))
  • overlay_default_eventfilters (bool) - Apply overlay default eventfilters (before this list)?
  • overlay_default_streamfilters (bool) - Apply overlay default streamfilters (before this list)?
  • default_encoding (str) - Default encoding
  • memoizer (MemoizerInterface) - New memoizer. If omitted or None, the new factory will be initialized without memoizing.
Returns: Factory
New factory instance

from_file(self, filename, encoding=None, key=None)

source code 
Build template from file
Parameters:
  • filename (str) - The filename to read the template from
  • encoding (str) - The initial template encoding. If omitted or None, the default encoding is applied.
Returns: Template
A new Template instance
Raises:
  • Error - An error occured while loading the template
  • IOError - Error while opening/reading the file

from_stream(self, stream, encoding=None, filename=None, mtime=None, opener=None, key=None)

source code 
Build template from stream
Parameters:
  • stream (file) - The stream to read from
  • encoding (str) - Initial template encoding. If omitted or None, the default encoding is applied.
  • filename (str) - Optional fake filename of the template. If not set, it's taken from stream.name. If this is not possible, it's <stream>.
  • mtime (int) - Optional fake mtime
  • opener - Deprecated. Don't use it anymore.
Returns: Template
The new Template instance

from_opener(self, opener, filename, encoding=None, key=None)

source code 
Build template from stream as returned by stream opener
Parameters:
  • opener (callable) - Stream opener, returns stream and mtime.
  • filename (str) - "Filename" of the template. It's passed to the opener, so it knows what to open.
  • encoding (str) - Initial template encoding. If omitted or None, the default encoding is applied.
Returns: Template
The new Template instance

from_string(self, data, encoding=None, filename=None, mtime=None, key=None)

source code 
Build template from from string
Parameters:
  • data (str) - The string to process
  • encoding (str) - The initial template encoding. If omitted or None, the default encoding is applied.
  • filename (str) - Optional fake filename of the template. If not set, it's <string>
  • mtime (int) - Optional fake mtime
Returns: Template
The new Template instance

from_files(self, names, encoding=None, basedir=None, key=None)

source code 
Load templates from files and overlay them
Parameters:
  • names (iterable) - List of filenames, possibly relative to basedir
  • encoding (str) - Initial template encoding for all files. If omitted or None, the default encoding is applied.
  • basedir (basestring) - Directory, all filenames are relative to. If omitted or None the names are applied as-is.
Returns: Template
The final template

from_streams(self, streams, encoding=None, streamopen=None, key=None)

source code 
Load templates from streams and overlay them
Parameters:
  • streams (iterable) - List of items identifying the streams. If streamopen is omitted or None the streams are assumed to be regular filenames.
  • encoding (str) - Initial template encoding for all streams. If omitted or None, the default encoding is applied.
  • streamopen (callable) - Function taking the passed item (of streams) and returning a tuple:

    • the stream specification. This itself is either a 2-tuple or a 3-tuple. A 2-tuple contains a stream opener and a filename and is passed to from_opener. A 3-tuple contains the open stream, the filename and the mtime and is passed to from_stream. (filename and mtime may be None.)
    • the memoization key, may be None

    If omitted or None, the items are assumed to be file names.

Returns: Template
The final template