Code cleanup

svn: r609
This commit is contained in:
Don Allingham 2001-12-09 05:24:29 +00:00
parent c78037f9f9
commit 7701714b77
21 changed files with 430 additions and 518 deletions

View File

@ -1,4 +1,3 @@
#! /usr/bin/python -O
#
# Gramps - a GTK+/GNOME based genealogy program
#
@ -52,18 +51,29 @@ import libglade
import const
import utils
import RelImage
from RelLib import Photo
import RelLib
class AddMediaObject:
"""
Displays the Add Media Dialog window, allowing the user to select
a media object from the file system, while providing a description.
"""
def __init__(self,db,update):
"""
Creates and displays the dialog box
db - the database in which the new object is to be stored
update - a function to call to update the display
"""
self.db = db
self.glade = libglade.GladeXML(const.imageselFile,"imageSelect")
self.window = self.glade.get_widget("imageSelect")
self.glade = libglade.GladeXML(const.imageselFile,"imageSelect")
self.window = self.glade.get_widget("imageSelect")
self.description = self.glade.get_widget("photoDescription")
self.image = self.glade.get_widget("image")
self.update = update
self.temp_name = ""
self.image = self.glade.get_widget("image")
self.file_text = self.glade.get_widget("fname")
self.update = update
self.temp_name = ""
self.glade.signal_autoconnect({
"on_savephoto_clicked" : self.on_savephoto_clicked,
@ -75,19 +85,24 @@ class AddMediaObject:
self.window.show()
def on_savephoto_clicked(self,obj):
"""
Callback function called with the save button is pressed.
A new media object is created, and added to the database.
"""
filename = self.glade.get_widget("photosel").get_full_path(0)
description = self.description.get_text()
external = self.glade.get_widget("private")
if os.path.exists(filename) == 0:
err = _("%s is not a valid file name or does not exist.") % filename
GnomeErrorDialog(err)
msgstr = _("%s is not a valid file name or does not exist.")
GnomeErrorDialog(msgstr % filename)
return
type = utils.get_mime_type(filename)
mobj = Photo()
if description == "":
description = os.path.basename(filename)
mobj = RelLib.Photo()
mobj.setDescription(description)
mobj.setMimeType(type)
self.db.addObject(mobj)
@ -104,19 +119,24 @@ class AddMediaObject:
utils.destroy_passed_object(obj)
def on_name_changed(self,obj):
filename = self.glade.get_widget("fname").get_text()
"""
Called anytime the filename text window changes. Checks to
see if the file exists. If it does, the imgae is loaded into
the preview window.
"""
filename = self.file_text.get_text()
basename = os.path.basename(filename)
(root,ext) = os.path.splitext(basename)
old_title = self.description.get_text()
if old_title == "" or old_title == self.temp_name:
if old_title == '' or old_title == self.temp_name:
self.description.set_text(root)
self.temp_name = root
if os.path.isfile(filename):
type = utils.get_mime_type(filename)
if type[0:5] == "image":
if type[0:5] == 'image':
image = RelImage.scale_image(filename,const.thumbScale)
self.image.load_imlib(image)
else:

View File

@ -45,14 +45,26 @@ import libglade
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
import RelLib
import const
import sort
import utils
class AddSpouse:
"""
Displays the AddSpouse dialog, allowing the user to create a new
family with the passed person as one spouse, and another person to
be selected.
"""
def __init__(self,db,person,update,addperson):
"""
Displays the AddSpouse dialog box.
db - database to which to add the new family
person - the current person, will be one of the parents
update - function that updates the family display
addperson - function that adds a person to the person view
"""
self.db = db
self.update = update
self.person = person
@ -61,9 +73,9 @@ class AddSpouse:
self.glade = libglade.GladeXML(const.gladeFile, "spouseDialog")
self.rel_combo = self.glade.get_widget("rel_combo")
self.rel_type = self.glade.get_widget("rel_type")
self.relation_type = self.glade.get_widget("rel_type")
self.spouse_list = self.glade.get_widget("spouseList")
self.rel_def = self.glade.get_widget("reldef")
self.relation_def = self.glade.get_widget("reldef")
self.top = self.glade.get_widget("spouseDialog")
self.given = self.glade.get_widget("given")
self.surname = self.glade.get_widget("surname")
@ -76,97 +88,111 @@ class AddSpouse:
self.top.editable_enters(self.given)
self.top.editable_enters(self.surname)
self.name_list = self.db.getPersonMap().values()
self.name_list.sort(sort.by_last_name)
self.glade.signal_autoconnect({
"on_select_spouse_clicked" : self.on_select_spouse_clicked,
"on_new_spouse_clicked" : self.on_new_spouse_clicked,
"on_rel_type_changed" : self.on_rel_type_changed,
"on_select_spouse_clicked" : self.select_spouse_clicked,
"on_new_spouse_clicked" : self.new_spouse_clicked,
"on_rel_type_changed" : self.relation_type_changed,
"on_combo_insert_text" : utils.combo_insert_text,
"destroy_passed_object" : utils.destroy_passed_object
})
self.rel_type.set_text(_("Married"))
self.relation_type.set_text(_("Married"))
def on_new_spouse_clicked(self,obj):
select_spouse = Person()
self.db.addPerson(select_spouse)
name = Name()
select_spouse.setPrimaryName(name)
def new_spouse_clicked(self,obj):
"""
Called when the spouse to be added does not exist, and needs
to be created and added to the database
"""
spouse = RelLib.Person()
self.db.addPerson(spouse)
name = spouse.getPrimaryName()
name.setSurname(string.strip(self.surname.get_text()))
name.setFirstName(string.strip(self.given.get_text()))
reltype = const.save_frel(self.rel_type.get_text())
if reltype == "Partners":
select_spouse.setGender(self.person.getGender())
relation = const.save_frel(self.relation_type.get_text())
if relation == "Partners":
spouse.setGender(self.person.getGender())
elif self.person.getGender() == RelLib.Person.male:
spouse.setGender(RelLib.Person.female)
else:
if self.person.getGender() == Person.male:
select_spouse.setGender(Person.female)
else:
select_spouse.setGender(Person.male)
utils.modified()
spouse.setGender(RelLib.Person.male)
family = self.db.newFamily()
family.setRelationship(relation)
self.person.addFamily(family)
select_spouse.addFamily(family)
spouse.addFamily(family)
if self.person.getGender() == Person.male:
family.setMother(select_spouse)
family.setMother(spouse)
family.setFather(self.person)
else:
family.setFather(select_spouse)
family.setFather(spouse)
family.setMother(self.person)
family.setRelationship(reltype)
utils.destroy_passed_object(obj)
self.addperson(select_spouse)
utils.modified()
self.addperson(spouse)
self.update(family)
def on_select_spouse_clicked(self,obj):
def select_spouse_clicked(self,obj):
"""
Called when the spouse to be added already exists and has been
selected from the list.
"""
if len(self.spouse_list.selection) == 0:
return
row = self.spouse_list.selection[0]
select_spouse = self.spouse_list.get_row_data(row)
spouse = self.spouse_list.get_row_data(row)
# don't do anything if the marriage already exists
for f in self.person.getFamilyList():
if select_spouse == f.getMother() or select_spouse == f.getFather():
if spouse == f.getMother() or spouse == f.getFather():
utils.destroy_passed_object(obj)
return
utils.modified()
family = self.db.newFamily()
self.person.addFamily(family)
select_spouse.addFamily(family)
spouse.addFamily(family)
if self.person.getGender() == Person.male:
family.setMother(select_spouse)
if self.person.getGender() == RelLib.Person.male:
family.setMother(spouse)
family.setFather(self.person)
else:
family.setFather(select_spouse)
family.setFather(spouse)
family.setMother(self.person)
family.setRelationship(const.save_frel(self.rel_type.get_text()))
family.setRelationship(const.save_frel(self.relation_type.get_text()))
utils.destroy_passed_object(obj)
self.update(family)
def on_rel_type_changed(self,obj):
nameList = self.db.getPersonMap().values()
nameList.sort(sort.by_last_name)
self.spouse_list.clear()
self.spouse_list.freeze()
def relation_type_changed(self,obj):
"""
Called whenever the relationship type changes. Rebuilds the
the potential spouse list.
"""
text = obj.get_text()
self.rel_def.set_text(const.relationship_def(text))
self.relation_def.set_text(const.relationship_def(text))
# determine the gender of the people to be loaded into
# the potential spouse list. If Partners is selected, use
# the same gender as the current person.
gender = self.person.getGender()
if text == _("Partners"):
if gender == Person.male:
gender = Person.female
if gender == RelLib.Person.male:
gender = RelLib.Person.female
else:
gender = Person.male
gender = RelLib.Person.male
index = 0
for person in nameList:
self.spouse_list.clear()
self.spouse_list.freeze()
for person in self.name_list:
if person.getGender() == gender:
continue
name = person.getPrimaryName().getName()

View File

@ -32,7 +32,7 @@ import libglade
#-------------------------------------------------------------------------
import const
import utils
from RelLib import *
import Date
from intl import gettext
_ = gettext
@ -43,13 +43,20 @@ _ = gettext
#
#-------------------------------------------------------------------------
class AddressEditor:
"""
Displays a dialog that allows the user to edit a address.
"""
def __init__(self,parent,addr):
self.parent = parent
self.addr = addr
"""
Displays the dialog box.
parent - The class that called the Address editor.
addr - The address that is to be edited
"""
# Get the important widgets from the glade description
self.top = libglade.GladeXML(const.editPersonFile, "addr_edit")
self.window = self.top.get_widget("addr_edit")
self.addr_start = self.top.get_widget("address_start")
self.addr_start = self.top.get_widget("address_start")
self.street = self.top.get_widget("street")
self.city = self.top.get_widget("city")
self.state = self.top.get_widget("state")
@ -58,10 +65,8 @@ class AddressEditor:
self.note_field = self.top.get_widget("addr_note")
self.priv = self.top.get_widget("priv")
if self.addr:
self.srcreflist = self.addr.getSourceRefList()
else:
self.srcreflist = []
self.parent = parent
self.addr = addr
name = parent.person.getPrimaryName().getName()
text = _("Address Editor for %s") % name
@ -76,30 +81,37 @@ class AddressEditor:
self.window.editable_enters(self.postal);
self.window.editable_enters(self.note_field);
if self.addr != None:
if self.addr:
self.srcreflist = self.addr.getSourceRefList()
self.addr_start.set_text(self.addr.getDate())
self.street.set_text(self.addr.getStreet())
self.city.set_text(self.addr.getCity())
self.state.set_text(self.addr.getState())
self.country.set_text(self.addr.getCountry())
self.postal.set_text(self.addr.getPostal())
self.priv.set_active(self.addr.getPrivacy())
self.note_field.set_point(0)
self.note_field.insert_defaults(self.addr.getNote())
self.note_field.set_word_wrap(1)
else:
self.srcreflist = []
self.top.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object,
"on_addr_edit_ok_clicked" : self.on_addr_edit_ok_clicked,
"on_source_clicked" : self.on_addr_source_clicked
"on_addr_edit_ok_clicked" : self.ok_clicked,
"on_source_clicked" : self.source_clicked
})
def on_addr_source_clicked(self,obj):
def source_clicked(self,obj):
"""Displays the SourceSelector, allowing sources to be edited"""
import Sources
Sources.SourceSelector(self.srcreflist,self.parent,src_changed)
def on_addr_edit_ok_clicked(self,obj):
def ok_clicked(self,obj):
"""
Called when the OK button is pressed. Gets data from the
form and updates the Address data structure
"""
date = self.addr_start.get_text()
street = self.street.get_text()
city = self.city.get_text()
@ -114,45 +126,55 @@ class AddressEditor:
self.addr.setSourceRefList(self.srcreflist)
self.parent.plist.append(self.addr)
self.update_address(date,street,city,state,country,postal,note,priv)
self.update(date,street,city,state,country,postal,note,priv)
self.parent.redraw_addr_list()
utils.destroy_passed_object(obj)
def update_address(self,date,street,city,state,country,postal,note,priv):
d = Date()
def check(self,get,set,data):
"""Compares a data item, updates if necessary, and sets the
parents lists_changed flag"""
if get() != data:
set(data)
self.parent.lists_changed = 1
def update(self,date,street,city,state,country,postal,note,priv):
"""Compares the data items, and updates if necessary"""
d = Date.Date()
d.set(date)
if self.addr.getDate() != d.getDate():
self.addr.setDate(date)
self.parent.lists_changed = 1
if self.addr.getState() != state:
self.addr.setState(state)
self.parent.lists_changed = 1
self.check(self.addr.getDate,self.addr.setDate,state)
self.check(self.addr.getStreet,self.addr.setStreet,street)
self.check(self.addr.getCountry,self.addr.setCountry,country)
self.check(self.addr.getCity,self.addr.setCity,city)
self.check(self.addr.getPostal,self.addr.setPostal,postal)
self.check(self.addr.getNote,self.addr.setNote,note)
self.check(self.addr.getPrivacy,self.addr.setPrivacy,priv)
if self.addr.getStreet() != street:
self.addr.setStreet(street)
self.parent.lists_changed = 1
if self.addr.getCountry() != country:
self.addr.setCountry(country)
self.parent.lists_changed = 1
if self.addr.getCity() != city:
self.addr.setCity(city)
self.parent.lists_changed = 1
if self.addr.getPostal() != postal:
self.addr.setPostal(postal)
self.parent.lists_changed = 1
if self.addr.getNote() != note:
self.addr.setNote(note)
self.parent.lists_changed = 1
if self.addr.getPrivacy() != priv:
self.addr.setPrivacy(priv)
self.parent.lists_changed = 1
# if self.addr.getState() != state:
# self.addr.setState(state)
# self.parent.lists_changed = 1
# if self.addr.getStreet() != street:
# self.addr.setStreet(street)
# self.parent.lists_changed = 1
# if self.addr.getCountry() != country:
# self.addr.setCountry(country)
# self.parent.lists_changed = 1
# if self.addr.getCity() != city:
# self.addr.setCity(city)
# self.parent.lists_changed = 1
# if self.addr.getPostal() != postal:
# self.addr.setPostal(postal)
# self.parent.lists_changed = 1
# if self.addr.getNote() != note:
# self.addr.setNote(note)
# self.parent.lists_changed = 1
# if self.addr.getPrivacy() != priv:
# self.addr.setPrivacy(priv)
# self.parent.lists_changed = 1
def src_changed(parent):
parent.lists_changed = 1

