The gramps.gen.plug Module

The “plug” package for handling plugins in Gramps.

Plugin

This module provides the base class for plugins.

class gramps.gen.plug._plugin.Plugin(name, description, module_name)[source]

Bases: object

This class serves as a base class for all plugins that can be registered with the plugin manager

get_description()[source]

Get the description of this plugin.

Returns:

a string that describes the plugin

get_module_name()[source]

Get the name of the module that this plugin lives in.

Returns:

a string representing the name of the module for this plugin

get_name()[source]

Get the name of this plugin.

Returns:

a string representing the name of the plugin

BaseManager

The core of the Gramps plugin system. This module provides capability to load plugins from specified directories and provide information about the loaded plugins.

Plugins are divided into several categories. These are: reports, tools, importers, exporters, quick reports, and document generators.

class gramps.gen.plug._manager.BasePluginManager[source]

Bases: object

unique singleton storage class for a PluginManager.

empty_managed_plugins()[source]

For some plugins, managed Plugin are used. These are only reobtained from the registry if this method is called

get_docgen_names()[source]

Get the list of docgen plugin names.

Returns:

a list of DocGenPlugin names

get_docgen_plugins()[source]

Get the list of docgen plugins.

Returns:

DocGenPlugin (a list of DocGenPlugin instances)

get_export_plugins()[source]

Get the list of export plugins.

Returns:

ExportPlugin (a list of ExportPlugin instances)

get_external_opt_dict()[source]

Return the dictionary of external options.

get_fail_list()[source]

Return the list of failed plugins.

get_import_plugins()[source]

Get the list of import plugins.

Returns:

ImportPlugin (a list of ImportPlugin instances)

static get_instance()[source]

Use this function to get the instance of the PluginManager

get_module_description(module)[source]

Given a module name, return the module description.

get_plugin(id)[source]

Returns a plugin object from PluginRegister by id.

get_plugin_data(category)[source]

Gets all of the data from general plugins of type category. plugin.data may be a single item, an iterable, or a callable.

>>> PLUGMAN.get_plugin_data('CSS')
<a list of raw data items>
get_reg_bookitems()[source]

Return list of reports registered as bookitem

get_reg_databases()[source]

Return list of registered database backends

get_reg_docgens()[source]

Return list of registered docgen

get_reg_exporters()[source]

Return list of registered exporters

get_reg_general(category=None)[source]

Return list of registered general libs

get_reg_gramplets()[source]

Return list of non hidden gramplets.

get_reg_importers()[source]

Return list of registered importers

get_reg_mapservices()[source]

Return list of registered mapservices

get_reg_quick_reports()[source]

Return list of registered quick reports

get_reg_reports(gui=True)[source]

Return list of registered reports :param gui: bool indicating if GUI reports or CLI reports must be returned

get_reg_sidebars()[source]

Return list of registered sidebars.

get_reg_tools(gui=True)[source]

Return list of registered tools :aram gui: bool indicating if GUI reports or CLI reports must be returned

get_reg_views()[source]

Return list of registered views

get_success_list()[source]

Return the list of succeeded plugins.

import_plugin(pdata)[source]

Rather than just __import__(id), this will add the pdata.fpath to sys.path first (if needed), import, and then reset path.

is_loaded(pdata_id)[source]

return True if plugin is already loaded

load_plugin(pdata)[source]

Load a PluginData object. This means import of the python module. Plugin directories are added to sys path, so files are found

load_plugin_category(category)[source]

Make sure all plugins of a type are loaded.

process_plugin_data(category)[source]

Gathers all of the data from general plugins of type category, and pass it to a single process function from one of those plugins.

>>> PLUGMAN.process_plugin_data('CSS')
<a list of processed data items>
reg_plugins(direct, dbstate=None, uistate=None, load_on_reg=False, rescan=False)[source]

Searches the specified directory, and registers python plugin that are being defined in gpr.py files.

If a relationship calculator for env var LANG is present, it is immediately loaded so it is available for all.

register_option(option, guioption)[source]

Register an external option.

Register a mapping from option to guioption for an option that is not native to Gramps but provided by the plugin writer. This should typically be called during initialisation of a ReportOptions class.

Parameters:
  • option (class that inherits from gen.plug.menu.Option) – the option class

  • guioption (class that inherits from Gtk.Widget.) – the gui-option class

reload(module, pdata)[source]

Reloads modules that might not be in the path.

reload_plugins()[source]

Reload previously loaded plugins

Export

This module provides the Plugin class for export plugins.

class gramps.gen.plug._export.ExportPlugin(name, description, export_function, extension, config=None)[source]

Bases: Plugin

This class represents a plugin for exporting data from Gramps

get_config()[source]

Get the config.

Returns:

(??,??)

get_export_function()[source]

Get the export function for this plugin.

Returns:

the callable export_function passed into __init__()

get_extension()[source]

Get the file extension for the export file.

Returns:

str

Gramplet

class gramps.gen.plug._gramplet.Gramplet(gui, nav_group=0)[source]

Bases: object

Base class for non-graphical gramplet code.

active_changed(handle)[source]

Developers should put their code that occurs when the active person is changed.

add_option(option)[source]

Add an option to the GUI gramplet.

append_text(text, scroll_to='end')[source]

Append the text to the textview. Additionally, move the cursor to the position given. Positions are:

Position

Description

‘start’

start of textview

‘end’

end of textview

‘begin’

begin of line, before setting the text.

build_options()[source]

External constructor for developers to put code for building options.

clear_text()[source]

Clear all of the text from the textview.

connect(signal_obj, signal, method)[source]
connect_signal(nav_type, method)[source]

Connect the given method to the active-changed signal for the navigation type requested.

db_changed()[source]

Method executed when the database is changed.

disconnect(signal)[source]
disconnect_all()[source]

Used to disconnect all the signals for this specific gramplet

get_active(nav_type)[source]

Return the handle of the active object for the given navigation type.

get_active_object(nav_type)[source]

Return the object of the active handle for the given navigation type.

get_option(label)[source]

Retireve an option by its label text.

get_option_widget(label)[source]

Retrieve an option’s widget by its label text.

get_text()[source]

Returns the current text of the textview.

hidden_widgets()[source]

A list of widgets to keep hidden. Needed because Gramps uses show_all() in some places.

init()[source]

External constructor for developers to put their initialization code. Designed to be overridden.

insert_text(text)[source]

Insert the given text in the textview at the cursor.

interrupt(*args)[source]

Force the generator to stop running.

Creates a clickable link in the textview area.

load_data_to_text(pos=0)[source]

Load information from the data portion of the saved Gramplet to the textview.

main()[source]

The main place for the gramplet’s code. This is a generator. Generator which will be run in the background, through update().

no_wrap()[source]

The view in gramplet should not wrap. DEPRICATED: use set_wrap() instead.

on_load()[source]

Gramplets should override this to take care of loading previously their special data.

on_save()[source]

Gramplets should override this to take care of saving their special data.

pause(*args)[source]

Pause the main() method.

post_init()[source]
render_text(text)[source]

Render the given text, given that set_use_markup() is on.

resume(*args)[source]

Resume the main() method that has previously paused.

save_options()[source]
save_text_to_data()[source]

Save the textview to the data portion of a saved gramplet.

save_update_options(obj)[source]

Save a gramplet’s options to file.

set_active(nav_type, handle)[source]

Change the handle of the active object for the given navigation type.

set_has_data(value)[source]

Set the status as to whether this gramplet has data.

set_text(text, scroll_to='start')[source]

Clear and set the text to the given text. Additionally, move the cursor to the position given. Positions are:

Position

Description

‘start’

start of textview

‘end’

end of textview

‘begin’

begin of line, before setting the text.

set_tooltip(tip)[source]

Sets the tooltip for this gramplet.

set_use_markup(value)[source]

Allows the use of render_text to show markup.

set_wrap(value)[source]

Set the textview to wrap or not.

update(*args)[source]

The main interface for running the main() method.

update_all(*args)[source]

Force the main loop to run right now (as opposed to running in background).

update_has_data()[source]

By default, assume that the gramplet has data.

Import

This module provides the Plugin class for import plugins.

class gramps.gen.plug._import.ImportPlugin(name, description, import_function, extension)[source]

Bases: Plugin

This class represents a plugin for importing data into Gramps

get_extension()[source]

Get the extension for the files imported by this plugin.

Returns:

str

get_import_function()[source]

Get the import function for this plugins.

Returns:

the callable import_function passed into __init__()

Menu

Abstracted option handling.

class gramps.gen.plug.menu._menu.Menu[source]

Bases: object

Introduction

A Menu is used to maintain a collection of options that need to be represented to the user in a non-implementation specific way. The options can be described using the various option classes. A menu contains many options and associates them with a unique name and category.

Usage

Menus are used in the following way.

  1. Create an option object and configure all the attributes of the option.

  2. Add the option to the menu by specifying the option, name and category.

  3. Add as many options as necessary.

  4. When all the options are added, the menu can be stored and passed to the part of the system that will actually represent the menu to the user.

add_option(category, name, option)[source]

Add an option to the menu.

Parameters:
  • category (string) – A label that describes the category that the option belongs to. Example: “Report Options”

  • name (string) – A name that is unique to this option. Example: “generations”

  • option (gen.plug.menu.Option) – The option instance to be added to this menu.

Returns:

nothing

get_all_option_names()[source]

Get a list of all the option names in this menu.

Returns:

a list of strings

get_categories()[source]

Get a list of categories in this menu.

Returns:

a list of strings

get_option(category, name)[source]

Get an option with the specified category and name.

Returns:

an Option instance or None on failure.

get_option_by_name(name)[source]

Get an option with the specified name.

Returns:

an Option instance or None on failure.

get_option_names(category)[source]

Get a list of option names for the specified category.

Returns:

a list of strings

