The gramps.gen Module¶
The gen module provides packages that are common to all gramps interfaces (gui, cli and web).
Database State¶
Provide the database state class
- class gramps.gen.dbstate.DbState[source]¶
Bases:
CallbackProvide a class to encapsulate the state of the database.
- apply_proxy(proxy, *args, **kwargs)[source]¶
Add a proxy to the current database. Use pop_proxy() to revert to previous db.
>>> dbstate.apply_proxy(gramps.gen.proxy.LivingProxyDb, 0) >>> dbstate.apply_proxy(gramps.gen.proxy.PrivateProxyDb)
>>> from gramps.gen.filters.rules.person import (IsDescendantOf, IsAncestorOf) >>> from gramps.gen.filters import GenericFilter >>> filter = GenericFilter() >>> filter.set_logical_op("or") >>> filter.add_rule(IsDescendantOf([db.get_default_person().gramps_id, True])) >>> filter.add_rule(IsAncestorOf([db.get_default_person().gramps_id, True])) >>> dbstate.apply_proxy(gramps.gen.proxy.FilterProxyDb, filter)
- change_database(database)[source]¶
Closes the existing db, and opens a new one. Retained for backward compatibility.
- change_database_noclose(database)[source]¶
Change the current database. and resets the configuration prefixes.
- is_open()[source]¶
Returns True if DbState.db refers to a database object instance, AND the database is open.
This tests both for the existence of the database and its being open, so that for the time being, the use of the dummy database on closure can continue, but at some future time, this could be altered to just set the database to none.
This replaces tests on DbState.open, DbState.db, DbState.db.is_open() and DbState.db.db_is_open all of which are deprecated.
Errors¶
Provide Error objects
- class gramps.gen.errors.DatabaseError(value='')[source]¶
Bases:
ExceptionError used to report database errors
- class gramps.gen.errors.DateError(value='')[source]¶
Bases:
ExceptionError 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:
ExceptionError used to report BerkeleyDB errors.
TODO
Recent Files¶
- class gramps.gen.recentfiles.RecentFiles[source]¶
Bases:
objectInterface to a RecentFiles collection
- class gramps.gen.recentfiles.RecentItem(p='', n='', t=0)[source]¶
Bases:
objectInterface to a single Gramps recent-items item
Sort¶
Provide sorting routines for use in Gramps. Since these functions are intended to provide fast sorting, they tend to bypass access methods, and directly use class members. For this reason, care needs to be taken to make sure these remain in sync with the rest of the design.
- class gramps.gen.sort.Sort(database)[source]¶
Bases:
object- by_birthdate_key(first_id)[source]¶
Sort routine for comparing two people by birth dates. If the birth dates are equal, sorts by name
- by_event_description_key(a_id)[source]¶
Sort routine for comparing two events by their descriptions.
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.
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:
UserBaseAn implementation of the
gen.user.UserBaseclass 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.
- 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