View File

@ -53,28 +53,21 @@ _NAMEINST = "namelist"
class Bookmarks :
"Handle the bookmarks interface for Gramps"
#---------------------------------------------------------------------
#
# __init__ - Creates a the bookmark editor
#
# arguments are:
# bookmarks - list of People
# menu - parent menu to attach users
# callback - task to connect to the menu item as a callback
#
#---------------------------------------------------------------------
def __init__(self,bookmarks,menu,callback):
"""
Creates a the bookmark editor
bookmarks - list of People
menu - parent menu to attach users
callback - task to connect to the menu item as a callback
"""
self.menu = menu
self.bookmarks = bookmarks
self.callback = callback
self.redraw()
#---------------------------------------------------------------------
#
# redraw - (re)create the pulldown menu
#
#---------------------------------------------------------------------
def redraw(self):
"""Create the pulldown menu"""
if len(self.bookmarks) > 0:
self.myMenu = gtk.GtkMenu()
for person in self.bookmarks:
@ -85,39 +78,30 @@ class Bookmarks :
self.menu.remove_submenu()
self.menu.set_sensitive(0)
#---------------------------------------------------------------------
#
# add - adds the person to the bookmarks, appended to the botom
#
#---------------------------------------------------------------------
def add(self,person):
"""appends the person to the bottom of the bookmarks"""
if person not in self.bookmarks:
utils.modified()
self.bookmarks.append(person)
self.redraw()
#---------------------------------------------------------------------
#
# add_to_menu - adds a person's name to the drop down menu
#
#---------------------------------------------------------------------
def add_to_menu(self,person):
"""adds a person's name to the drop down menu"""
item = gtk.GtkMenuItem(person.getPrimaryName().getName())
item.connect("activate", self.callback, person)
item.show()
self.myMenu.append(item)
#---------------------------------------------------------------------
#
# edit - display the bookmark editor.
#
# The current bookmarked people are inserted into the namelist,
# attaching the person object to the corresponding row. The currently
# selected row is attached to the name list. This is either 0 if the
# list is not empty, or -1 if it is.
#
#---------------------------------------------------------------------
def edit(self):
"""
display the bookmark editor.
The current bookmarked people are inserted into the namelist,
attaching the person object to the corresponding row. The currently
selected row is attached to the name list. This is either 0 if the
list is not empty, or -1 if it is.
"""
top = libglade.GladeXML(const.bookFile,_TOPINST)
self.namelist = top.get_widget(_NAMEINST)
index = 0
@ -127,41 +111,43 @@ class Bookmarks :
index = index + 1
top.signal_autoconnect({
"on_ok_clicked" : self.on_ok_clicked,
"on_down_clicked" : self.on_down_clicked,
"on_up_clicked" : self.on_up_clicked,
"on_delete_clicked" : self.on_delete_clicked,
"on_cancel_clicked" : self.on_cancel_clicked
"on_ok_clicked" : self.ok_clicked,
"on_down_clicked" : self.down_clicked,
"on_up_clicked" : self.up_clicked,
"on_delete_clicked" : self.delete_clicked,
"on_cancel_clicked" : self.cancel_clicked
})
def on_delete_clicked(self,obj):
def delete_clicked(self,obj):
"""Removes the current selection from the list"""
if len(obj.selection) > 0:
index = obj.selection[0]
obj.remove(index)
obj.remove(obj.selection[0])
def on_up_clicked(self,obj):
def up_clicked(self,obj):
"""Moves the current selection up one row"""
if len(obj.selection) > 0:
index = obj.selection[0]
obj.swap_rows(index-1,index)
def on_down_clicked(self,obj):
def down_clicked(self,obj):
"""Moves the current selection down one row"""
if len(obj.selection) > 0:
index = obj.selection[0]
if index != obj.rows-1:
obj.swap_rows(index+1,index)
def on_ok_clicked(self,obj):
def ok_clicked(self,obj):
"""Saves the current bookmarks from the list"""
del self.bookmarks[0:]
for index in range(0,self.namelist.rows):
person = self.namelist.get_row_data(index)
if person:
self.bookmarks.append(person)
self.redraw()
obj.destroy()
def on_cancel_clicked(self,obj):
def cancel_clicked(self,obj):
"""Closes the current window"""
obj.destroy()