Option class representing a boolean (yes/no, true/false).

class gramps.gen.plug.menu._boolean.BooleanOption(label, value)[source]

Bases: Option

This class describes an option that is a boolean (True or False).

Option class representing a list of boolean values.

class gramps.gen.plug.menu._booleanlist.BooleanListOption(heading)[source]

Bases: Option

This class describes an option that provides a list of check buttons.

add_button(description, default)[source]

Add a check button to the list.

Parameters:
  • description (string) – A description for this check button. Example: “Census”

  • value (int) – The default for this check button (True or False). Example: True

Returns:

nothing

get_descriptions()[source]

Get a list of check button descriptions for this option.

Returns:

a list of check button descriptions.

get_selected()[source]

Get a list of descriptions where the check button is selected.

Returns:

a list of check button descriptions.

Option class representing a color.

class gramps.gen.plug.menu._color.ColorOption(label, value)[source]

Bases: Option

This class describes an option that allows the selection of a color.

Option class representing a file destination.

class gramps.gen.plug.menu._destination.DestinationOption(label, value)[source]

Bases: StringOption

This class describes an option that specifies a destination file or path. The destination can be a directory or a file. If the destination is a file, the extension can be specified.

get_directory_entry()[source]
Returns:

True if the destination is a directory. False if the destination is a file.

Return type:

bool

get_extension()[source]
Returns:

The extension for the destination file.

set_directory_entry(is_directory)[source]
Parameters:

is_directory (bool) – Specifies whether the destination is a directory or a file.

Returns:

nothing

set_extension(extension)[source]
Parameters:

extension (str) – Specifies the extension for the destination file.

Returns:

nothing

Option class representing an enumerated list of possible values.

class gramps.gen.plug.menu._enumeratedlist.EnumeratedListOption(label, value)[source]

Bases: Option

This class describes an option that provides a finite number of values. Each possible value is assigned a value and a description.

add_item(value, description, xml_item=False)[source]

Add an item to the list of possible values.

Parameters:
  • value (int) – The value that corresponds to this item. Example: 5

  • description (string) – A description of this value. Example: “8.5 x 11”

  • xml_item – allow deferred translation of item description

Returns:

nothing

clear()[source]

Clear all possible values from this option.

Returns:

nothing.

get_items(xml_items=False)[source]

Get all the possible values for this option.

Parameters:

xml_items – allow deferred translation of item descriptions

Returns:

an array of tuples containing (value,description) pairs.

set_items(items, xml_items=False)[source]

Add a list of items to the list of possible values.

Parameters:
  • items (array) – A list of tuples containing value, description pairs. Example: [ (5,”8.5 x 11”), (6,”11 x 17”)]

  • xml_items – allow deferred translation of item descriptions

Returns:

nothing

set_value(value)[source]

Set the value of this option.

Parameters:

value (The type will depend on the type of option.) – A value for this option. Example: True

Returns:

nothing

Option class representing a family.

class gramps.gen.plug.menu._family.FamilyOption(label)[source]

Bases: StringOption

This class describes an option that allows a family from the database to be selected.

Option class representing a list of filters.

class gramps.gen.plug.menu._filter.FilterOption(label, value)[source]

Bases: EnumeratedListOption

This class describes an option that provides a list of person filters. Each possible value represents one of the possible filters.

get_filter()[source]

Return the currently selected filter object.

Returns:

A filter object.

set_filters(filter_list)[source]

Set the list of filters available to be chosen from.

Parameters:

filter_list (array) – An array of person filters.

Returns:

nothing

Option class representing a media object.

class gramps.gen.plug.menu._media.MediaOption(label)[source]

Bases: StringOption

This class describes an option that allows a media object from the database to be selected.

Option class representing a string.

class gramps.gen.plug.menu._note.NoteOption(label)[source]

Bases: StringOption

This class describes an option that allows a note from the database to be selected.

Option class representing a number.

class gramps.gen.plug.menu._number.NumberOption(label, value, min_val, max_val, step=1)[source]

Bases: Option

This class describes an option that is a simple number with defined maximum and minimum values.

get_max()[source]

Get the maximum value for this option.

Returns:

an int that represents the maximum value for this option.

get_min()[source]

Get the minimum value for this option.

Returns:

an int that represents the minimum value for this option.

get_step()[source]

Get the step size for this option.

Returns:

an int that represents the step size for this option.

The base option class for all other option classes.

class gramps.gen.plug.menu._option.Option(label, value)[source]

Bases: Callback

This class serves as a base class for all options. All Options must minimally provide the services provided by this class. Options are allowed to add additional functionality.

get_available()[source]

Get the availability of this option.

Returns:

A Bool indicating the availablity of this option. True indicates that the option is available. False indicates that the option is not available.

get_help()[source]

Get the help information for this option.

Returns:

A string that provides additional help beyond the label.

get_label()[source]

Get the friendly label for this option.

Returns:

string

get_value()[source]

Get the value of this option.

Returns:

The option value.

set_available(avail)[source]

Set the availability of this option.

Parameters:

avail (Bool) – An indicator of whether this option is currently available. True indicates that the option is available. False indicates that the option is not available.

Returns:

nothing

set_help(help_text)[source]

Set the help information for this option.

Parameters:

help – A string that provides additional help beyond the label. Example: “Whether to include or exclude people who are calculated to be alive at the time of the generation of this report”

Returns:

nothing

set_label(label)[source]

Set the friendly label for this option.

Parameters:

label (string) – A friendly label to be applied to this option. Example: “Exclude living people”

Returns:

nothing

set_value(value)[source]

Set the value of this option.

Parameters:

value (The type will depend on the type of option.) – A value for this option. Example: True

Returns:

nothing

Option class representing a person.

class gramps.gen.plug.menu._person.PersonOption(label)[source]

Bases: StringOption

This class describes an option that allows a person from the database to be selected.

Option class representing a list of people.

class gramps.gen.plug.menu._personlist.PersonListOption(label)[source]

Bases: Option

This class describes a widget that allows multiple people from the database to be selected.

Option class representing a list of places.

class gramps.gen.plug.menu._placelist.PlaceListOption(label)[source]

Bases: Option

This class describes a widget that allows multiple places from the database to be selected.

Option class representing a string.

class gramps.gen.plug.menu._string.StringOption(label, value)[source]

Bases: Option

This class describes an option that is a simple one-line string.

Option class representing a document style.

class gramps.gen.plug.menu._style.StyleOption(label, default_style, module_name)[source]

Bases: EnumeratedListOption

This class describes an option that allows the use to select a style sheet.

get_default_style()[source]

Get the default style

get_style()[source]

Get the selected style

get_style_file()[source]

Get the name of the style file

Option class representing color/surname mappings.

class gramps.gen.plug.menu._surnamecolor.SurnameColorOption(label)[source]

Bases: Option

This class describes a widget that allows multiple surnames to be selected from the database, and to assign a color (not necessarily unique) to each one.

Option class representing a block of text.

class gramps.gen.plug.menu._text.TextOption(label, value)[source]

Bases: Option

This class describes an option that is a multi-line string.

Options

General option handling, including saving and parsing.

class gramps.gen.plug._options.MenuOptions[source]

Bases: object

Introduction

A MenuOptions is used to implement the necessary functions for adding options to a menu.

add_menu_option(category, name, option)[source]

Add a single option to the menu.

add_menu_options(menu)[source]

Add the user defined options to the menu.

Parameters:

menu (Menu) – A menu class for the options to belong to.

Returns:

nothing

add_user_options()[source]

Generic method to add user options to the menu.

make_default_style(default_style)[source]

This function is currently required by some reports.

parse_user_options()[source]

Load the changed values into the saved options.

class gramps.gen.plug._options.OptionHandler(module_name, options_dict, person_id=None)[source]

Bases: object

Implements handling of the options for the plugins.

get_person_id()[source]
init_common()[source]
init_subclass()[source]
save_common_options()[source]
save_options()[source]

Saves options to file.

We need to only store non-default options. Therefore, we remove all options whose values are the defaults prior to saving.

set_common_options()[source]
set_options()[source]

Set options to be used in this plugin according to the passed options dictionary.

Dictionary values are all strings, since they were read from XML. Here we need to convert them to the needed types. We use default values to determine the type.

set_person_id(val)[source]
class gramps.gen.plug._options.OptionList[source]

Bases: object

Implements a set of options to parse and store for a given module.

get_option(name)[source]

Return the value of a particular option in the OptionList.

Parameters:

name (str) – name of the option to retrieve

Returns:

value associated with the passed option

Return type:

str

get_options()[source]

Return the whole bunch of options for the OptionList.

Returns:

list of options

Return type:

list

remove_option(name)[source]

Remove a particular option from the OptionList.

Parameters:

name (str) – name of the option to remove.

set_option(name, value)[source]

Set a particular option in the OptionList.

Parameters:
  • name (str) – name of the option to set.

  • value (str) – value of the option to set.

set_options(options)[source]

Set the whole bunch of options for the OptionList.

Parameters:

options (list) – list of options to set.

class gramps.gen.plug._options.OptionListCollection(filename)[source]

Bases: object

Implements a collection of option lists.

get_module_names()[source]

Return a list of all the module names in the OptionListCollection

Returns:

returns the list of module names

Return type:

list

get_option_list(name)[source]

Return the option_list associated with the module name

Parameters:

name (str) – name associated with the desired module.

Returns:

returns the option list associated with the name, or None of no such option exists

Return type:

str

get_option_list_map()[source]

Return the map of module names to option lists.

Returns:

Returns the map of module names to option lists.

Return type:

dictionary

init_common()[source]
parse()[source]

Loads the OptionList from the associated file, if it exists.

save()[source]

Saves the current OptionListCollection to the associated file.

set_option_list(name, option_list)[source]

Add or replaces an option_list in the OptionListCollection.

