Package pyffi :: Package spells
[hide private]
[frames] | no frames]

Package spells

source code

This module is based on wz's NifTester module, although nothing of wz's original code is left in this module.

A toaster, implemented by subclasses of the abstract Toaster class, walks over all files in a folder, and applies one or more transformations on each file. Such transformations are called spells, and are implemented by subclasses of the abstract Spell class.

A spell can also run independently of a toaster and be applied on a branch directly. The recommended way of doing this is via the Spell.recurse method.

Supported spells

For format specific spells, refer to the corresponding module.

Some spells are applicable on every file format, and those are documented here.

Adding new spells

To create new spells, derive your custom spells from the Spell class, and include them in the Toaster.SPELLS attribute of your toaster.

Grouping spells together

It is also possible to create composite spells, that is, spells that simply execute other spells. The following functions and classes can be used for this purpose.

Creating toaster scripts

To create a new toaster script, derive your toaster from the Toaster class, and set the Toaster.FILEFORMAT attribute of your toaster to the file format class of the files it can toast.

Submodules [hide private]

Classes [hide private]
  Spell
Spell base class.
  SpellGroupBase
Base class for grouping spells.
  SpellGroupSeriesBase
Base class for running spells in series.
  SpellGroupParallelBase
Base class for running spells in parallel (that is, with only a single recursion in the tree).
  SpellApplyPatch
A spell for applying a patch on files.
  fake_logger
Simple logger for testing.
  Toaster
Toaster base class.
Functions [hide private]
 
SpellGroupSeries(*args)
Class factory for grouping spells in series.
source code
 
SpellGroupParallel(*args)
Class factory for grouping spells in parallel.
source code
 
_toaster_job(args)
For multiprocessing.
source code
Variables [hide private]
  CPU_COUNT = 4
  __package__ = 'pyffi.spells'
Function Details [hide private]

_toaster_job(args)

source code 
For multiprocessing. This function creates a new toaster, with the given options and spells, and calls the toaster on filename.