View File

@ -18,13 +18,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------
#
# The original algorithms for this module came from Scott E. Lee's
# C implementation. The original C source can be found at Scott's
# web site at http://www.scottlee.com
#
#-------------------------------------------------------------------
_FR_SDN_OFFSET = 2375474
_FR_DAYS_PER_4_YEARS = 1461
@ -59,8 +59,14 @@ _NOON = (18 * _HALAKIM_PER_HOUR)
_AM3_11_20 = ((9 * _HALAKIM_PER_HOUR) + 204)
_AM9_32_43 = ((15 * _HALAKIM_PER_HOUR) + 589)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
monthsPerYear = [
12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13
12, 12, 13, 12, 12, 13, 12, 13, 12,
12, 13, 12, 12, 13, 12, 12, 13, 12, 13
]
yearOffset = [
@ -68,21 +74,27 @@ yearOffset = [
136, 148, 160, 173, 185, 197, 210, 222
]
def french_to_sdn(year,month,day):
if (year < 1 or year > 14 or month < 1 or month > 13 or day < 1 or day > 30):
return 0
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
return (year*_FR_DAYS_PER_4_YEARS)/4 + (month-1)*_FR_DAYS_PER_MONTH + day +_FR_SDN_OFFSET
def french_to_sdn(y,m,d):
"""Converts a French Republican Calendar date to an SDN number"""
if (y < 1 or y > 14 or m < 1 or m > 13 or d < 1 or d > 30):
return 0
return (y*_FR_DAYS_PER_4_YEARS)/4+(m-1)*_FR_DAYS_PER_MONTH+d+_FR_SDN_OFFSET
def sdn_to_french(sdn):
"""Converts an SDN number to a French Republican Calendar date"""
if (sdn < _FR_FIRST_VALID or sdn > _FR_LAST_VALID) :
return (0,0,0)
temp = (sdn - _FR_SDN_OFFSET) * 4 - 1
year = temp / _FR_DAYS_PER_4_YEARS
dayOfYear = (temp % _FR_DAYS_PER_4_YEARS) / 4
month = dayOfYear / _FR_DAYS_PER_MONTH + 1
day = dayOfYear % _FR_DAYS_PER_MONTH + 1
temp = (sdn-_FR_SDN_OFFSET)*4 - 1
year = temp/_FR_DAYS_PER_4_YEARS
dayOfYear = (temp%_FR_DAYS_PER_4_YEARS)/4
month = (dayOfYear/_FR_DAYS_PER_MONTH)+1
day = (dayOfYear%_FR_DAYS_PER_MONTH)+1
return (year,month,day)

View File

@ -38,15 +38,17 @@ import libglade
# gramps modules
#
#-------------------------------------------------------------------------
from RelLib import *
import RelLib
import const
import sort
import utils
import Config
class ChooseParents:
"""
Displays the Choose Parents dialog box, allowing the parents
to be edited.
"""
def __init__(self,db,person,family,family_update,full_update):
self.db = db
self.person = person
@ -62,42 +64,40 @@ class ChooseParents:
self.father = None
self.glade = libglade.GladeXML(const.gladeFile,"familyDialog")
self.top = self.glade.get_widget("familyDialog")
self.mrel = self.glade.get_widget("mrel")
self.frel = self.glade.get_widget("frel")
self.mother_rel = self.glade.get_widget("mrel")
self.father_rel = self.glade.get_widget("frel")
self.fcombo = self.glade.get_widget("prel_combo")
self.prel = self.glade.get_widget("prel")
self.title = self.glade.get_widget("chooseTitle")
self.fatherName = self.glade.get_widget("fatherName")
self.motherName = self.glade.get_widget("motherName")
self.father_name = self.glade.get_widget("fatherName")
self.mother_name = self.glade.get_widget("motherName")
self.father_list = self.glade.get_widget("fatherList")
self.mother_list = self.glade.get_widget("motherList")
self.flabel = self.glade.get_widget("flabel")
self.mlabel = self.glade.get_widget("mlabel")
self.fcombo.set_popdown_strings(const.familyRelations)
if self.family and self.family == self.person.getMainFamily():
self.mrel.set_text(_("Birth"))
self.frel.set_text(_("Birth"))
self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth"))
else:
for (f,mr,fr) in self.person.getAltFamilyList():
if f == self.family:
self.mrel.set_text(_(mr))
self.frel.set_text(_(fr))
self.mother_rel.set_text(_(mr))
self.father_rel.set_text(_(fr))
break
else:
self.mrel.set_text(_("Birth"))
self.frel.set_text(_("Birth"))
self.mother_rel.set_text(_("Birth"))
self.father_rel.set_text(_("Birth"))
self.glade.signal_autoconnect({
"on_motherList_select_row" : self.on_mother_list_select_row,
"on_fatherList_select_row" : self.on_father_list_select_row,
"on_save_parents_clicked" : self.on_save_parents_clicked,
"on_addmother_clicked" : self.on_addmother_clicked,
"on_addfather_clicked" : self.on_addfather_clicked,
"on_prel_changed" : self.on_prel_changed,
"on_motherList_select_row" : self.mother_list_select_row,
"on_fatherList_select_row" : self.father_list_select_row,
"on_save_parents_clicked" : self.save_parents_clicked,
"on_addmother_clicked" : self.add_mother_clicked,
"on_addfather_clicked" : self.add_father_clicked,
"on_prel_changed" : self.parent_relation_changed,
"on_combo_insert_text" : utils.combo_insert_text,
"destroy_passed_object" : utils.destroy_passed_object
})
@ -107,15 +107,15 @@ class ChooseParents:
if self.family:
self.prel.set_text(_(self.family.getRelationship()))
else:
self.on_prel_changed(self.prel)
self.parent_relation_changed(self.prel)
self.top.show()
def on_prel_changed(self,obj):
def parent_relation_changed(self,obj):
type = obj.get_text()
self.fatherName.set_text(Config.nameof(self.father))
self.motherName.set_text(Config.nameof(self.mother))
self.father_name.set_text(Config.nameof(self.father))
self.mother_name.set_text(Config.nameof(self.mother))
self.father_list.freeze()
self.mother_list.freeze()
@ -133,18 +133,19 @@ class ChooseParents:
father_index = 1
mother_index = 1
for person in people:
if person == self.person or person.getGender() == Person.unknown:
if person == self.person:
continue
if person.getGender() == RelLib.Person.unknown:
continue
rdata = [utils.phonebook_name(person),utils.birthday(person)]
if type == "Partners":
self.father_list.append(rdata)
self.father_list.set_row_data(father_index,person)
father_index = father_index + 1
self.mother_list.append(rdata)
self.mother_list.set_row_data(mother_index,person)
mother_index = mother_index + 1
elif person.getGender() == Person.male:
elif person.getGender() == RelLib.Person.male:
self.father_list.append(rdata)
self.father_list.set_row_data(father_index,person)
father_index = father_index + 1
@ -164,7 +165,10 @@ class ChooseParents:
self.father_list.thaw()
def find_family(self,father,mother):
"""
Finds the family associated with the father and mother.
If one does not exist, it is created.
"""
if not father and not mother:
return None
@ -184,37 +188,36 @@ class ChooseParents:
father.addFamily(family)
if mother:
mother.addFamily(family)
return family
def on_mother_list_select_row(self,obj,a,b,c):
def mother_list_select_row(self,obj,a,b,c):
self.mother = obj.get_row_data(a)
self.motherName.set_text(Config.nameof(self.mother))
self.mother_name.set_text(Config.nameof(self.mother))
def on_father_list_select_row(self,obj,a,b,c):
def father_list_select_row(self,obj,a,b,c):
self.father = obj.get_row_data(a)
self.fatherName.set_text(Config.nameof(self.father))
self.father_name.set_text(Config.nameof(self.father))
def on_save_parents_clicked(self,obj):
mrel = const.childRelations[self.mrel.get_text()]
frel = const.childRelations[self.frel.get_text()]
def save_parents_clicked(self,obj):
mother_rel = const.childRelations[self.mother_rel.get_text()]
father_rel = const.childRelations[self.father_rel.get_text()]
type = const.save_frel(self.prel.get_text())
if self.father or self.mother:
if self.mother and not self.father:
if self.mother.getGender() == Person.male:
if self.mother.getGender() == RelLib.Person.male:
self.father = self.mother
self.mother = None
self.family = self.find_family(self.father,self.mother)
elif self.father and not self.mother:
if self.father.getGender() == Person.female:
if self.father.getGender() == RelLib.Person.female:
self.mother = self.father
self.father = None
self.family = self.find_family(self.father,self.mother)
elif self.mother.getGender() != self.father.getGender():
if type == "Partners":
type = "Unknown"
if self.father.getGender() == Person.female:
if self.father.getGender() == RelLib.Person.female:
x = self.father
self.father = self.mother
self.mother = x
@ -228,14 +231,14 @@ class ChooseParents:
utils.destroy_passed_object(obj)
if self.family:
self.family.setRelationship(type)
self.change_family_type(self.family,mrel,frel)
self.change_family_type(self.family,mother_rel,father_rel)
self.family_update(self.family)
def on_addparent_clicked(self,obj,sex):
def add_parent_clicked(self,obj,sex):
self.xml = libglade.GladeXML(const.gladeFile,"addperson")
self.xml.get_widget(sex).set_active(1)
self.xml.signal_autoconnect({
"on_addfather_close": self.on_addparent_close,
"on_addfather_close": self.add_parent_close,
"on_combo_insert_text" : utils.combo_insert_text,
"destroy_passed_object" : utils.destroy_passed_object
})
@ -245,83 +248,77 @@ class ChooseParents:
window.editable_enters(self.xml.get_widget("surname"))
utils.attach_surnames(self.xml.get_widget("surnameCombo"))
def on_addfather_clicked(self,obj):
self.on_addparent_clicked(obj,"male")
def add_father_clicked(self,obj):
self.add_parent_clicked(obj,"male")
def on_addmother_clicked(self,obj):
self.on_addparent_clicked(obj,"female")
def add_mother_clicked(self,obj):
self.add_parent_clicked(obj,"female")
def change_family_type(self,family,mrel,frel):
def change_family_type(self,family,mother_rel,father_rel):
"""
Changes the family type of the specified family. If the family
is None, the the relationship type shoud be deleted.
"""
is_main = mother_rel == "Birth" and father_rel == "Birth"
is_main = (mrel == "Birth") and (frel == "Birth")
if not family:
if is_main:
main = self.person.getMainFamily()
if main:
main.removeChild(self.person)
self.person.setMainFamily(None)
else:
for fam in self.person.getAltFamilyList():
if is_main:
self.person.removeAltFamily(fam[0])
fam.removeChild(self.person)
return
elif family == self.person.getMainFamily():
family.addChild(self.person)
if family == self.person.getMainFamily():
# make sure that the person is listed as a child
if self.person not in family.getChildList():
family.addChild(self.person)
# if the relationships indicate that this is no longer
# the main family, we need to delete the main family,
# and add it as an alternate family (assuming that it
# does not already in the list)
if not is_main:
utils.modified()
self.person.setMainFamily(None)
for fam in self.person.getAltFamilyList():
if fam[0] == family:
fam[1] = type
break
elif fam[1] == type:
fam[0] = family
break
if fam[1] == mother_rel and fam[2] == father_rel:
return
else:
self.person.removeFamily(fam[0])
else:
self.person.addAltFamily(family,mrel,frel)
self.person.addAltFamily(family,mother_rel,father_rel)
# The family is not already the main family
else:
family.addChild(self.person)
if self.person not in family.getChildList():
family.addChild(self.person)
for fam in self.person.getAltFamilyList():
if family == fam[0]:
if is_main:
self.person.setMainFamily(family)
self.person.removeAltFamily(family)
utils.modified()
break
if mrel == fam[1] and frel == fam[2]:
break
if mrel != fam[1] or frel != fam[2]:
if mother_rel == fam[1] and father_rel == fam[2]:
return
if mother_rel != fam[1] or father_rel != fam[2]:
self.person.removeAltFamily(family)
self.person.addAltFamily(family,mrel,frel)
utils.modified()
self.person.addAltFamily(family,mother_rel,father_rel)
break
else:
if is_main:
self.person.setMainFamily(family)
else:
self.person.addAltFamily(family,mrel,frel)
utils.modified()
self.person.addAltFamily(family,mother_rel,father_rel)
utils.modified()
def on_addparent_close(self,obj):
def add_parent_close(self,obj):
surname = self.xml.get_widget("surname").get_text()
given = self.xml.get_widget("given").get_text()
person = Person()
person = RelLib.Person()
self.db.addPerson(person)
name = Name()
name = person.getPrimaryName()
name.setSurname(surname)
name.setFirstName(given)
person.setPrimaryName(name)
if self.xml.get_widget("male").get_active():
person.setGender(Person.male)
person.setGender(RelLib.Person.male)
self.father = person
else:
person.setGender(Person.female)
person.setGender(RelLib.Person.female)
self.mother = person
utils.modified()
self.on_prel_changed(self.prel)
self.parent_relation_changed(self.prel)
utils.destroy_passed_object(obj)
self.full_update()

View File

@ -43,19 +43,22 @@ FRENCH = 3
#
#-------------------------------------------------------------------------
_fmonth = [
"Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse",
"Ventôse", "Germinal", "Floréal", "Prairial", "Messidor", "Thermidor",
"Fructidor", "Extra", ]
"Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse",
"Ventôse", "Germinal", "Floréal", "Prairial", "Messidor",
"Thermidor", "Fructidor", "Extra",
]
_fmonth2num = {
"vend" : 0, "brum" : 1, "frim" : 2, "nivo" : 3, "pluv" : 4,
"vent" : 5, "germ" : 6, "flor" : 7, "prai" : 8, "mess" : 9,
"ther" :10, "fruc" :11, "extr" : 12,"comp" :12, "nivô" : 3 }
"ther" :10, "fruc" :11, "extr" : 12,"comp" :12, "nivô" : 3
}
_hmonth = [
"Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI",
"AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av", "Elul"
]
"AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av",
"Elul",
]
_hmonth2num = {
"tishri" : 0, "heshvan" : 1, "kislev" : 2, "tevet" : 3,
@ -67,23 +70,20 @@ _hmonth2num = {
"aav" :11, "ell" :12,
}
_mname = [ _("January"), _("February"), _("March"), _("April"),
_("May"), _("June"), _("July"), _("August"),
_("September"), _("October"), _("November"), _("December") ]
_m2num = { string.lower(_mname[0][0:3]) : 0,
string.lower(_mname[1][0:3]) : 1,
string.lower(_mname[2][0:3]) : 2,
string.lower(_mname[3][0:3]) : 3,
string.lower(_mname[4][0:3]) : 4,
string.lower(_mname[5][0:3]) : 5,
string.lower(_mname[6][0:3]) : 6,
string.lower(_mname[7][0:3]) : 7,
string.lower(_mname[8][0:3]) : 8,
string.lower(_mname[9][0:3]) : 9,
string.lower(_mname[10][0:3]) : 10,
string.lower(_mname[11][0:3]) : 11 }
_mname = [
_("January"), _("February"), _("March"), _("April"),
_("May"), _("June"), _("July"), _("August"),
_("September"), _("October"), _("November"), _("December")
]
_m2num = {
string.lower(_mname[0][0:3]): 0, string.lower(_mname[1][0:3]): 1,
string.lower(_mname[2][0:3]): 2, string.lower(_mname[3][0:3]): 3,
string.lower(_mname[4][0:3]): 4, string.lower(_mname[5][0:3]): 5,
string.lower(_mname[6][0:3]): 6, string.lower(_mname[7][0:3]): 7,
string.lower(_mname[8][0:3]): 8, string.lower(_mname[9][0:3]): 9,
string.lower(_mname[10][0:3]): 10, string.lower(_mname[11][0:3]): 11
}
UNDEF = -999999
@ -98,9 +98,6 @@ class Date:
Error = "Illegal Date"
range = 1
normal = 0
# The last part of these two strings must remain untranslated. It
# is required to read saved data from XML.
from_str = _("(from|between|bet|bet.") + "|FROM)"
@ -147,15 +144,6 @@ class Date:
def getYear(self):
return self.start.year
def getHighYear(self):
if self.stop == None:
return self.start.year
else:
return self.stop.year
def getLowYear(self):
return self.start.getYear()
def getMonth(self):
if self.start.month == UNDEF:
return UNDEF
@ -264,16 +252,6 @@ class Date:
d2 = self.stop.display_calendar(month_map)
return "%s %s %s %s (%s)" % ( _("from"),d1,_("to"), d2,cal_str)
def getSaveDate(self):
if self.range == 1:
d1 = self.start.getSaveDate()
d2 = self.stop.getSaveDate()
return "FROM %s TO %s" % (d1,d2)
elif self.range == -1:
return self.text
else:
return self.start.getSaveDate()
def isEmpty(self):
s = self.start
return s.year==UNDEF and s.month==UNDEF and s.day==UNDEF
@ -315,31 +293,29 @@ class SingleDate:
before = 2
after = 3
emname =[ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ]
emname =[
'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
]
em2num ={ "jan" : 0, "feb" : 1, "mar" : 2, "apr" : 3,
"may" : 4, "jun" : 5, "jul" : 6, "aug" : 7,
"sep" : 8, "oct" : 9, "nov" : 10,"dec" : 11 }
em2num ={
"jan" : 0, "feb" : 1, "mar" : 2, "apr" : 3,
"may" : 4, "jun" : 5, "jul" : 6, "aug" : 7,
"sep" : 8, "oct" : 9, "nov" : 10,"dec" : 11
}
m2v = { _("abt") : about ,
_("about") : about,
_("abt.") : about,
_("est") : about ,
_("est.") : about ,
_("circa") : about,
_("around") : about,
_("before") : before,
_("bef") : before,
_("bef.") : before,
_("after") : after,
_("aft.") : after,
_("aft") : after,
m2v = {
_("abt") : about , _("about") : about,
_("abt.") : about, _("est") : about ,
_("est.") : about , _("circa") : about,
_("around") : about, _("before") : before,
_("bef") : before, _("bef.") : before,
_("after") : after, _("aft.") : after,
_("aft") : after,
# And the untranslated versions for reading saved data from XML.
"abt" : about,
"about" : about,
"after" : after,
"before" : before }
"abt" : about, "about" : about,
"after" : after, "before": before
}
modifiers = '(' + \
_("abt\.?") + '|' + \
@ -355,15 +331,14 @@ class SingleDate:
start = "^\s*" + modifiers + "?\s*"
fmt1 = compile(start + "(\S+)(\s+\d+\s*,)?\s*(\d+)?\s*$", IGNORECASE)
fmt2 = compile(start + "(\d+)\.?\s+(\S+)(\s+\d+)?\s*$", IGNORECASE)
quick= compile(start + "(\d+)?\s(\S\S\S)?\s(\d+)?", IGNORECASE)
fmt3 = compile(start + r"([?\d]+)\s*[./-]\s*([?\d]+)\s*[./-]\s*([?\d]+)\s*$",
fmt1 = compile(start+"(\S+)(\s+\d+\s*,)?\s*(\d+)?\s*$", IGNORECASE)
fmt2 = compile(start+"(\d+)\.?\s+(\S+)(\s+\d+)?\s*$", IGNORECASE)
fmt3 = compile(start+r"([?\d]+)\s*[./-]\s*([?\d]+)\s*[./-]\s*([?\d]+)\s*$",
IGNORECASE)
fmt7 = compile(start + r"([?\d]+)\s*[./-]\s*([?\d]+)\s*$", IGNORECASE)
fmt4 = compile(start + "(\S+)\s+(\d+)\s*$", IGNORECASE)
fmt5 = compile(start + "(\d+)\s*$", IGNORECASE)
fmt6 = compile(start + "(\S+)\s*$", IGNORECASE)
fmt7 = compile(start+r"([?\d]+)\s*[./-]\s*([?\d]+)\s*$", IGNORECASE)
fmt4 = compile(start+"(\S+)\s+(\d+)\s*$", IGNORECASE)
fmt5 = compile(start+"(\d+)\s*$", IGNORECASE)
fmt6 = compile(start+"(\S+)\s*$", IGNORECASE)
def __init__(self,source=None):
if source:
@ -383,8 +358,7 @@ class SingleDate:
if val == None:
self.mode = SingleDate.exact
else:
val = string.lower(val)
self.mode = SingleDate.m2v[val]
self.mode = SingleDate.m2v[string.lower(val)]
def setMonth(self,val):
if val > 12 or val < 0:
@ -435,6 +409,7 @@ class SingleDate:
self.month = _m2num[string.lower(text[0:3])]
except KeyError:
self.setMonthStrEng(text)
raise Date.Error,text
def setMonthStrEng(self,text):
try:
@ -463,33 +438,6 @@ class SingleDate:
d = "-%02d" % self.day
return "%s%s%s" % (y,m,d)
def getSaveDate(self):
if self.month == UNDEF and self.day == UNDEF and self.year == UNDEF :
return ""
elif self.day == UNDEF:
if self.month == UNDEF:
retval = str(self.year)
elif self.year == UNDEF:
retval = SingleDate.emname[self.month]
else:
retval = "%s %d" % (SingleDate.emname[self.month],self.year)
elif self.month == UNDEF:
retval = str(self.year)
else:
month = SingleDate.emname[self.month]
if self.year == UNDEF:
retval = "%d %s ????" % (self.day,month)
else:
retval = "%d %s %d" % (self.day,month,self.year)
if self.mode == SingleDate.about:
retval = "ABOUT %s" % retval
elif self.mode == SingleDate.before:
retval = "BEFORE" + " " + retval
elif self.mode == SingleDate.after:
retval = "AFTER" + " " + retval
return retval
def get_fmt1(self):
if self.month == UNDEF and self.day == UNDEF and self.year == UNDEF :
return ""
@ -841,8 +789,6 @@ class SingleDate:
matches = match.groups()
self.setMode(matches[0])
self.setMonthStr(matches[2])
if self.month == UNDEF:
raise Date.Error,text
self.day = int(matches[1])
if len(matches) == 4 and matches[3] != None:
self.setYearVal(matches[3])
@ -891,21 +837,14 @@ class SingleDate:
match = SingleDate.fmt1.match(text)
if match != None:
matches = match.groups()
self.setMode(matches[0])
self.setMonthStr(matches[1])
if self.month == UNDEF:
raise Date.Error,text
val = matches[2]
if val:
self.day = int(string.replace(val,',',''))
(mode,mon,day,year) = match.groups()
self.setMode(mode)
self.setMonthStr(mon)
if day:
self.setDayVal(int(string.replace(day,',','')))
else:
self.day = UNDEF
val = matches[3]
if val:
self.setYearVal(matches[3])
else:
self.setYearVal(UNDEF)
self.setYearVal(year)
return 1
match = SingleDate.fmt4.match(text)
@ -913,8 +852,6 @@ class SingleDate:
matches = match.groups()
self.setMode(matches[0])
self.setMonthStr(matches[1])
if self.month == UNDEF:
raise Date.Error,text
self.day = UNDEF
if len(matches) == 4:
self.setYearVal(matches[3])
@ -1007,37 +944,5 @@ def compare_dates(f,s):
else:
return cmp(first.day,second.day)
_func = SingleDate.fmtFunc[0]
if __name__ == "__main__":
def checkit(s):
d = Date()
d.set(s)
print s, ':', d.getDate(), ':', d.getQuoteDate()
for code in range(0,7):
Date.formatCode = code
Date.entryCode = 0
print "\nFormat Code = %d\n" % code
checkit("June 11")
checkit("1923")
checkit("11/12/1293")
checkit("11 JAN 1923")
checkit("11-1-1929")
checkit("4/3/1203")
checkit("3/1203")
checkit("?/3/1203")
checkit("January 4, 1923")
checkit("before 3/3/1239")
checkit("est 2-3-1023")
checkit("between January 4, 1234 and NOV 4, 1245")
checkit("from 3-2-1234 to 5-4-2345")
Date.entryCode = 1
checkit("1/12/1999")
checkit("12/11/1999")
checkit("summer")
print "----------"
checkit("BET. 1994 - 1999")

View File

@ -391,10 +391,7 @@ class EditPerson:
self.redraw_event_list()
def ev_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
@ -414,10 +411,7 @@ class EditPerson:
self.redraw_url_list()
def url_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
@ -441,10 +435,7 @@ class EditPerson:
self.redraw_attr_list()
def at_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
@ -468,10 +459,7 @@ class EditPerson:
self.redraw_addr_list()
def ad_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);

View File

@ -169,10 +169,7 @@ class EditPlace:
self.redraw_url_list()
def url_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);

