The gramps.gen Module

The gen module provides packages that are common to all gramps interfaces (gui, cli and web).

Database State

Errors

Provide Error objects

class gramps.gen.errors.DatabaseError(value='')[source]

Bases: Exception

Error used to report database errors

class gramps.gen.errors.DateError(value='')[source]

Bases: Exception

Error used to report Date errors

Might have a .date attribute holding an invalid Date object that triggered the error.

class gramps.gen.errors.DbError(value)[source]

Bases: Exception

Error used to report BerkeleyDB errors.

TODO

Recent Files

Sort

Update callback

A set of basic utilities that everything in Gramps can depend upon.

The goal is to have this module not depend on any other gramps module. That way, e.g. database classes can safely depend on that without other Gramps baggage.

class gramps.gen.updatecallback.UpdateCallback(callback, interval=1)[source]

Bases: object

Basic class providing way of calling the callback to update things during lengthy operations.

reset(text='')[source]

Reset the count to zero.

set_text(text)[source]

Set the text.

set_total(total)[source]

Set the total.

update_empty(count=None)[source]

Dummy update used when no callback is specified.

update_real(count=None)[source]

Called when the count is updated.

User

The User class provides basic interaction with the user.

class gramps.gen.user.User(callback=None, error=None, uistate=None, dbstate=None)[source]

Bases: UserBase

An implementation of the gen.user.UserBase class which supresses output and accepts prompts. This is useful for unit tests.

begin_progress(title, message, steps)[source]

Start showing a progress indicator to the user.

Don’t use this method directly, use progress instead.

Parameters:
  • title (str) – the title of the progress meter

  • message (str) – the message associated with the progress meter

  • steps (int) – the total number of steps for the progress meter. a value of 0 indicates that the ending is unknown and the meter should just show activity.

Returns:

none

end_progress()[source]

Stop showing the progress indicator to the user.

Don’t use this method directly, use progress instead.

info(msg1, infotext, parent=None, monospaced=False)[source]

Displays information to the user

notify_db_error(error)[source]

Notify the user of a DB error.

Parameters:

error (str) – the error message

Returns:

none

notify_db_repair(error)[source]

Notify the user their DB might need repair.

Parameters:

error (str) – the error message

Returns:

none

notify_error(title, error='')[source]

Notify the user of an error.

Parameters:
  • title (str) – the title of the error

  • error (str) – the error message

Returns:

none

prompt(title, message, accept_label, reject_label, parent=None, default_label=None)[source]

Prompt the user with a message to select an alternative.

Parameters:
  • title (str) – the title of the question, e.g.: “Undo history warning”

  • message – the message, e.g.: “Proceeding with the tool will erase the undo history. If you think you may want to revert running this tool, please stop here and make a backup of the DB.”

  • accept_label (str) – what to call the positive choice, e.g.: “Proceed”

  • reject_label (str) – what to call the negative choice, e.g.: “Stop”

  • default_label (str or None) – the label of the default

Returns:

the user’s answer to the question

Return type:

bool

step_progress()[source]

Advance the progress meter.

Don’t use this method directly, use progress instead.

warn(title, warning='')[source]

Warn the user.

Parameters:
  • title (str) – the title of the warning

  • warning (str) – the warning

Returns:

none