Parameters:
  • name (str) – name associated with the module to add or replace.

  • option_list (OptionList) – list of options

write_common(filename)[source]

Stub function for common options. Overridden by reports.

write_module_common(filename, option_list)[source]

Stub function for common options. Overridden by reports.

class gramps.gen.plug._options.OptionParser(collection)[source]

Bases: ContentHandler

SAX parsing class for the OptionListCollection XML file.

endElement(tag)[source]

Overridden class that handles the end of a XML element

startElement(tag, attrs)[source]

Overridden class that handles the start of a XML element

class gramps.gen.plug._options.Options(name, person_id=None)[source]

Bases: object

Defines options and provides handling interface.

This is a base Options class for the modules. All modules, options classes should derive from it.

add_user_options()[source]

Set up UI controls (widgets) for the options specific for this module.

This method MUST be overridden by modules that define new options.

Note

To really have any effect besides looking pretty, each widget set up here must be also parsed in the parse_user_options() method below.

load_previous_values()[source]

Modifies all options to have the value they were last used as. Call this function after all options have been added.

parse_user_options()[source]

Parses UI controls (widgets) for the options specific for this module.

This method MUST be overridden by modules that define new options.

After obtaining values from the widgets, they MUST be used to set the appropriate options_dict values. Otherwise the values will not have any user-visible effect.

Note

Any widget parsed here MUST be defined and added to the dialog in the add_user_options() method above.

Reports

Report option handling, including saving and parsing.

class gramps.gen.plug.report._options.DocOptionHandler(module_name, options_dict)[source]

Bases: OptionHandler

Implements handling of the docgen options for the plugins.

init_subclass()[source]
set_options()[source]

Set options to be used in this plugin according to the passed options dictionary.

Dictionary values are all strings, since they were read from XML. Here we need to convert them to the needed types. We use default values to determine the type.

class gramps.gen.plug.report._options.DocOptionListCollection(filename)[source]

Bases: OptionListCollection

Implements a collection of option lists.

init_common()[source]
parse()[source]

Loads the OptionList from the associated file, if it exists.

class gramps.gen.plug.report._options.DocOptionParser(collection)[source]

Bases: OptionParser

SAX parsing class for the DocOptionListCollection XML file.

endElement(tag)[source]

Overridden class that handles the end of a XML element

startElement(tag, attrs)[source]

Overridden class that handles the start of a XML element

class gramps.gen.plug.report._options.DocOptions(name)[source]

Bases: MenuOptions

Defines options and provides handling interface.

load_previous_values()[source]
class gramps.gen.plug.report._options.EmptyDoc[source]

Bases: object

close()[source]
init()[source]
open(filename)[source]
set_creator(creator)[source]
set_rtl_doc(value)[source]
class gramps.gen.plug.report._options.MenuReportOptions(name, dbase)[source]

Bases: MenuOptions, ReportOptions

The MenuReportOptions class implements the ReportOptions functionality in a generic way so that the user does not need to be concerned with the actual representation of the options.

The user should inherit the MenuReportOptions class and override the add_menu_options function. The user can add options to the menu and the MenuReportOptions class will worry about setting up the UI.

get_subject()[source]

Return a string that describes the subject of the report.

This method MUST be overridden by subclasses.

load_previous_values()[source]

Modifies all options to have the value they were last used as. Call this function after all options have been added.

class gramps.gen.plug.report._options.OptionHandler(module_name, options_dict)[source]

Bases: OptionHandler

Implements handling of the options for the plugins.

get_css_filename()[source]

get the CSS filename

get_custom_paper_size()[source]

get the paper’s custom paper size, if any

get_default_stylesheet_name()[source]

get the default stylesheet name

get_format_name()[source]

get the format name

get_margins()[source]

get the paper’s margin sizes

get_orientation()[source]

get the paper’s orientation

get_paper()[source]

This method is for temporary storage, not for saving/restoring.

get_paper_metric()[source]

get the paper metric

get_paper_name()[source]

get the paper name

get_stylesheet_savefile()[source]

Where to save user defined styles for this report.

init_common()[source]

Specific initialization for reports.

init_subclass()[source]
save_common_options()[source]
save_options()[source]

Saves options to file.

set_common_options()[source]
set_css_filename(css_filename)[source]

set the CSS filename

set_custom_paper_size(custom_paper_size)[source]

set the paper’s custom paper size

set_default_stylesheet_name(style_name)[source]

set the default stylesheet name

set_format_name(format_name)[source]

set the format name

set_margins(margins)[source]

set the paper’s margin sizes

set_orientation(orientation)[source]

set the paper’s orientation

set_paper(paper)[source]

This method is for temporary storage, not for saving/restoring.

set_paper_metric(paper_metric)[source]

set the paper metric

set_paper_name(paper_name)[source]

set the paper name

class gramps.gen.plug.report._options.OptionList[source]

Bases: OptionList

Implements a set of options to parse and store for a given report.

get_css_filename()[source]

Return the template name of the OptionList.

Returns:

template name

Return type:

str

get_custom_paper_size()[source]

Return the custom paper size for the OptionList.

Returns:

returns the custom paper size in cm

Return type:

[float, float]

get_format_name()[source]

Return the format name of the OptionList.

Returns:

returns the format name

Return type:

str

get_margin(pos)[source]

Return a margin for the OptionList.

Parameters:

pos (int) – Position of margin [left, right, top, bottom]

Returns:

float cm of margin

Return type:

float

get_margins()[source]

Return the margins for the OptionList.

Returns margins:

returns the margins, floats in cm

Rtype margins:

[float, float, float, float]

get_orientation()[source]

Return the orientation for the OptionList.

Returns:

returns the selected orientation. Valid values are PAPER_LANDSCAPE or PAPER_PORTRAIT

Return type:

int

get_output()[source]

Return the output of the OptionList.

Returns:

returns the output name

Return type:

str

get_paper_metric()[source]

Return the paper metric of the OptionList.

Returns:

returns whether to use metric

Return type:

boolean

get_paper_name()[source]

Return the paper name of the OptionList.

Returns:

returns the paper name

Return type:

str

get_style_name()[source]

Return the style name of the OptionList.

Returns:

string representing the style name

Return type:

str

set_css_filename(css_filename)[source]

Set the template name for the OptionList.

Parameters:

template_name (str) – name of the template to set.

set_custom_paper_size(paper_size)[source]

Set the custom paper size for the OptionList.

Parameters:

paper_size ([float, float]) – paper size to set in cm.

set_format_name(format_name)[source]

Set the format name for the OptionList.

Parameters:

format_name (str) – name of the format to set.

set_margin(pos, value)[source]

Set a margin for the OptionList.

Parameters:
  • pos (int) – Position of margin [left, right, top, bottom]

  • value (float) – floating point in cm

set_margins(margins)[source]

Set the margins for the OptionList.

Parameters:

margins ([float, float, float, float]) – margins to set. Possible values are floats in cm

set_orientation(orientation)[source]

Set the orientation for the OptionList.

Parameters:

orientation (int) – orientation to set. Possible values are PAPER_LANDSCAPE or PAPER_PORTRAIT

set_output(output)[source]

Set the output for the OptionList.

Parameters:

output (str) – name of the output to set.

set_paper_metric(paper_metric)[source]

Set the paper metric for the OptionList.

Parameters:

paper_metric – whether to use metric.

set_paper_name(paper_name)[source]

Set the paper name for the OptionList.

Parameters:

paper_name (str) – name of the paper to set.

set_style_name(style_name)[source]

Set the style name for the OptionList.

Parameters:

style_name (str) – name of the style to set.

class gramps.gen.plug.report._options.OptionListCollection(filename)[source]

Bases: OptionListCollection

Implements a collection of option lists.

get_last_css_filename()[source]

Return the last template used for any report in this collection.

get_last_custom_paper_size()[source]

Return the last custom paper size used for any report in this collection.

Returns:

list of last custom paper size used in cm (width, height)

Return type:

[float, float]

get_last_format_name()[source]

Return the last format used for any report in this collection.

get_last_margin(pos)[source]

Return the last margins used for any report in this collection.

Parameters:

pos (int) – position in margins list

Returns:

last margin used in pos

Return type:

float

get_last_margins()[source]

Return the last margins used for any report in this collection.

Returns:

list of last margins used in cm (left, right, top, bottom)

Return type:

[float, float, float, float]

get_last_orientation()[source]

Return the last orientation used for any report in this collection.

Returns:

last orientation used

Return type:

int

get_last_paper_metric()[source]

Return the last paper metric used for any report in this collection.

Returns:

returns whether or not to use metric

Return type:

boolean

get_last_paper_name()[source]

Return the last paper name used for any report in this collection.

Returns:

returns the name of the paper

Return type:

str

init_common()[source]
parse()[source]

Loads the OptionList from the associated file, if it exists.

set_last_css_filename(css_filename)[source]

Set the last css used for any report in this collection.

Parameters:

css_filename – name of the style to set.

set_last_custom_paper_size(custom_paper_size)[source]

Set the last custom paper size used for any report in this collection.

Parameters:

custom_paper_size ([float, float]) – size to set in cm (width, height)

set_last_format_name(format_name)[source]

Set the last format used for any report in this collection.

Parameters:

format_name – name of the format to set.

set_last_margin(pos, value)[source]

Set the last margin used for any report in this collection.

Parameters:
  • pos (int) – pos to set (0-4) (left, right, top, bottom)

  • value (float) – value to set the margin to in cm

set_last_margins(margins)[source]

Set the last margins used for any report in this collection.

Parameters:

margins ([float, float, float, float]) – margins to set in cm (left, right, top, bottom)

set_last_orientation(orientation)[source]

Set the last orientation used for any report in this collection.

Parameters:

orientation (int) – orientation to set.

set_last_paper_metric(paper_metric)[source]