View File

@ -401,7 +401,11 @@ class GrampsParser:
self.placeobj.addPhoto(self.pref)
def start_daterange(self,attrs):
if self.address:
if self.source_ref:
d = self.source_ref.getDate()
elif self.ord:
d = self.ord.getDateObj()
elif self.address:
d = self.address.getDateObj()
else:
d = self.event.getDateObj()
@ -414,7 +418,9 @@ class GrampsParser:
d.range = 1
def start_dateval(self,attrs):
if self.ord:
if self.source_ref:
d = self.source_ref.getDate()
elif self.ord:
d = self.ord.getDateObj()
elif self.address:
d = self.address.getDateObj()
@ -432,7 +438,9 @@ class GrampsParser:
d.get_start_date().setMode(None)
def start_datestr(self,attrs):
if self.ord:
if self.source_ref:
d = self.source_ref.getDate()
elif self.ord:
d = self.ord.getDateObj()
elif self.address:
d = self.address.getDateObj()

View File

@ -185,10 +185,7 @@ class Marriage:
self.redraw_event_list()
def ev_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
@ -212,11 +209,7 @@ class Marriage:
self.redraw_attr_list()
def at_source_drag_data_get(self,widget, context, selection_data, info, time):
if len(widget.selection) != 1:
return
row = widget.selection[0]
ev = widget.get_row_data(row)
ev = widget.get_row_data(widget.focus_row)
bits_per = 8; # we're going to pass a string
pickled = pickle.dumps(ev);
data = str(('fattr',self.family.getId(),pickled));

