Writing Export Filters

Export filters are similar to report generators. They are not allowed to modify the database. An export filter accepts three arguments — a database, the filename of the file that is to be written, and a callback function.

The callback function is indentical from the callback function used for import filters. The export filter's callback function is used to indicate progress and update the status bar during the export process. The function takes a value between 0.0 and 1.0, where 0.0 represents the start of the export and 1.0 represents the completion of the export.

As with the other plugin types, an export filter must be registered with gramps. This is accomplished by calling the Plugins.register_export task. The Plugins.register_export accepts two arguments — the function the performs the import and a string providing a brief description. This description is used as the menu entry under the File->Export menu.


import Plugins

def gedcom_export(database,filename,callback):
    ... actual code ...

Plugins.register_export(gedcom_export,"GEDCOM export")

      

Figure 5. Sample Export Implementation