Set the last paper metric used for any report in this collection.

Parameters:

paper_metric – whether to use metric.

set_last_paper_name(paper_name)[source]

Set the last paper name used for any report in this collection.

Parameters:

paper_name (str) – name of the paper to set.

write_common(file)[source]

Stub function for common options. Overridden by reports.

write_module_common(file, option_list)[source]

Stub function for common options. Overridden by reports.

class gramps.gen.plug.report._options.OptionParser(collection)[source]

Bases: OptionParser

SAX parsing class for the OptionListCollection XML file.

endElement(tag)[source]

Overridden class that handles the end of a XML element

startElement(tag, attrs)[source]

Overridden class that handles the start of a XML element

class gramps.gen.plug.report._options.ReportOptions(name, dbase)[source]

Bases: Options

Defines options and provides handling interface.

This is a base Options class for the reports. All reports, options classes should derive from it.

get_document()[source]

Return document instance.

Warning

This method MUST NOT be overridden by subclasses.

get_output()[source]

Return document output destination.

Warning

This method MUST NOT be overridden by subclasses.

load_previous_values()[source]

Modifies all options to have the value they were last used as. Call this function after all options have been added.

make_default_style(default_style)[source]

Defines default style for this report.

This method MUST be overridden by reports that use the user-adjustable paragraph styles.

Note

Unique names MUST be used for all style names, otherwise the styles will collide when making a book with duplicate style names. A rule of safety is to prepend style name with the acronym based on report name.

The following acronyms are already taken:

Code

Report

AC

Ancestor Chart

AC2

Ancestor Chart 2 (Wall Chart)

AHN

Ahnentafel Report

AR

Comprehensive Ancestors report

CBT

Custom Book Text

DG

Descendant Graph

DR

Descendant Report

DAR

Detailed Ancestral Report

DDR

Detailed Descendant Report

FGR

Family Group Report

FC

Fan Chart

FTA

FTM Style Ancestral report

FTD

FTM Style Descendant report

IDS

Individual Complete Report

IDX

Alphabetical Index

IVS

Individual Summary Report

PLC

Place Report

SBT

Simple Book Title

TLG

Timeline Graph

TOC

Table Of Contents

set_document(val)[source]

Set document to a given instance.

Warning

This method MUST NOT be overridden by subclasses.

set_output(val)[source]

Set output destination to a given string.

Warning

This method MUST NOT be overridden by subclasses.

gramps.gen.plug.report._options.escxml(word)[source]

Contain and organize bibliographic information.

class gramps.gen.plug.report._bibliography.Bibliography(mode=31)[source]

Bases: object

Store and organize multiple citations into a bibliography.

MODE_ALL = 31
MODE_CONF = 4
MODE_DATE = 1
MODE_MEDIA = 16
MODE_NOTE = 8
MODE_PAGE = 2
add_reference(lib_citation)[source]

Add a reference to a source to this bibliography. If the source already exists, don’t add it again. If a similar reference exists, don’t add another one.

Parameters:

citation (Citation) – Citation object

Returns:

A tuple containing the index of the source among all the sources and the key of the reference among all the references. If there is no reference information, the second element will be None.

Return type:

(int,char) or (int,None)

Note

Within this file, the name ‘citation’ is used both for gen.lib.Citation, and for _bibliography.Citation. It is not clear how best to rename the concepts in this file to avoid the clash, so the names have been retained. In this function, lib_citation is used for gen.lib.Citation instances, and citation for _bibliography.Citation instances. Elsewhere in this file, source_ref is used for gen.lib.Citation instances.

get_citation_count()[source]

Report the number of citations in this bibliography.

Returns:

number of citations

Return type:

int

get_citation_list()[source]

Return a list containing all the citations in this bibliography.

Returns:

citation list

Return type:

list of Citation objects

class gramps.gen.plug.report._bibliography.Citation[source]

Bases: object

Store information about a citation and all of its references.

add_reference(source_ref)[source]

Add a reference to this citation. If a similar reference exists, don’t add another one.

Parameters:

source_ref (Citation) – Source Reference

Returns:

The key of the added reference among all the references.

Return type:

char

get_ref_list()[source]

List all the references to this citation.

Returns:

a list of references

Return type:

list of Citation objects

get_source_handle()[source]

Provide the handle to the source that this citation is for.

Returns:

Source Handle

Return type:

handle

set_source_handle(handle)[source]

Set the handle for the source that this citation is for.

Parameters:

handle (handle) – Source Handle

Report Generation Framework

Provide utilities for printing endnotes in text reports.

gramps.gen.plug.report.endnotes.add_endnote_styles(style_sheet)[source]

Add paragraph styles to a style sheet to be used for displaying endnotes.

Parameters:

style_sheet (StyleSheet) – Style sheet

gramps.gen.plug.report.endnotes.cite_source(bibliography, database, obj, elocale=<gramps.gen.utils.grampslocale.GrampsLocale object>)[source]

Cite any sources for the object and add them to the bibliography.

Parameters:
  • bibliography (Bibliography) – The bibliography to contain the citations.

  • obj (CitationBase) – An object with source references.

  • elocale (a GrampsLocale instance) – allow deferred translation of dates and strings

gramps.gen.plug.report.endnotes.write_endnotes(bibliography, database, doc, printnotes=False, links=False, elocale=<gramps.gen.utils.grampslocale.GrampsLocale object>)[source]

Write all the entries in the bibliography as endnotes.

If elocale is passed in (a GrampsLocale), then (insofar as possible) the translated values will be returned instead.

Parameters:
  • bibliography (Bibliography) – The bibliography that contains the citations.

  • database (DbBase) – The database that the sources come from.

  • doc (TextDoc) – The document to write the endnotes into.

  • printnotes (bool) – Indicate if the notes attached to a source must be written too.

  • links (bool) – Indicate if URL links should be makde ‘clickable’.

  • elocale (a GrampsLocale instance) – allow deferred translation of dates and strings

class gramps.gen.plug.report._paper.PageSizeParser(paper_list)[source]

Bases: ContentHandler

Parses the XML file and builds the list of page sizes

setDocumentLocator(locator)[source]

Called by the parser to give the application a locator for locating the origin of document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application’s business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

startElement(tag, attrs)[source]

Signals the start of an element in non-namespace mode.

The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.

class gramps.gen.plug.report._reportbase.Report(database, options_class, user)[source]

Bases: object

The Report base class. This is a base class for generating customized reports. It cannot be used as is, but it can be easily sub-classed to create a functional report generator.

begin_report()[source]
end_report()[source]
set_locale(language)[source]

Set the translator to one selected with stdoptions.add_localization_option().

write_report()[source]

A collection of utilities to aid in the generation of reports.

gramps.gen.plug.report.utils.cm2pt(cm_)[source]

Convert centimeters to points. Fonts are typically specified in points, but the BaseDoc classes use centimeters.

Parameters:

cm (float or int) – centimeters

Returns:

equivalent units in points

Return type:

float

gramps.gen.plug.report.utils.find_marriage(database, family)[source]

find the marriage of a family

gramps.gen.plug.report.utils.find_spouse(person, family)[source]

find the spouse of a person

gramps.gen.plug.report.utils.get_address_str(addr)[source]

Return a string that combines the elements of an address

Parameters:

addr – the Gramps address instance

gramps.gen.plug.report.utils.get_family_filters(database, family, include_single=True, name_format=None)[source]

Return a list of filters that are relevant for the given family

Parameters:
  • database (DbBase) – The database that the family is in.

  • family (Family) – the family the filters should apply to.

  • include_single (boolean) – include a filter to include the single family

  • name_format (None or int) – optional format to control display of person’s name

gramps.gen.plug.report.utils.get_person_filters(person, include_single=True, name_format=None)[source]

Return a list of filters that are relevant for the given person

Parameters:
  • person (Person) – the person the filters should apply to.

  • include_single (boolean) – include a filter to include the single person

  • name_format (None or int) – optional format to control display of person’s name

gramps.gen.plug.report.utils.get_person_mark(dbase, person)[source]

Return a IndexMark that can be used to index a person in a report

Parameters:
  • dbase – the Gramps database instance

  • person – the key is for

gramps.gen.plug.report.utils.insert_image(database, doc, photo, user, w_cm=4.0, h_cm=4.0, alt='', style_name=None, align='right')[source]

Insert pictures of a person into the document.

Parameters:
  • alt – an alternative text to use. Useful for eg html reports

  • style_name – style to use for the “alternative text” or captions

  • align – image alignment: ‘left’, ‘right’, ‘center’, or ‘single’

gramps.gen.plug.report.utils.place_name(dbase, place_handle)[source]

returns a place string given a handle

gramps.gen.plug.report.utils.pt2cm(pt_)[source]

Convert points to centimeters. Fonts are typically specified in points, but the BaseDoc classes use centimeters.

Parameters:

pt (float or int) – points

Returns:

equivalent units in centimeters

Return type:

float

gramps.gen.plug.report.utils.rgb_color(color)[source]

Convert color value from 0-255 integer range into 0-1 float range.

Parameters:

color (int) – list or tuple of integer values for red, green, and blue

Returns:

(red, green, blue) tuple of floating point color values

Return type:

3-tuple

gramps.gen.plug.report.utils.roman(num)[source]

Integer to Roman numeral converter for 0 < num < 4000

Docgen

This module provides the Plugin class for document generator plugins.

class gramps.gen.plug._docgenplugin.DocGenPlugin(name, description, basedoc, paper, style, extension, docoptclass, basedocname)[source]

Bases: Plugin

This class represents a plugin for generating documents from Gramps

get_basedoc()[source]

Get the BaseDoc class for this plugin.

Returns:

the BaseDoc class passed into __init__()

get_basedocname()[source]

Get the BaseDoc name for this plugin.

Returns:

the BaseDoc name passed into __init__()

get_doc_option_class()[source]

Get the DocOptions subclass for this plugin, if any

Returns:

the DocOptions subclass passed into __init__()

get_draw_support()[source]

Check if the plugin supports the DrawDoc interface.

Returns:

bool: True if DrawDoc is supported; False if DrawDoc is not supported.

get_extension()[source]

Get the file extension for the output file.

Returns:

str

get_paper_used()[source]

Get the paper flag for this plugin.

Returns:

bool - True = use paper; False = do not use paper

get_style_support()[source]

Get the style flag for this plugin.

Returns:

bool - True = use styles; False = do not use styles

get_text_support()[source]

Check if the plugin supports the TextDoc interface.

Returns:

bool: True if TextDoc is supported; False if TextDoc is not supported.

Generators

Provide base interface to text based documents. Specific document interfaces should be derived from the core classes.

class gramps.gen.plug.docgen.basedoc.BaseDoc(styles, paper_style, track=[], uistate=None)[source]

Bases: object

Base class for document generators. Different output formats, such as OpenOffice, AbiWord, and LaTeX are derived from this base class, providing a common interface to all document generators.

abstract close()[source]

Closes the generated file.

get_creator()[source]

Return the owner name

get_rtl_doc()[source]
get_style_sheet()[source]

Return the StyleSheet of the document.

init()[source]
abstract open(filename)[source]

Opens the file so that it can be generated.

Parameters:

filename – path name of the file to create

set_creator(name)[source]

Set the owner name

set_rtl_doc(value)[source]
set_style_sheet(style_sheet)[source]

Set the StyleSheet of the document.

Parameters:

style_sheet (StyleSheet) – The new style sheet for the document

class gramps.gen.plug.docgen.drawdoc.DrawDoc[source]

Bases: object

Abstract Interface for graphical document generators. Output formats for graphical reports must implement this interface to be used by the report system.

abstract center_text(style, text, x1, y1, mark=None)[source]
Parameters:

markIndexMark to use for indexing (if supported)

abstract draw_box(style, text, x, y, w, h, mark=None)[source]
Parameters:

markIndexMark to use for indexing (if supported)

abstract draw_line(style, x1, y1, x2, y2)[source]

Draw a line.

abstract draw_path(style, path)[source]

Draw a path.

abstract draw_text(style, text, x1, y1, mark=None)[source]
Parameters:

markIndexMark to use for indexing (if supported)

abstract end_page()[source]

End a page.

get_usable_height()[source]

Return the height of the text area in centimeters. The value is the page height less the margins.

get_usable_width()[source]

Return the width of the text area in centimeters. The value is the page width less the margins.

abstract rotate_text(style, text, x, y, angle, mark=None)[source]
Parameters:

markIndexMark to use for indexing (if supported)

abstract start_page()[source]

Start a page.

string_multiline_width(fontstyle, text)[source]

Determine the width need for multiline text in given font

string_width(fontstyle, text)[source]

Determine the width need for text in given font

Provide a rough estimate of the width of a text string.

gramps.gen.plug.docgen.fontscale.string_multiline_width(font, text)[source]
gramps.gen.plug.docgen.fontscale.string_trim(font, text, width, ellipses='...')[source]

Like string_width, but this makes sure the length of the string is <= width. Optionally, add ellipses (…).

gramps.gen.plug.docgen.fontscale.string_width(font, text)[source]

returns with width of a string in the specified font

class gramps.gen.plug.docgen.fontstyle.FontStyle(style=None)[source]

Bases: object

Defines a font style. Controls the font face, size, color, and attributes. In order to remain generic, the only font faces available are FONT_SERIF and FONT_SANS_SERIF. Document formatters should convert these to the appropriate fonts for the target format.

The FontStyle represents the desired characteristics. There are no guarentees that the document format generator will be able implement all or any of the characteristics.

get_bold()[source]

1 indicates use bold face

get_color()[source]

Return an RGB color tuple

get_italic()[source]

1 indicates use italics

get_size()[source]

returns font size in points

get_type_face()[source]

returns the font face type

get_underline()[source]

1 indicates underlining

set(face=None, size=None, italic=None, bold=None, underline=None, color=None)[source]

Set font characteristics.

Parameters:
  • face – font type face, either FONT_SERIF or FONT_SANS_SERIF

  • size – type face size in points

  • italic – True enables italics, False disables italics

  • bold – True enables bold face, False disables bold face

  • underline – True enables underline, False disables underline

  • color – an RGB color representation in the form of three integers in the range of 0-255 represeting the red, green, and blue components of a color.

set_bold(val)[source]

0 disables bold face, 1 enables bold face

set_color(val)[source]

sets the color using an RGB color tuple

set_italic(val)[source]

0 disables italics, 1 enables italics

set_size(val)[source]

sets font size in points

set_type_face(val)[source]

sets the font face type

set_underline(val)[source]

1 enables underlining

Graphviz adapter for Graphs

class gramps.gen.plug.docgen.graphdoc.GVDoc[source]

Bases: object

Abstract Interface for Graphviz document generators. Output formats for Graphviz reports must implement this interface to be used by the report system.

abstract add_comment(comment)[source]

Add a comment to the source file.

Parameters:

comment (string) – A text string to add as a comment. Example: “Next comes the individuals.”

Returns:

nothing

Add a link between two nodes.

Parameters:
  • id1 (string) – The unique identifier of the starting node. Example: “p55”

  • id2 (string) – The unique identifier of the ending node. Example: “p55”

  • comment (string) – A text string displayed at the end of the link line. Example: “person C is the son of person A and person B”

Returns:

nothing

abstract add_node(node_id, label, shape='', color='', style='', fillcolor='', url='', htmloutput=False)[source]

Add a node to this graph. Nodes can be different shapes like boxes and circles.

Parameters:
  • node_id (string) – A unique identification value for this node. Example: “p55”

  • label (string) – The text to be displayed in the node. Example: “John Smith”

  • shape (string) – The shape for the node. Examples: “box”, “ellipse”, “circle”

  • color (string) – The color of the node line. Examples: “blue”, “lightyellow”

  • style (string) – The style of the node.

  • fillcolor (string) – The fill color for the node. Examples: “blue”, “lightyellow”

  • url (string) – A URL for the node.

  • htmloutput (boolean) – Whether the label contains HTML.

Returns:

nothing

abstract end_subgraph()[source]

End a subgraph that was previously started in this graph.

Returns:

nothing

abstract start_subgraph(graph_id)[source]

Start a subgraph in this graph.

Parameters:

id – The unique identifier of the subgraph. Example: “p55”

Returns:

nothing

class gramps.gen.plug.docgen.graphdoc.GVDocBase(options, paper_style, uistate=None)[source]

Bases: BaseDoc, GVDoc

Base document generator for all Graphviz document generators. Classes that inherit from this class will only need to implement the close function. The close function will generate the actual file of the appropriate type.

add_comment(comment)[source]

Add a comment.

Implements GVDocBase.add_comment().

Add a link between two nodes.

Implements GVDocBase.add_link().

add_node(node_id, label, shape='', color='', style='', fillcolor='', url='', htmloutput=False)[source]

Add a node to this graph. Nodes can be different shapes like boxes and circles.

Implements GVDocBase.add_node().

close()[source]

This isn’t useful by itself. Other classes need to override this and actually generate a file.

end_subgraph()[source]

Implement GVDocBase.end_subgraph()

open(filename)[source]

Implement GVDocBase.open()

start_subgraph(graph_id)[source]

Implement GVDocBase.start_subgraph()

write(text)[source]

Write text to the dot file

class gramps.gen.plug.docgen.graphdoc.GVDotDoc(options, paper_style, uistate=None)[source]

Bases: GVDocBase

GVDoc implementation that generates a .gv text file.

close()[source]

Implements GVDotDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVGifDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .gif file using Graphviz.

close()[source]

Implements GVGifDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVJpegDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .jpg file using Graphviz.

close()[source]

Implements GVJpegDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVOptions[source]

Bases: object

Defines all of the controls necessary to configure the graph reports.

add_menu_options(menu)[source]

Add all graph related options to the menu.

Parameters:

menu (Menu) – The menu the options should be added to.

Returns:

nothing

pages_changed()[source]

This method gets called every time the v_pages or h_pages options are changed; when both vertical and horizontal pages are set to “1”, then the page_dir control needs to be unavailable

class gramps.gen.plug.docgen.graphdoc.GVPdfGsDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .pdf file using Ghostscript.

close()[source]

Implements GVPdfGsDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVPdfGvDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .pdf file using Graphviz.

close()[source]

Implements GVPdfGvDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVPngDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .png file using Graphviz.

close()[source]

Implements GVPngDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVPsDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .ps file using Graphviz.

close()[source]

Implements GVPsDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVSvgDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .svg file using Graphviz.

close()[source]

Implements GVSvgDoc.close()

class gramps.gen.plug.docgen.graphdoc.GVSvgzDoc(options, paper_style)[source]

Bases: GVDocBase

GVDoc implementation that generates a .svg file using Graphviz.

close()[source]

Implements GVSvgzDoc.close()

class gramps.gen.plug.docgen.graphicstyle.GraphicsStyle(obj=None)[source]

Bases: object

Defines the properties of graphics objects, such as line width, color, fill, ect.

get_color()[source]
get_dash_style(val=None)[source]
get_dash_style_name(val=None)[source]
get_description()[source]

Return the description of the graphics object

get_fill_color()[source]
get_line_style()[source]
get_line_width()[source]

Return the name of the StyleSheet

get_paragraph_style()[source]
get_shadow()[source]
get_shadow_space()[source]
set_color(val)[source]
set_description(text)[source]

Set the description of the graphics object

set_fill_color(val)[source]
set_line_style(val)[source]
set_line_width(val)[source]

sets the line width