View File

@ -277,18 +277,15 @@ class MediaView:
def on_drag_data_get(self,w, context, selection_data, info, time):
if info == 1:
return
if len(w.selection) > 0:
row = w.selection[0]
d = w.get_row_data(row)
id = d.getId()
selection_data.set(selection_data.target, 8, id)
d = w.get_row_data(w.focus_row)
id = d.getId()
selection_data.set(selection_data.target, 8, id)
def on_drag_data_received(self,w, context, x, y, data, info, time):
import urlparse
if data and data.format == 8:
d = string.strip(string.replace(data.data,'\0',' '))
protocol,site,file, j,k,l = urlparse.urlparse(d)
print protocol,site,file,j,k,l
if protocol == "file":
name = file
mime = utils.get_mime_type(name)

View File

@ -225,7 +225,6 @@ def reload_plugins(obj):
for plugin in _failed:
try:
__import__(plugin)
print plugin
except:
print _("Failed to load the module: %s") % plugin
import traceback

View File

@ -1227,12 +1227,6 @@ class Event(DataObj):
"""sets the Date object associated with the Event"""
self.date = date
def getSaveDate(self) :
"""returns the date of the Event in the form wanted by gramps XML save"""
if self.date:
return self.date.getSaveDate()
return ""
class Family:
"""Represents a family unit in the gramps database"""

