surname guessing

svn: r6236
This commit is contained in:
Don Allingham 2006-03-30 22:15:03 +00:00
parent f13f54c107
commit 41d125fc53
3 changed files with 44 additions and 2 deletions

View File

@ -1,4 +1,5 @@
2006-03-30 Don Allingham <don@gramps-project.org> 2006-03-30 Don Allingham <don@gramps-project.org>
* src/Editors/_EditFamily.py: add surname guessing back in
* src/Mime/_GnomeMime.py: filter out bad KDE mime type commands * src/Mime/_GnomeMime.py: filter out bad KDE mime type commands
* src/Utils.py: clean up launch routine * src/Utils.py: clean up launch routine
* src/Editors/_EditPerson.py: setup autocomp list * src/Editors/_EditPerson.py: setup autocomp list

View File

@ -191,6 +191,16 @@ class ChildEmbedList(EmbeddedList):
from Editors import EditPerson from Editors import EditPerson
person = RelLib.Person() person = RelLib.Person()
autoname = Config.get_lastnamegen()
if autoname == 0:
name = self.north_american()
elif autoname == 2:
name = self.latin_american()
else:
name = self.no_name()
person.get_primary_name().set_surname(name[1])
person.get_primary_name().set_surname_prefix(name[0])
EditPerson(self.dbstate,self.uistate,[],person, self.new_child_added) EditPerson(self.dbstate,self.uistate,[],person, self.new_child_added)
def new_child_added(self, person): def new_child_added(self, person):
@ -270,6 +280,36 @@ class ChildEmbedList(EmbeddedList):
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
def north_american(self):
father_handle = self.family.get_father_handle()
if father_handle:
father = self.dbstate.db.get_person_from_handle(father_handle)
pname = father.get_primary_name()
return (pname.get_surname_prefix(),pname.get_surname())
return ("","")
def no_name(self):
return ("","")
def latin_american(self):
if self.family:
father_handle = self.family.get_father_handle()
mother_handle = self.family.get_mother_handle()
if not father_handle or not mother_handle:
return ("","")
father = self.db.db.get_person_from_handle(father_handle)
mother = self.db.db.get_person_from_handle(mother_handle)
fsn = father.get_primary_name().get_surname()
msn = mother.get_primary_name().get_surname()
if not father or not mother:
return ("","")
try:
return ("","%s %s" % (fsn.split()[0],msn.split()[0]))
except:
return ("","")
else:
return ("","")
class FastMaleFilter: class FastMaleFilter:
def __init__(self,db): def __init__(self,db):
@ -782,3 +822,4 @@ class EditFamily(EditPrimary):
self.db.commit_family(self.obj,trans) self.db.commit_family(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Family")) self.db.transaction_commit(trans,_("Edit Family"))
self.close_window() self.close_window()

View File

@ -476,8 +476,8 @@ class EditPerson(EditPrimary):
self.pname, self.update_name) self.pname, self.update_name)
def update_name(self,name): def update_name(self,name):
for obj in (self.suffix, self.prefix, self.given, self.title, self.ntype_field, for obj in (self.suffix, self.prefix, self.given, self.title,
self.surname_field): self.ntype_field, self.surname_field):
obj.update() obj.update()
def load_person_image(self): def load_person_image(self):