set_paragraph_style(val)[source]
set_shadow(val, space=0.2)[source]
gramps.gen.plug.docgen.graphicstyle.get_line_style_by_name(style_name)[source]
class gramps.gen.plug.docgen.paperstyle.PaperSize(name, height, width)[source]

Bases: object

Defines the dimensions of a sheet of paper. All dimensions are in centimeters.

get_height()[source]

Return the page height in cm

get_height_inches()[source]

Return the page height in inches

get_name()[source]

Return the name of the paper style

get_width()[source]

Return the page width in cm

get_width_inches()[source]

Return the page width in inches

set_height(height)[source]

Set the page height in cm

set_width(width)[source]

Set the page width in cm

class gramps.gen.plug.docgen.paperstyle.PaperStyle(size, orientation, lmargin=2.54, rmargin=2.54, tmargin=2.54, bmargin=2.54)[source]

Bases: object

Define the various options for a sheet of paper.

get_bottom_margin()[source]

Return the bottom margin.

Returns:

Bottom margin in centimeters

Return type:

float

get_left_margin()[source]

Return the left margin.

Returns:

Left margin in centimeters

Return type:

float

get_orientation()[source]

Return the orientation of the page.

Returns:

PAPER_PORTRIAT or PAPER_LANDSCAPE

Return type:

int

get_right_margin()[source]

Return the right margin.

Returns:

Right margin in centimeters

Return type:

float

get_size()[source]

Return the size of the paper.

Returns:

object indicating the paper size

Return type:

PaperSize

get_top_margin()[source]

Return the top margin.

Returns:

Top margin in centimeters

Return type:

float

get_usable_height()[source]

Return the height of the page area in centimeters.

The value is the page height less the margins.

get_usable_width()[source]

Return the width of the page area in centimeters.

The value is the page width less the margins.

class gramps.gen.plug.docgen.paragraphstyle.ParagraphStyle(source=None)[source]

Bases: object

Defines the characteristics of a paragraph. The characteristics are: font (a FontStyle instance), right margin, left margin, first indent, top margin, bottom margin, alignment, level, top border, bottom border, right border, left border, padding, and background color.

get_alignment()[source]

Return the alignment of the paragraph

get_alignment_text()[source]

Return a text string representing the alignment, either ‘left’, ‘right’, ‘center’, or ‘justify’

get_background_color()[source]

Return a tuple indicating the RGB components of the background color

get_bottom_border()[source]

Return 1 if a bottom border is specified

get_bottom_margin()[source]

returns the space below paragraph in centimeters

get_description()[source]

Return the description of the paragraph

get_first_indent()[source]

returns the first line indent in centimeters

get_font()[source]

Return the FontStyle of the paragraph

get_header_level()[source]

Return the header level of the paragraph

get_left_border()[source]

Return 1 if a left border is specified

get_left_margin()[source]

returns the left indent in centimeters

get_padding()[source]

Return a the padding of the paragraph

get_right_border()[source]

Return 1 if a right border is specified

get_right_margin()[source]

returns the right indent in centimeters

get_tabs()[source]
get_top_border()[source]

Return 1 if a top border is specified

get_top_margin()[source]

returns the space above paragraph in centimeters

set(rmargin=None, lmargin=None, first_indent=None, tmargin=None, bmargin=None, align=None, tborder=None, bborder=None, rborder=None, lborder=None, pad=None, bgcolor=None, font=None)[source]

Allows the values of the object to be set.

Parameters:
  • rmargin – right indent in centimeters

  • lmargin – left indent in centimeters

  • first_indent – first line indent in centimeters

  • tmargin – space above paragraph in centimeters

  • bmargin – space below paragraph in centimeters

  • align – alignment type (PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, or PARA_ALIGN_JUSTIFY)

  • tborder – non zero indicates that a top border should be used

  • bborder – non zero indicates that a bottom border should be used

  • rborder – non zero indicates that a right border should be used

  • lborder – non zero indicates that a left border should be used

  • pad – padding in centimeters

  • bgcolor – background color of the paragraph as an RGB tuple.

  • font – FontStyle instance that defines the font

set_alignment(align)[source]

Set the paragraph alignment.

Parameters:

align – PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, or PARA_ALIGN_JUSTIFY

set_background_color(color)[source]

Set the background color of the paragraph.

Parameters:

color – tuple representing the RGB components of a color (0,0,0) to (255,255,255)

set_bottom_border(val)[source]

Set the presence or absence of bottom border.

Parameters:

val – True indicates a border should be used, False indicates no border.

set_bottom_margin(value)[source]

sets the space below paragraph in centimeters

set_description(text)[source]

Set the description of the paragraph

set_first_indent(value)[source]

sets the first line indent in centimeters

set_font(font)[source]

Set the font style of the paragraph.

Parameters:

fontFontStyle object containing the font definition to use.

set_header_level(level)[source]

Set the header level for the paragraph. This is useful for numbered paragraphs. A value of 1 indicates a header level format of X, a value of two implies X.X, etc. A value of zero means no header level.

set_left_border(val)[source]

Set the presence or absence of left border.

Parameters:

val – True indicates a border should be used, False indicates no border.

set_left_margin(value)[source]

sets the left indent in centimeters

set_padding(val)[source]

Set the paragraph padding in centimeters

Parameters:

val – floating point value indicating the padding in centimeters

set_right_border(val)[source]

Set the presence or absence of rigth border.

Parameters:

val – True indicates a border should be used, False indicates no border.

set_right_margin(value)[source]

sets the right indent in centimeters

set_tabs(tab_stops)[source]
set_top_border(val)[source]

Set the presence or absence of top border.

Parameters:

val – True indicates a border should be used, False indicates no border.

set_top_margin(value)[source]

sets the space above paragraph in centimeters

class gramps.gen.plug.docgen.stylesheet.SheetParser(sheetlist)[source]

Bases: ContentHandler

SAX parsing class for the StyleSheetList XML file.

endElement(tag)[source]

Overridden class that handles the end of a XML element

startElement(tag, attrs)[source]

Overridden class that handles the start of a XML element

class gramps.gen.plug.docgen.stylesheet.StyleSheet(obj=None)[source]

Bases: object

A collection of named paragraph styles.

add_cell_style(name, style)[source]

Add a cell style to the style sheet.

Parameters:
add_draw_style(name, style)[source]

Add a draw style to the style sheet.

Parameters:
add_paragraph_style(name, style)[source]

Add a paragraph style to the style sheet.

Parameters:
add_table_style(name, style)[source]

Add a table style to the style sheet.

Parameters:
clear()[source]

Remove all styles from the StyleSheet

get_cell_style(name)[source]

Return the TableCellStyle associated with the name

Parameters:

name – name of the TableCellStyle that is wanted

get_cell_style_names()[source]

Return the list of cell style names in the StyleSheet

get_draw_style(name)[source]

Return the GraphicsStyle associated with the name

Parameters:

name – name of the GraphicsStyle that is wanted

get_draw_style_names()[source]

Return the list of draw style names in the StyleSheet

get_name()[source]

Return the name of the StyleSheet

get_paragraph_style(name)[source]

Return the ParagraphStyle associated with the name

Parameters:

name – name of the ParagraphStyle that is wanted

get_paragraph_style_names()[source]

Return the list of paragraph names in the StyleSheet

get_table_style(name)[source]

Return the TableStyle associated with the name

Parameters:

name – name of the TableStyle that is wanted

get_table_style_names()[source]

Return the list of table style names in the StyleSheet

is_empty()[source]

Checks if any styles are defined

set_name(name)[source]

Set the name of the StyleSheet

Parameters:

name – The name to be given to the StyleSheet

class gramps.gen.plug.docgen.stylesheet.StyleSheetList(filename, defstyle)[source]

Bases: object

Interface into the user’s defined style sheets. Each StyleSheetList has a predefined default style specified by the report. Additional styles are loaded from a specified XML file if it exists.

delete_style_sheet(name)[source]

Remove a style from the list. Since each style must have a unique name, the name is used to delete the stylesheet.

name - Name of the style to delete

get_style_names()[source]

Return a list of all the style names in the StyleSheetList

get_style_sheet(name)[source]

Return the StyleSheet associated with the name

name - name associated with the desired StyleSheet.

get_style_sheet_map()[source]

Return the map of names to styles.

parse()[source]

Loads the StyleSheets from the associated file, if it exists.

save()[source]

Saves the current StyleSheet definitions to the associated file.

set_style_sheet(name, style)[source]

Add or replaces a StyleSheet in the StyleSheetList. The default style may not be replaced.

name - name associated with the StyleSheet to add or replace. style - definition of the StyleSheet

write_cell_style(xml_file, sheet, c_name)[source]
write_graphics_style(xml_file, sheet, g_name)[source]
write_paragraph_style(xml_file, sheet, p_name)[source]
write_table_style(xml_file, sheet, t_name)[source]
gramps.gen.plug.docgen.stylesheet.cnv2color(text)[source]

converts a hex value in the form of #XXXXXX into a tuple of integers representing the RGB values

gramps.gen.plug.docgen.stylesheet.escxml(string)[source]

Escapes XML special characters.

class gramps.gen.plug.docgen.tablestyle.TableCellStyle(obj=None)[source]

Bases: object

Defines the style of a particular table cell. Characteristics are: right border, left border, top border, bottom border, and padding.

get_bottom_border()[source]

Return 1 if a bottom border is requested

get_description()[source]

Return the description of the table cell object

get_left_border()[source]

Return 1 if a left border is requested

get_longlist()[source]
get_padding()[source]

Return the cell padding in centimeters

get_right_border()[source]

Return 1 if a right border is requested

get_top_border()[source]

Return 1 if a top border is requested

set_borders(val)[source]

Defines if a border is used

Parameters:

val – if True, a border is used, if False, it is not