View File

@ -107,12 +107,12 @@ def dump_my_event(g,name,event,index=1):
if not event:
return
date = event.getSaveDate()
date = event.getDateObj()
place = event.getPlace()
description = event.getDescription()
cause = event.getCause()
if (not name or name == "Birth" or name == "Death") and \
not date and not place and not description:
date.isEmpty() and not place and not description:
return
sp = " " * index
@ -160,10 +160,10 @@ def dump_source_ref(g,source_ref,index=1):
p = source_ref.getPage()
c = source_ref.getComments()
t = source_ref.getText()
d = source_ref.getDate().getSaveDate()
d = source_ref.getDate()
q = source_ref.getConfidence()
g.write(" " * index)
if p == "" and c == "" and t == "" and d == "" and q == 2:
if p == "" and c == "" and t == "" and d.isEmpty() and q == 2:
g.write('<sourceref ref="%s"/>\n' % source.getId())
else:
if q == 2:
@ -173,7 +173,7 @@ def dump_source_ref(g,source_ref,index=1):
write_line(g,"spage",p,index+1)
write_note(g,"scomments",c,index+1)
write_note(g,"stext",t,index+1)
write_line(g,"sdate",d,index+1)
write_date(g,d,index+1)
g.write("%s</sourceref>\n" % (" " * index))
#-------------------------------------------------------------------------

