Creating a Custom Fixup
You can read about what a Fixup is here.
Here is a simple Fixup that is already included in Peach. This fixup will calculate the CRC32 of a data element pointed to by a parameter passed to the Fixup.
After creating the fixup you will need to import the Python module via Import before you can reference the fixup.
The code you write should live in a .py file in the same folder as your .xml file. This will make it all much easier to package up. See the PythonPath and Import elements for how to include your new code into your Peach XML file.
NOTE: Never add the code into the Peach source folders! You’re welcome to submit them as patches, but otherwise keep them in another folder. This will make it easier to move to another machine, and upgrade Peach in the future.
import zlib from Peach.fixup import Fixup class Crc32Fixup(Fixup): ''' Standard CRC32 as defined by ISO 3309. Used by PNG, zip, etc. ''' def __init__(self, ref): Fixup.__init__(self) self.ref = ref def fixup(self): # Locate and get the value of the element we are interested in obj = self._findDataElementByName(self.ref) if obj == None: raise Exception("Error: Crc32Fixup was unable to locate [%s]" % self.ref) stuff = obj.getValue() # Return the CRC32 of that value return zlib.crc32(stuff)