set_bottom_border(val)[source]

Defines if a bottom border in used

Parameters:

val – if 1, a bottom border is used, if 0, it is not

set_description(text)[source]

Set the description of the table cell object

set_left_border(val)[source]

Defines if a left border in used

Parameters:

val – if True, a left border is used, if False, it is not

set_longlist(val)[source]
set_padding(val)[source]

Return the cell padding in centimeters

set_right_border(val)[source]

Defines if a right border in used

Parameters:

val – if True, a right border is used, if False, it is not

set_top_border(val)[source]

Defines if a top border in used

Parameters:

val – if True, a top border is used, if False, it is not

class gramps.gen.plug.docgen.tablestyle.TableStyle(obj=None)[source]

Bases: object

Specifies the style or format of a table. The TableStyle contains the characteristics of table width (in percentage of the full width), the number of columns, and the width of each column as a percentage of the width of the table.

get_column_width(index)[source]

Return the column width of the specified column as a percentage of the entire table width.

Parameters:

index – column to return (index starts at 0)

get_columns()[source]

Return the number of columns

get_description()[source]

Return the description of the table object

get_width()[source]

Return the specified width as a percentage of the available space

set_column_width(index, width)[source]

Set the width of a specified column to the specified width.

Parameters:
  • index – column being set (index starts at 0)

  • width – percentage of the table width assigned to the column

set_column_widths(clist)[source]

Set the width of all the columns at once, taking the percentages from the passed list.

set_columns(columns)[source]

Set the number of columns.

Parameters:

columns – number of columns that should be used.

set_description(text)[source]

Set the description of the table object

set_width(width)[source]

Set the width of the table in terms of percent of the available width

class gramps.gen.plug.docgen.textdoc.IndexMark(key='', itype=0, level=1)[source]

Bases: object

Defines a mark to be associated with text for indexing.

class gramps.gen.plug.docgen.textdoc.TextDoc[source]

Bases: object

Abstract Interface for text document generators. Output formats for text reports must implement this interface to be used by the report system.

abstract add_media(name, align, w_cm, h_cm, alt='', style_name=None, crop=None)[source]

Add a photo of the specified width (in centimeters).

Parameters:
  • name – filename of the image to add

  • align – alignment of the image. Valid values are ‘left’, ‘right’, ‘center’, and ‘single’

  • w_cm – width in centimeters

  • h_cm – height in centimeters

  • alt – an alternative text to use. Useful for eg html reports

  • style_name – style to use for captions

  • crop – image cropping parameters

abstract end_bold()[source]

End a section of bold text.

abstract end_cell()[source]

Ends the current table cell.

abstract end_paragraph()[source]

Ends the current paragraph.

abstract end_row()[source]

Ends the current row on the current table.

abstract end_superscript()[source]

End a section of superscript text.

abstract end_table()[source]

Ends the current table.

insert_index()[source]

Insert an Alphabetical Index at this point in the document. This passes without error so that docgen types are not required to have this.

insert_toc()[source]

Insert a Table of Contents at this point in the document. This passes without error so that docgen types are not required to have this.

abstract page_break()[source]

Forces a page break, creating a new page.

abstract start_bold()[source]

Start a section of bold text.

abstract start_cell(style_name, span=1)[source]

Starts a new table cell, using the paragraph style specified.

Parameters:
  • style_nameTableCellStyle to use for the cell

  • span – number of columns to span

Start a link section. This defaults to underlining.

Parameters:

link – should be an item that makes sense in this docgen type, if it implements linking.

abstract start_paragraph(style_name, leader=None)[source]

Starts a new paragraph, using the specified style name.

Parameters:
  • style_name – name of the ParagraphStyle to use for the paragraph.

  • leader – Leading text for a paragraph. Typically used for numbering.

abstract start_row()[source]

Starts a new row on the current table.

abstract start_superscript()[source]

Start a section of superscript text.

abstract start_table(name, style_name)[source]

Starts a new table.

Parameters:
  • name – Unique name of the table.

  • style_nameTableStyle to use for the new table

start_underline()[source]

Start a section of underlining. This passes without error so that docgen types are not required to have this.

Stop the link section. Defaults to stopping the underlining for docgen types that don’t support links.

stop_underline()[source]

Stops a section of underlining. This passes without error so that docgen ntypes are not required to have this.

write_markup(text, s_tags, mark=None)[source]

Writes the text in the current paragraph. Should only be used after a start_paragraph and before an end_paragraph. Not all backends support s_tags, then the same happens as with write_text. Backends supporting write_markup will overwrite this method

Parameters:
  • text – text to write. The text is assumed to be _not_ escaped

  • s_tags – assumed to be list of styledtexttags to apply to the text

  • markIndexMark to use for indexing (if supported)

write_styled_note(styledtext, format, style_name, contains_html=False, links=False)[source]

Convenience function to write a styledtext to the cairo doc.

Parameters:
  • styledtext – assumed a StyledText object to write

  • format – 0 = Flowed, 1 = Preformatted

  • style_name – name of the style to use for default presentation

  • contains_html – bool, the backend should not check if html is present. If contains_html=True, then the textdoc is free to handle that in some way. Eg, a textdoc could remove all tags, or could make sure a link is clickable.

  • links – bool, make URLs in the text clickable (if supported)

overwrite this method if the backend supports styled notes

abstract write_text(text, mark=None, links=False)[source]

Writes the text in the current paragraph. Should only be used after a start_paragraph and before an end_paragraph.

Parameters:
  • text – text to write.

  • markIndexMark to use for indexing (if supported)

  • links – make URLs in the text clickable (if supported)

write_text_citation(text, mark=None, links=None)[source]

Method to write text with Gramps <super> citation marks.

Doc Backend

File and File format management for the different reports

class gramps.gen.plug.docbackend.cairobackend.CairoBackend(filename=None)[source]

Bases: DocBackend

Implementation for cairo docs

ESCAPE_FUNC()
STYLETAG_MARKUP = {0: ('<b>', '</b>'), 1: ('<i>', '</i>'), 2: ('<u>', '</u>'), 7: ('<sup>', '</sup>')}
STYLETAG_TO_PROPERTY = {3: 'face', 4: 'size', 5: 'foreground', 6: 'background'}
SUPPORTED_MARKUP = [0, 1, 2, 3, 4, 5, 6, 7]

File and File format management for the different reports

class gramps.gen.plug.docbackend.docbackend.DocBackend(filename=None)[source]

Bases: object

Base class for text document backends. The DocBackend manages a file to which it writes. It further knowns enough of the file format to be able to translate between the BaseDoc API and the file format. Specifically for text reports a translation of styled notes to the file format usage is done.

BOLD = 0
CLASSMAP = None
ESCAPE_FUNC()
FONTCOLOR = 5
FONTFACE = 3
FONTSIZE = 4
HIGHLIGHT = 6
ITALIC = 1
STYLETAG_MARKUP = {0: ('', ''), 1: ('', ''), 2: ('', ''), 7: ('', ''), 8: ('', '')}
STYLETYPE_MAP = {}
SUPERSCRIPT = 7
SUPPORTED_MARKUP = []
UNDERLINE = 2
add_markup_from_styled(text, s_tags, split='', escape=True)[source]

Input is plain text, output is text with markup added according to the s_tags which are assumed to be styledtexttags. When split is given the text will be split over the value given, and tags applied in such a way that it the text can be safely splitted in pieces along split.

Parameters:
  • text – str, a piece of text

  • s_tags – styledtexttags that must be applied to the text

  • split – str, optional. A string along which the output can be safely split without breaking the styling.

As adding markup means original text must be escaped, ESCAPE_FUNC is used. This can be used to convert the text of a styledtext to the format needed for a document backend. Do not call this method in a report, use the write_markup() method.

Note

the algorithm is complex as it assumes mixing of tags is not allowed: eg <b>text<i> here</b> not</i> is assumed invalid as markup. If the s_tags require such a setup, what is returned is <b>text</b><i><b> here</b> not</i> overwrite this method if this complexity is not needed.

close()[source]

Closes the file that is written on.

escape(preformatted=False)[source]

The escape func on text for this file format.

Parameters:

preformatted (bool) – some formats can have different escape function for normal text and preformatted text

property filename

The filename the backend works on

find_tag_by_stag(s_tag)[source]
Parameters:
  • s_tag – object: assumed styledtexttag

  • s_tagvalue – None/int/str: value associated with the tag

A styled tag is type with a value. Every styled tag must be converted to the tags used in the corresponding markup for the backend, eg <b>text</b> for bold in html. These markups are stored in STYLETAG_MARKUP. They are tuples for begin and end tag. If a markup is not present yet, it is created, using the _create_xmltag() method you can overwrite.

Default format for links. Override for better support.

value is: “TYPE DATA” where TYPE is ‘url’ or ‘ref’.

getf()[source]

Obtain the filename on which backend writes

open()[source]

Opens the document.

setf(value)[source]

Set the filename on which the backend writes, changing the value passed on initialization. Can only be done if the previous filename is not open.

write(string)[source]

Write a string to the file. There is no return value. Due to buffering, the string may not actually show up until the close() method is called.

writelines(sequence)[source]

Write a sequence of strings to the file. The sequence can be any iterable object producing strings, typically a list of strings.

exception gramps.gen.plug.docbackend.docbackend.DocBackendError(value='')[source]

Bases: Exception

Error used to report docbackend errors.

gramps.gen.plug.docbackend.docbackend.noescape(text)[source]

Function that does not escape the text passed. Default for backends

Register

This module provides the base class for plugin registration. It provides an object containing data about the plugin (version, filename, …) and a register for the data of all plugins .

class gramps.gen.plug._pluginreg.PluginData[source]

Bases: object

This is the base class for all plugin data objects. The workflow is:

  1. plugin manager reads all register files, and stores plugin data objects in a plugin register

  2. when plugin is needed, the plugin register creates the plugin, and the manager stores this, after which it can be executed.