View File

@ -79,6 +79,7 @@ revisionFile = "%s/revision.glade" % rootDir
srcselFile = "%s/srcsel.glade" % rootDir
findFile = "%s/find.glade" % rootDir
mergeFile = "%s/mergedata.glade" % rootDir
traceFile = "%s/trace.glade" % rootDir
pluginsDir = "%s/plugins" % rootDir
filtersDir = "%s/filters" % rootDir
dataDir = "%s/data" % rootDir

View File

@ -4,6 +4,9 @@ import traceback
import intl
import os
import gtk
import gnome.ui
import const
intl.textdomain("gramps")
@ -23,10 +26,11 @@ try:
else:
gramps_main.main(None)
except:
traceback.print_exc()
fname = os.path.expanduser("~/gramps.err")
errfile = open(fname,"w")
traceback.print_exc(file=errfile)
errfile.close()

View File

@ -2029,6 +2029,7 @@ def main(arg):
read_file(Config.lastfile)
database.setResearcher(Config.owner)
gtk.mainloop()
#-------------------------------------------------------------------------

View File

@ -666,13 +666,13 @@ class GedcomWriter:
birth = person.getBirth()
if not (self.private and birth.getPrivacy()):
if birth.getSaveDate() != "" or birth.getPlaceName() != "":
if not birth.getDateObj().isEmpty() or birth.getPlaceName() != "":
self.g.write("1 BIRT\n")
self.dump_event_stats(birth)
death = person.getDeath()
if not (self.private and death.getPrivacy()):
if death.getSaveDate() != "" or death.getPlaceName() != "":
if not death.getDateObj().isEmpty() or death.getPlaceName() != "":
self.g.write("1 DEAT\n")
self.dump_event_stats(death)
@ -764,9 +764,7 @@ class GedcomWriter:
if self.private and addr.getPrivacy():
continue
self.g.write("1 RESI\n")
datestr = addr.getDateObj().getSaveDate()
if datestr != "":
self.g.write("2 DATE %s\n" % self.cnvtxt(datestr))
self.print_date("2 DATE",addr.getDateObj())
if self.resi == 0:
self.write_long_text("ADDR",2,addr.getStreet())
if addr.getCity() != "":
@ -881,10 +879,7 @@ class GedcomWriter:
def dump_event_stats(self,event):
dateobj = event.getDateObj()
if not dateobj.isEmpty():
self.print_date("2 DATE",dateobj)
elif dateobj.getText() != "":
self.g.write("2 DATE %s\n" % self.cnvtxt(dateobj.getText()))
self.print_date("2 DATE",dateobj)
if event.getPlaceName() != "":
self.g.write("2 PLAC %s\n" % self.cnvtxt(event.getPlaceName()))
if event.getCause() != "":
@ -906,8 +901,11 @@ class GedcomWriter:
def print_date(self,prefix,date):
start = date.get_start_date()
if date.get_calendar() == Date.GREGORIAN:
if date.isEmpty():
val = date.getText()
if val != "":
self.g.write("%s %s\n" % (prefix,self.cnvtxt(val)))
elif date.get_calendar() == Date.GREGORIAN:
if date.isRange():
val = "FROM %s TO %s" % (make_date(start,_month),
make_date(date.get_stop_date(),_month))
@ -969,12 +967,13 @@ class GedcomWriter:
self.g.write("%d PAGE %s\n" % (level+1,ref.getPage()))
ref_text = ref.getText()
if ref_text != "" or ref.getDate().getDate() != "":
if ref_text != "" or not ref.getDate().isEmpty():
self.g.write('%d DATA\n' % (level+1))
if ref_text != "":
self.write_long_text("TEXT",level+2,ref_text)
if ref.getDate().getDate():
self.g.write("%d DATE %s\n" % (level+2,ref.getDate().getSaveDate()))
pfx = "%d DATE" % (level+2)
print pfx,ref.getDate()
self.print_date(pfx,ref.getDate())
if ref.getComments() != "":
self.write_long_text("NOTE",level+1,ref.getComments())

