* src/plugins/TestcaseGenerator.py: Small changes to family generation

* src/plugins/StatisticsChart.py: Added statistics for Surnames, Number of Families and Event Types


svn: r4278
This commit is contained in:
Martin Hawlisch 2005-04-01 20:32:06 +00:00
parent c2b556d9f4
commit 4abe4ea4be
3 changed files with 58 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2005-04-01 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/TestcaseGenerator.py: Small changes to family generation
* src/plugins/StatisticsChart.py: Added statistics for Surnames,
Number of Families and Event Types
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDBCallback.py: rewrite of new callback scheme using python signals * src/GrampsDBCallback.py: rewrite of new callback scheme using python signals
* src/GrampsBSDDB.py: handle signals instead of callback functions * src/GrampsBSDDB.py: handle signals instead of callback functions

View File

@ -95,6 +95,8 @@ class Extract:
self.extractors = { self.extractors = {
'data_title': ("Titles", _("Titles"), 'data_title': ("Titles", _("Titles"),
self.get_person, self.get_title), self.get_person, self.get_title),
'data_sname': ("Surnames", _("Surnames"),
self.get_person, self.get_surname),
'data_fname': ("Forenames", _("Forenames"), 'data_fname': ("Forenames", _("Forenames"),
self.get_person, self.get_forename), self.get_person, self.get_forename),
'data_gender': ("Genders", _("Genders"), 'data_gender': ("Genders", _("Genders"),
@ -115,18 +117,22 @@ class Extract:
self.get_death, self.get_place), self.get_death, self.get_place),
'data_mplace': ("Marriage places", _("Marriage places"), 'data_mplace': ("Marriage places", _("Marriage places"),
self.get_marriage_handles, self.get_places), self.get_marriage_handles, self.get_places),
'data_mcount': ("Number of relationships", _("Number of relationships"),
self.get_family_handles, self.get_handle_count),
'data_fchild': ("Ages when first child born", _("Ages when first child born"), 'data_fchild': ("Ages when first child born", _("Ages when first child born"),
self.get_child_handles, self.get_first_child_age), self.get_child_handles, self.get_first_child_age),
'data_lchild': ("Ages when last child born", _("Ages when last child born"), 'data_lchild': ("Ages when last child born", _("Ages when last child born"),
self.get_child_handles, self.get_last_child_age), self.get_child_handles, self.get_last_child_age),
'data_ccount': ("Number of children", _("Number of children"), 'data_ccount': ("Number of children", _("Number of children"),
self.get_child_handles, self.get_child_count), self.get_child_handles, self.get_handle_count),
'data_mage': ("Marriage ages", _("Marriage ages"), 'data_mage': ("Marriage ages", _("Marriage ages"),
self.get_marriage_handles, self.get_event_ages), self.get_marriage_handles, self.get_event_ages),
'data_dage': ("Ages at death", _("Ages at death"), 'data_dage': ("Ages at death", _("Ages at death"),
self.get_person, self.get_death_age), self.get_person, self.get_death_age),
'data_age': ("Ages", _("Ages"), 'data_age': ("Ages", _("Ages"),
self.get_person, self.get_person_age) self.get_person, self.get_person_age),
'data_etypes': ("Event types", _("Event types"),
self.get_event_handles, self.get_event_type)
} }
# ----------------- data extraction methods -------------------- # ----------------- data extraction methods --------------------
@ -150,6 +156,15 @@ class Extract:
else: else:
return [_("(Preferred) forename missing")] return [_("(Preferred) forename missing")]
def get_surname(self, person):
"return surnames for given person"
# TODO: return all surnames, not just primary ones...
surnames = person.get_primary_name().get_surname().strip()
if surnames:
return [name.capitalize() for name in surnames.split()]
else:
return [_("(Preferred) surname missing")]
def get_gender(self, person): def get_gender(self, person):
"return gender for given person" "return gender for given person"
# TODO: why there's no Person.getGenderName? # TODO: why there's no Person.getGenderName?
@ -233,6 +248,17 @@ class Extract:
return ages return ages
return [_("Events missing")] return [_("Events missing")]
def get_event_type(self, data):
"return event types at given (person,event_handles)"
types = []
person, event_handles = data
for event_handle in event_handles:
event = self.db.get_event_from_handle(event_handle)
types.append(event.get_name())
if types:
return types
return [_("Events missing")]
def get_first_child_age(self, data): def get_first_child_age(self, data):
"return age when first child in given (person,child_handles) was born" "return age when first child in given (person,child_handles) was born"
ages, errors = self.get_sorted_child_ages(data) ages, errors = self.get_sorted_child_ages(data)
@ -249,8 +275,8 @@ class Extract:
return errors return errors
return [_("Children missing")] return [_("Children missing")]
def get_child_count(self, data): def get_handle_count(self, data):
"return number of children in given (person,child_handles)" "return number of handles in given (person,handle_list) used for child count, family count"
return [str(len(data[1]))] return [str(len(data[1]))]
# ------------------- utility methods ------------------------- # ------------------- utility methods -------------------------
@ -336,6 +362,22 @@ class Extract:
return (person, marriages) return (person, marriages)
return None return None
def get_family_handles(self, person):
"return list of family handles for given person or None"
families = person.get_family_handle_list()
if families:
return (person, families)
return None
def get_event_handles(self, person):
"return list of event handles for given person or None"
events = person.get_event_list()
if events:
return (person, events)
return None
# ----------------- data collection methods -------------------- # ----------------- data collection methods --------------------
def get_person_data(self, person, collect): def get_person_data(self, person, collect):

View File

@ -133,6 +133,10 @@ class TestcaseGenerator:
self.persons_todo.append( self.generate_person(0)) self.persons_todo.append( self.generate_person(0))
for person_h in self.persons_todo: for person_h in self.persons_todo:
self.generate_family(person_h) self.generate_family(person_h)
if randint(0,3) == 0:
self.generate_family(person_h)
if randint(0,7) == 0:
self.generate_family(person_h)
if self.person_count > self.max_person_count: if self.person_count > self.max_person_count:
break break
for child_h in self.parents_todo: for child_h in self.parents_todo:
@ -438,6 +442,7 @@ class TestcaseGenerator:
self.db.commit_person(child,self.trans) self.db.commit_person(child,self.trans)
if randint(0,3) > 0: if randint(0,3) > 0:
self.persons_todo.append(child_h) self.persons_todo.append(child_h)
def generate_parents(self,child_h): def generate_parents(self,child_h):
child = self.db.get_person_from_handle(child_h) child = self.db.get_person_from_handle(child_h)
if child.get_parent_family_handle_list(): if child.get_parent_family_handle_list():
@ -448,9 +453,9 @@ class TestcaseGenerator:
person1_h = self.generate_person(1,lastname) person1_h = self.generate_person(1,lastname)
person2_h = self.generate_person(0) person2_h = self.generate_person(0)
if randint(0,2) > 0: if randint(0,2) > 1:
self.parents_todo.append(person1_h) self.parents_todo.append(person1_h)
if randint(0,2) > 0: if randint(0,2) > 1:
self.parents_todo.append(person2_h) self.parents_todo.append(person2_h)