Attributes present for all plugins

id
A unique identifier for the plugin. This is eg used to store the plugin
settings.
name
A friendly name to call this plugin (normally translated)
name_accell
A friendly name to call this plugin (normally translated), with an
accellerator present (eg '_Descendant report', with D to be accellerator
key
description
A friendly description of what the plugin does
version
The version of the plugin
status
The status of the plugin, STABLE or UNSTABLE
UNSTABLE is only visible in development code, not in release
fname
The python file where the plugin implementation can be found
fpath
The python path where the plugin implementation can be found
ptype
The plugin type. One of REPORT , QUICKREPORT, TOOL, IMPORT,
EXPORT, DOCGEN, GENERAL, MAPSERVICE, VIEW, GRAMPLET, DATABASE
authors
List of authors of the plugin, default=[]
authors_email
List of emails of the authors of the plugin, default=[]
supported
Bool value indicating if the plugin is still supported, default=True
load_on_reg
bool value, if True, the plugin is loaded on Gramps startup. Some
plugins. Only set this value if for testing you want the plugin to be
loaded immediately on startup. default=False

Attributes for RELCALC plugins:

relcalcclass
The class in the module that is the relationcalc class
lang_list
List of languages this plugin handles

Attributes for REPORT plugins:

require_active
Bool, If the reports requries an active person to be set or not
reportclass
The class in the module that is the report class
report_modes
The report modes: list of REPORT_MODE_GUI ,REPORT_MODE_BKI,REPORT_MODE_CLI

Attributes for REPORT and TOOL and QUICKREPORT and VIEW plugins

category
Or the report category the plugin belongs to, default=CATEGORY_TEXT
or the tool category a plugin belongs to, default=TOOL_UTILS
or the quickreport category a plugin belongs to, default=CATEGORY_QR_PERSON
or the view category a plugin belongs to,
default=("Miscellaneous", _("Miscellaneous"))

Attributes for REPORT and TOOL and DOCGEN plugins

optionclass
The class in the module that is the option class

Attributes for TOOL plugins

toolclass
The class in the module that is the tool class
tool_modes
The tool modes: list of TOOL_MODE_GUI, TOOL_MODE_CLI

Attributes for DOCGEN plugins

docclass
The class in the module that is the BaseDoc defined
paper
bool, Indicates whether the plugin uses paper or not, default=True
style
bool, Indicates whether the plugin uses styles or not, default=True

Attribute for DOCGEN, EXPORT plugins

extension
str, The file extension to use for output produced by the docgen/export,
default=''

Attributes for QUICKREPORT plugins

runfunc
The function that executes the quick report

Attributes for MAPSERVICE plugins

mapservice
The class in the module that is a mapservice

Attributes for EXPORT plugins

export_function
Function that produces the export
export_options
Class to set options
export_options_title
Title for the option page

Attributes for IMPORT plugins

import_function
Function that starts an import

Attributes for GRAMPLET plugins

gramplet
The function or class that defines the gramplet.
height
The height the gramplet should have in a column on GrampletView,
default = 200
detached_height
The height the gramplet should have detached, default 300
detached_width
The width the gramplet should have detached, default 400
expand
If the attributed should be expanded on start, default False
gramplet_title
Title to use for the gramplet, default = _('Gramplet')
navtypes
Navigation types that the gramplet is appropriate for, default = []
help_url
The URL where documentation for the URL can be found

Attributes for VIEW plugins

viewclass
A class of type ViewCreator that holds the needed info of the
view to be created: icon, viewclass that derives from pageview, ...
stock_icon
The icon in the toolbar or sidebar used to select the view

Attributes for SIDEBAR plugins

sidebarclass
The class that defines the sidebar.
menu_label
A label to use on the seltion menu.

Attributes for VIEW and SIDEBAR plugins

order
order can be START or END. Default is END. For END, on registering,
the plugin is appended to the list of plugins. If START, then the
plugin is prepended. Only set START if you want a plugin to be the
first in the order of plugins

Attributes for DATABASE plugins

databaseclass
The class in the module that is the database class
reset_system
Boolean to indicate that the system (sys.modules) should
be reset.
property authors
property authors_email
property category
property data
property databaseclass
property depends_on
property description
property detached_height
property detached_width
property expand
property export_function
property export_options
property export_options_title
property extension
property fname
property fpath
property gramplet
property gramplet_title
property gramps_target_version
property height
property help_url
property icondir
property icons
property id
property import_function
property include_in_listing
property lang_list
property load_on_reg
property mapservice
property menu_label
property name
property name_accell
property navtypes
property optionclass
property order
property orientation
property paper
property process
property ptype
property relcalcclass
property report_modes
property reportclass
property require_active
property reset_system
property runfunc
property sidebarclass
property status
statustext()[source]
property stock_icon
property style
property supported
property tool_modes
property toolclass
property version
property viewclass
class gramps.gen.plug._pluginreg.PluginRegister[source]

Bases: object

PluginRegister is a Singleton which holds plugin data

add_plugindata(plugindata)[source]

This is used to add an entry to the registration list. The way it is used, this entry is not yet filled in, so we cannot use the id to add to the __id_to_pdata dict at this time.

bookitem_plugins()[source]

Return a list of REPORT PluginData that are can be used as bookitem

database_plugins()[source]

Return a list of PluginData that are of type DATABASE

docgen_plugins()[source]

Return a list of PluginData that are of type DOCGEN

export_plugins()[source]

Return a list of PluginData that are of type EXPORT

filter_load_on_reg()[source]

Return a list of PluginData that have load_on_reg == True

general_plugins(category=None)[source]

Return a list of PluginData that are of type GENERAL

static get_instance()[source]

Use this function to get the instance of the PluginRegister

get_plugin(id)[source]

Return the PluginData for the plugin with id

gramplet_plugins()[source]

Return a list of PluginData that are of type GRAMPLET

import_plugins()[source]

Return a list of PluginData that are of type IMPORT

mapservice_plugins()[source]

Return a list of PluginData that are of type MAPSERVICE

quickreport_plugins()[source]

Return a list of PluginData that are of type QUICKREPORT

relcalc_plugins()[source]

Return a list of PluginData that are of type RELCALC

report_plugins(gui=True)[source]

Return a list of gui or cli PluginData that are of type REPORT

Parameters:

gui – bool, if True then gui plugin, otherwise cli plugin

scan_dir(dir, filenames, uistate=None)[source]

The dir name will be scanned for plugin registration code, which will be loaded in PluginData objects if they satisfy some checks.

Returns:

A list with PluginData objects

sidebar_plugins()[source]

Return a list of PluginData that are of type SIDEBAR

tool_plugins(gui=True)[source]

Return a list of PluginData that are of type TOOL

type_plugins(ptype)[source]

Return a list of PluginData that are of type ptype

view_plugins()[source]

Return a list of PluginData that are of type VIEW

gramps.gen.plug._pluginreg.make_environment(**kwargs)[source]
gramps.gen.plug._pluginreg.myint(s)[source]

Protected version of int()

gramps.gen.plug._pluginreg.newplugin()[source]

Function to create a new plugindata object, add it to list of registered plugins

Returns:

a newly created PluginData which is already part of the register

gramps.gen.plug._pluginreg.register(ptype, **kwargs)[source]

Convenience function to register a new plugin using a dictionary as input. The register functions will call newplugin() function, and use the dictionary kwargs to assign data to the PluginData newplugin() created, as in: plugindata.key = data

Parameters:
  • ptype – the plugin type, one of REPORT, TOOL, …

  • kwargs – dictionary with keys attributes of the plugin, and data the value

Returns:

a newly created PluginData which is already part of the register and which has kwargs assigned as attributes

gramps.gen.plug._pluginreg.valid_plugin_version(plugin_version_string)[source]

Checks to see if string is a valid version string for this version of Gramps.

gramps.gen.plug._pluginreg.version(sversion)[source]

Return the tuple version of a string version.

Utils

General utility functions useful for the generic plugin system

class gramps.gen.plug.utils.OpenFileOrStdin(filename, add_mode='', encoding=None)[source]

Bases: object

Context manager to open a file or stdin for reading.

class gramps.gen.plug.utils.OpenFileOrStdout(filename, encoding=None, errors=None, newline=None)[source]

Bases: object

Context manager to open a file or stdout for writing.

class gramps.gen.plug.utils.Zipfile(buffer)[source]

Bases: object

Class to duplicate the methods of tarfile.TarFile, for Python 2.5.

close()[source]

Close the zip object.

extractall(path, members=None)[source]

Extract all of the files in the zip into path.

extractfile(name)[source]

Extract a name from the zip file.

>>> Zipfile(buffer).extractfile("Dir/dile.py").read()
<Contents>
get_files(items)[source]

Get the files from the items.

get_paths(items)[source]

Get the directories from the items.

getnames()[source]

Get the files and directories of the zipfile.

is_file(name)[source]

Is the name a directory?

is_path(name)[source]

Is the name a path?

gramps.gen.plug.utils.available_updates()[source]
gramps.gen.plug.utils.load_addon_file(path, callback=None)[source]

Load an addon from a particular path (from URL or file system).

class gramps.gen.plug.utils.newplugin[source]

Bases: object

Fake newplugin.

gramps.gen.plug.utils.register(ptype, **kwargs)[source]

Fake registration. Side-effect sets register_results to kwargs.

gramps.gen.plug.utils.urlopen_maybe_no_check_cert(URL)[source]

Similar to urllib.request.urlopen, but disables certificate verification on Mac.

gramps.gen.plug.utils.version_str_to_tup(sversion, positions)[source]

Given a string version and positions count, returns a tuple of integers.

>>> version_str_to_tup("1.02.9", 2)
(1, 2)