64
edits
Changes
From Gramps
m
→Defining the Report class: Fixed code description
===Defining the Report class===
The actual implemention implementation of the <ttcode>DbSummaryDbSummaryReport</ttcode> report is rather simple. No additional work needs to be done to initialize the class, so the parent <ttcode>__init__</ttcode> routine is called.
All the work is done in the <ttcode>write_report()</ttcode> functionmethod. This function It uses a [https://www.gramps-project.org/docs/gen/gen_db.html#gramps.gen.db.generic.DbGeneric.iter_people <ttcode>GrampsCursorself.database.iter_people()</ttcode> ] to iterate through the map of [https://www.gramps-project.org/docs/gen/gen_lib.html#module-gramps.gen.lib.person <ttcode>Person</ttcode> ] objects and gathers some simple statistics.
The only thing of any complication is the determination of the most common surname. A python dictionary is used to store the number of times each surname is used. Each time a surname is encountered, the value in the dictionary is incremented. The results are then loaded into a list and sorted, allowing us to find the most common name by looking at the last entry in the list.