* src/DateParser.py: handle leap year in gregorial validity check
* src/MergeData.py: Preserve more data when merging the 1.0.X patch from Julio Sanchez) * src/plugins/ReadGedcom.py: Attach top leve source to the person instead of the primary name (ported from the 1.0.X patch from Julio Sanchez) * src/const.py: Add support for "Number of Children" attribute (GEDCOM NCHI) (ported from the 1.0.X patch from Julio Sanchez) svn: r3728
This commit is contained in:
parent
824df0bf5a
commit
5aefd4463f
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2004-11-14 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/DateParser.py: handle leap year in gregorial validity check
|
||||||
|
* src/MergeData.py: Preserve more data when merging
|
||||||
|
the 1.0.X patch from Julio Sanchez)
|
||||||
|
* src/plugins/ReadGedcom.py: Attach top leve source to the
|
||||||
|
person instead of the primary name (ported from the 1.0.X patch
|
||||||
|
from Julio Sanchez)
|
||||||
|
* src/const.py: Add support for "Number of Children" attribute
|
||||||
|
(GEDCOM NCHI) (ported from the 1.0.X patch from Julio Sanchez)
|
||||||
|
|
||||||
2004-11-12 Tim Waugh <twaugh@redhat.com>
|
2004-11-12 Tim Waugh <twaugh@redhat.com>
|
||||||
* src/plugins/Ancestors.py (person_name): Handle surname prefix (patch
|
* src/plugins/Ancestors.py (person_name): Handle surname prefix (patch
|
||||||
from Julio Sanchez).
|
from Julio Sanchez).
|
||||||
|
@ -36,6 +36,7 @@ __version__ = "$Revision$"
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
|
import calendar
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -49,7 +50,8 @@ import Date
|
|||||||
# Top-level module functions
|
# Top-level module functions
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
_max_days = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
||||||
|
_leap_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
||||||
|
|
||||||
def gregorian_valid(date_tuple):
|
def gregorian_valid(date_tuple):
|
||||||
day = date_tuple[0]
|
day = date_tuple[0]
|
||||||
@ -58,6 +60,9 @@ def gregorian_valid(date_tuple):
|
|||||||
try:
|
try:
|
||||||
if month > 12:
|
if month > 12:
|
||||||
valid = False
|
valid = False
|
||||||
|
elif calendar.isleap(date_tuple[2]):
|
||||||
|
if day > _leap_days[month-1]:
|
||||||
|
valid = False
|
||||||
elif day > _max_days[month-1]:
|
elif day > _max_days[month-1]:
|
||||||
valid = False
|
valid = False
|
||||||
except:
|
except:
|
||||||
@ -82,18 +87,9 @@ class DateParser:
|
|||||||
# RFC-2822 only uses capitalized English abbreviated names, no locales.
|
# RFC-2822 only uses capitalized English abbreviated names, no locales.
|
||||||
_rfc_days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
|
_rfc_days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
|
||||||
_rfc_mons_to_int = {
|
_rfc_mons_to_int = {
|
||||||
'Jan' : 1,
|
'Jan' : 1, 'Feb' : 2, 'Mar' : 3, 'Apr' : 4,
|
||||||
'Feb' : 2,
|
'May' : 5, 'Jun' : 6, 'Jul' : 7, 'Aug' : 8,
|
||||||
'Mar' : 3,
|
'Sep' : 9, 'Oct' : 10, 'Nov' : 11, 'Dec' : 12,
|
||||||
'Apr' : 4,
|
|
||||||
'May' : 5,
|
|
||||||
'Jun' : 6,
|
|
||||||
'Jul' : 7,
|
|
||||||
'Aug' : 8,
|
|
||||||
'Sep' : 9,
|
|
||||||
'Oct' : 10,
|
|
||||||
'Nov' : 11,
|
|
||||||
'Dec' : 12,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
month_to_int = {
|
month_to_int = {
|
||||||
@ -317,9 +313,9 @@ class DateParser:
|
|||||||
|
|
||||||
def _parse_greg_julian(self,text):
|
def _parse_greg_julian(self,text):
|
||||||
return self._parse_calendar(text,self._text,self._text2,
|
return self._parse_calendar(text,self._text,self._text2,
|
||||||
self.month_to_int)
|
self.month_to_int,gregorian_valid)
|
||||||
|
|
||||||
def _parse_calendar(self,text,regex1,regex2,mmap):
|
def _parse_calendar(self,text,regex1,regex2,mmap,check=None):
|
||||||
match = regex1.match(text)
|
match = regex1.match(text)
|
||||||
if match:
|
if match:
|
||||||
groups = match.groups()
|
groups = match.groups()
|
||||||
@ -336,7 +332,10 @@ class DateParser:
|
|||||||
d = self._get_int(groups[1])
|
d = self._get_int(groups[1])
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
s = groups[4] != None
|
s = groups[4] != None
|
||||||
return (d,m,y,s)
|
value = (d,m,y,s)
|
||||||
|
if check and not check((d,m,y)):
|
||||||
|
value = Date.EMPTY
|
||||||
|
return value
|
||||||
|
|
||||||
match = regex2.match(text)
|
match = regex2.match(text)
|
||||||
if match:
|
if match:
|
||||||
@ -354,7 +353,11 @@ class DateParser:
|
|||||||
else:
|
else:
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
s = groups[4] != None
|
s = groups[4] != None
|
||||||
return (d,m,y,s)
|
value = (d,m,y,s)
|
||||||
|
if check and not check((d,m,y)):
|
||||||
|
value = DATE.EMPTY
|
||||||
|
return value
|
||||||
|
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
|
|
||||||
def _parse_subdate(self,text,subparser=None):
|
def _parse_subdate(self,text,subparser=None):
|
||||||
@ -363,6 +366,9 @@ class DateParser:
|
|||||||
"""
|
"""
|
||||||
if subparser == None:
|
if subparser == None:
|
||||||
subparser = self._parse_greg_julian
|
subparser = self._parse_greg_julian
|
||||||
|
check = gregorian_valid
|
||||||
|
else:
|
||||||
|
check = None
|
||||||
|
|
||||||
value = subparser(text)
|
value = subparser(text)
|
||||||
if value != Date.EMPTY:
|
if value != Date.EMPTY:
|
||||||
@ -374,7 +380,7 @@ class DateParser:
|
|||||||
y = self._get_int(groups[0])
|
y = self._get_int(groups[0])
|
||||||
m = self._get_int(groups[1])
|
m = self._get_int(groups[1])
|
||||||
d = self._get_int(groups[2])
|
d = self._get_int(groups[2])
|
||||||
if gregorian_valid((d,m)):
|
if gregorian_valid((d,m,y)):
|
||||||
return (d,m,y,False)
|
return (d,m,y,False)
|
||||||
else:
|
else:
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
@ -385,7 +391,7 @@ class DateParser:
|
|||||||
d = self._get_int(groups[2])
|
d = self._get_int(groups[2])
|
||||||
m = self._rfc_mons_to_int[groups[3]]
|
m = self._rfc_mons_to_int[groups[3]]
|
||||||
y = self._get_int(groups[4])
|
y = self._get_int(groups[4])
|
||||||
if gregorian_valid((d,m)):
|
if gregorian_valid((d,m,y)):
|
||||||
return (d,m,y,False)
|
return (d,m,y,False)
|
||||||
else:
|
else:
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
@ -400,11 +406,11 @@ class DateParser:
|
|||||||
m = self._get_int(groups[1])
|
m = self._get_int(groups[1])
|
||||||
d = self._get_int(groups[3])
|
d = self._get_int(groups[3])
|
||||||
y = self._get_int(groups[4])
|
y = self._get_int(groups[4])
|
||||||
if gregorian_valid((d,m)):
|
value = (d,m,y,False)
|
||||||
return (d,m,y,False)
|
if check and not check((d,m,y)):
|
||||||
else:
|
value = Date.EMPTY
|
||||||
return Date.EMPTY
|
return value
|
||||||
|
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
|
|
||||||
def set_date(self,date,text):
|
def set_date(self,date,text):
|
||||||
|
@ -235,8 +235,8 @@ class MergePeople:
|
|||||||
for xdata in self.p2.get_alternate_names():
|
for xdata in self.p2.get_alternate_names():
|
||||||
for data in lst:
|
for data in lst:
|
||||||
if data.are_equal(xdata):
|
if data.are_equal(xdata):
|
||||||
self.copy_note(xdata,data)
|
self.copy_note(data,xdata)
|
||||||
self.copy_sources(xdata,data)
|
self.copy_sources(data,xdata)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.p1.add_alternate_name(xdata)
|
self.p1.add_alternate_name(xdata)
|
||||||
@ -246,8 +246,8 @@ class MergePeople:
|
|||||||
for data in lst:
|
for data in lst:
|
||||||
if data.get_type() == xdata.get_type() and \
|
if data.get_type() == xdata.get_type() and \
|
||||||
data.getValue() == xdata.get_value():
|
data.getValue() == xdata.get_value():
|
||||||
self.copy_note(xdata,data)
|
self.copy_note(data,xdata)
|
||||||
self.copy_sources(xdata,data)
|
self.copy_sources(data,xdata)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.p1.add_attribute(xdata)
|
self.p1.add_attribute(xdata)
|
||||||
@ -256,12 +256,22 @@ class MergePeople:
|
|||||||
for xdata in self.p2.get_event_list():
|
for xdata in self.p2.get_event_list():
|
||||||
for data in lst:
|
for data in lst:
|
||||||
if data.are_equal(xdata):
|
if data.are_equal(xdata):
|
||||||
self.copy_note(xdata,data)
|
self.copy_note(data,xdata)
|
||||||
self.copy_sources(xdata,data)
|
self.copy_sources(data,xdata)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.p1.add_event(xdata)
|
self.p1.add_event(xdata)
|
||||||
|
|
||||||
|
lst = self.p1.get_address_list()
|
||||||
|
for xdata in self.p2.getAddressList():
|
||||||
|
for data in lst:
|
||||||
|
if data.are_equal(xdata):
|
||||||
|
self.copy_note(data,xdata)
|
||||||
|
self.copy_sources(data,xdata)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.p1.addAddress(xdata)
|
||||||
|
|
||||||
lst = self.p1.get_url_list()[:]
|
lst = self.p1.get_url_list()[:]
|
||||||
for xdata in self.p2.get_url_list():
|
for xdata in self.p2.get_url_list():
|
||||||
for data in lst:
|
for data in lst:
|
||||||
@ -345,6 +355,8 @@ class MergePeople:
|
|||||||
old_note = old_note + "\n\n"
|
old_note = old_note + "\n\n"
|
||||||
self.p1.set_note(old_note + self.p2.get_note())
|
self.p1.set_note(old_note + self.p2.get_note())
|
||||||
|
|
||||||
|
self.copy_sources(self.p1,self.p2)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.db.remove_person(self.p2.get_handle())
|
self.db.remove_person(self.p2.get_handle())
|
||||||
self.db.personMap[self.p1.get_handle()] = self.p1
|
self.db.personMap[self.p1.get_handle()] = self.p1
|
||||||
|
@ -985,7 +985,7 @@ class GedcomParser:
|
|||||||
self.person.add_event_handle(event.get_handle())
|
self.person.add_event_handle(event.get_handle())
|
||||||
elif matches[1] == "SOUR":
|
elif matches[1] == "SOUR":
|
||||||
source_ref = self.handle_source(matches,2)
|
source_ref = self.handle_source(matches,2)
|
||||||
self.person.get_primary_name().add_source_reference(source_ref)
|
self.person.add_source_reference(source_ref)
|
||||||
elif matches[1] == "REFN":
|
elif matches[1] == "REFN":
|
||||||
if intRE.match(matches[2]):
|
if intRE.match(matches[2]):
|
||||||
try:
|
try:
|
||||||
|
@ -382,6 +382,7 @@ personalConstantAttributes = {
|
|||||||
"Description" : "DSCR",
|
"Description" : "DSCR",
|
||||||
"Identification Number" : "IDNO",
|
"Identification Number" : "IDNO",
|
||||||
"National Origin" : "NATI",
|
"National Origin" : "NATI",
|
||||||
|
"Number of Children" : "NCHI",
|
||||||
"Social Security Number": "SSN"
|
"Social Security Number": "SSN"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,6 +397,7 @@ personal_attributes = TransTable({
|
|||||||
"Description" : _("Description"),
|
"Description" : _("Description"),
|
||||||
"Identification Number" : _("Identification Number"),
|
"Identification Number" : _("Identification Number"),
|
||||||
"National Origin" : _("National Origin"),
|
"National Origin" : _("National Origin"),
|
||||||
|
"Number of Children" : _("Number of Children"),
|
||||||
"Social Security Number": _("Social Security Number")
|
"Social Security Number": _("Social Security Number")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user