View File

@ -43,26 +43,19 @@ def soundex(str):
"Return the soundex value to a string argument."
str = string.strip(string.upper(str))
if not str:
return "Z000"
str2 = str[0]
str = string.translate(str, TABLE, IGNORE)
if not str:
return "Z000"
prev = str[0]
for x in str[1:]:
if x != prev and x != "0":
str2 = str2 + x
prev = x
# pad with zeros
str2 = str2+"0000"
return str2[:4]
#-------------------------------------------------------------------------
@ -72,5 +65,4 @@ def soundex(str):
#-------------------------------------------------------------------------
def compare(str1, str2):
"1 if strings are close. 0 otherwise."
return soundex(str1) == soundex(str2)

View File

@ -103,34 +103,25 @@ def phonebook_name(person):
return ""
def family_name(family):
"""Builds a name for the family from the parents names"""
father = family.getFather()
mother = family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),mother.getPrimaryName().getName())
fname = father.getPrimaryName().getName()
mname = mother.getPrimaryName().getName()
name = _("%s and %s") % (fname,mname)
elif father:
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
return name
#-------------------------------------------------------------------------
#
# Short hand function to return either the person's name, or an empty
# string if the person is None
#
#-------------------------------------------------------------------------
def phonebook_from_name(name,alt):
if alt:
return "%s *" % name.getName()
else:
return name.getName()
#-------------------------------------------------------------------------
#
# Short hand function to return either the person's name, or an empty
# string if the person is None
#
#-------------------------------------------------------------------------
def normal_name(person):
if person:
return person.getPrimaryName().getRegularName()
@ -155,33 +146,15 @@ def destroy_passed_object(obj):
#-------------------------------------------------------------------------
if string.find("%.3f" % 1.2, ",") == -1:
_use_comma = 0
else:
_use_comma = 1
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
if _use_comma:
def txt2fl(st):
return string.atof(string.replace(st,'.',','))
else:
def txt2fl(st):
return string.atof(string.replace(st,',','.'))
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
if _use_comma:
def fl2txt(fmt,val):
return string.replace(fmt % val, ',', '.')
else:
def fl2txt(fmt,val):
return fmt % val
else:
def txt2fl(st):
return string.atof(string.replace(st,'.',','))
def fl2txt(fmt,val):
return string.replace(fmt % val, ',', '.')
#-------------------------------------------------------------------------
#
@ -478,7 +451,6 @@ def combo_insert_text(combo,new_text,new_text_len,i_dont_care):
timer = gtk.timeout_add(5, combo_timer_callback, combo)
combo.set_data("timer", timer);
#-------------------------------------------------------------------------
#
# The combo box entry field lost focus. Go clear any selection. Why
@ -489,7 +461,6 @@ def combo_insert_text(combo,new_text,new_text_len,i_dont_care):
def combo_lost_focus(entry,a,b):
entry.select_region(0, 0)
#-------------------------------------------------------------------------
#
# The workhorse routine of file completion. This routine grabs the