* RelLib/_*.py: Make objects serialize all the way down to built-in
python objects, so that Gramps classes are never pickled. * Date.py, CalSdn.py: Move to RelLib. * src/dates/Date_*.py: Use new Date. * src/plugins/*.py: Use new Date. * src/GrampsDb/_*.py: Use new Date, new unserialize. * src/*.py: Use new Date. svn: r5875
This commit is contained in:
parent
fd279d348c
commit
7329720f07
@ -1,3 +1,12 @@
|
||||
2006-02-03 Alex Roitman <shura@gramps-project.org>
|
||||
* RelLib/_*.py: Make objects serialize all the way down to built-in
|
||||
python objects, so that Gramps classes are never pickled.
|
||||
* Date.py, CalSdn.py: Move to RelLib.
|
||||
* src/dates/Date_*.py: Use new Date.
|
||||
* src/plugins/*.py: Use new Date.
|
||||
* src/GrampsDb/_*.py: Use new Date, new unserialize.
|
||||
* src/*.py: Use new Date.
|
||||
|
||||
2006-02-03 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
|
||||
* src/TreeViews/_PersonTreeView.py: added more columns
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -54,7 +54,6 @@ import RelLib
|
||||
import const
|
||||
import Utils
|
||||
import PeopleModel
|
||||
import Date
|
||||
import Marriage
|
||||
import NameDisplay
|
||||
import GenericFilter
|
||||
@ -152,11 +151,11 @@ class AddSpouse:
|
||||
|
||||
if birth_ref:
|
||||
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||
date_obj = Date.Date(birth.get_date_object())
|
||||
date_obj = RelLib.Date(birth.get_date_object())
|
||||
year = date_obj.get_year()
|
||||
if year:
|
||||
date_obj.set_year(year-50)
|
||||
date_obj.set_modifier(Date.MOD_AFTER)
|
||||
date_obj.set_modifier(RelLib.Date.MOD_AFTER)
|
||||
text = DateHandler.displayer.display(date_obj)
|
||||
rule = GenericFilter.HasBirth([text,"",""])
|
||||
filt.add_rule(rule)
|
||||
@ -373,7 +372,7 @@ class LikelyFilter(GenericFilter.Rule):
|
||||
person = db.get_person_from_handle(self.list[0])
|
||||
if person.birth_handle:
|
||||
birth = db.get_event_from_handle(person.birth_handle)
|
||||
dateobj = Date.Date(birth.date)
|
||||
dateobj = RelLib.Date(birth.date)
|
||||
year = dateobj.get_year()
|
||||
dateobj.set_year(year+40)
|
||||
self.lower = dateobj.sortval
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -48,7 +48,6 @@ import gtk.glade
|
||||
import GrampsDisplay
|
||||
import const
|
||||
import Utils
|
||||
import Date
|
||||
import RelLib
|
||||
import Sources
|
||||
import DateEdit
|
||||
@ -124,7 +123,7 @@ class AddressEditor(DisplayState.ManagedWindow):
|
||||
|
||||
if self.addr:
|
||||
self.srcreflist = self.addr.get_source_references()
|
||||
self.addr_date_obj = Date.Date(self.addr.get_date_object())
|
||||
self.addr_date_obj = RelLib.Date(self.addr.get_date_object())
|
||||
self.addr_start.set_text(DateHandler.get_date(self.addr))
|
||||
self.street.set_text(self.addr.get_street())
|
||||
self.city.set_text(self.addr.get_city())
|
||||
@ -146,7 +145,7 @@ class AddressEditor(DisplayState.ManagedWindow):
|
||||
Utils.bold_label(self.general_label)
|
||||
else:
|
||||
Utils.unbold_label(self.general_label)
|
||||
self.addr_date_obj = Date.Date()
|
||||
self.addr_date_obj = RelLib.Date()
|
||||
self.srcreflist = []
|
||||
self.addr = RelLib.Address()
|
||||
self.switch_page()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -63,7 +63,6 @@ import RelLib
|
||||
import const
|
||||
import Utils
|
||||
import PeopleModel
|
||||
import Date
|
||||
import NameDisplay
|
||||
import DateHandler
|
||||
import GenericFilter
|
||||
@ -247,18 +246,18 @@ class ChooseParents:
|
||||
|
||||
if birth_ref:
|
||||
birth = self.db.get_event_from_handle(birth_ref.ref)
|
||||
date_obj = Date.Date(birth.get_date_object())
|
||||
date_obj = RelLib.Date(birth.get_date_object())
|
||||
year = date_obj.get_year()
|
||||
if year:
|
||||
date_obj.set_year(year-10)
|
||||
date_obj.set_modifier(Date.MOD_BEFORE)
|
||||
date_obj.set_modifier(RelLib.Date.MOD_BEFORE)
|
||||
rule = GenericFilter.HasBirth(
|
||||
[DateHandler.displayer.display(date_obj),"",""])
|
||||
filt.add_rule(rule)
|
||||
|
||||
date_obj = Date.Date(birth.get_date_object())
|
||||
date_obj = RelLib.Date(birth.get_date_object())
|
||||
date_obj.set_year(year-60)
|
||||
date_obj.set_modifier(Date.MOD_AFTER)
|
||||
date_obj.set_modifier(RelLib.Date.MOD_AFTER)
|
||||
rule = GenericFilter.HasBirth(
|
||||
[DateHandler.displayer.display(date_obj),"",""])
|
||||
filt.add_rule(rule)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -20,514 +20,6 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
"Support for dates"
|
||||
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
from gettext import gettext as _
|
||||
from Errors import DateError
|
||||
from CalSdn import *
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
MOD_NONE = 0
|
||||
MOD_BEFORE = 1
|
||||
MOD_AFTER = 2
|
||||
MOD_ABOUT = 3
|
||||
MOD_RANGE = 4
|
||||
MOD_SPAN = 5
|
||||
MOD_TEXTONLY = 6
|
||||
|
||||
QUAL_NONE = 0
|
||||
QUAL_ESTIMATED = 1
|
||||
QUAL_CALCULATED= 2
|
||||
|
||||
CAL_GREGORIAN = 0
|
||||
CAL_JULIAN = 1
|
||||
CAL_HEBREW = 2
|
||||
CAL_FRENCH = 3
|
||||
CAL_PERSIAN = 4
|
||||
CAL_ISLAMIC = 5
|
||||
|
||||
EMPTY = (0,0,0,False)
|
||||
|
||||
_POS_DAY = 0
|
||||
_POS_MON = 1
|
||||
_POS_YR = 2
|
||||
_POS_SL = 3
|
||||
_POS_RDAY = 4
|
||||
_POS_RMON = 5
|
||||
_POS_RYR = 6
|
||||
_POS_RSL = 7
|
||||
|
||||
_calendar_convert = [
|
||||
gregorian_sdn,
|
||||
julian_sdn,
|
||||
hebrew_sdn,
|
||||
french_sdn,
|
||||
persian_sdn,
|
||||
islamic_sdn,
|
||||
]
|
||||
|
||||
_calendar_change = [
|
||||
gregorian_ymd,
|
||||
julian_ymd,
|
||||
hebrew_ymd,
|
||||
french_ymd,
|
||||
persian_ymd,
|
||||
islamic_ymd,
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Date class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Date:
|
||||
"""
|
||||
The core date handling class for GRAMPs. Supports partial dates,
|
||||
compound dates and alternate calendars.
|
||||
"""
|
||||
|
||||
calendar_names = ["Gregorian",
|
||||
"Julian",
|
||||
"Hebrew",
|
||||
"French Republican",
|
||||
"Persian",
|
||||
"Islamic"]
|
||||
|
||||
|
||||
ui_calendar_names = [_("Gregorian"),
|
||||
_("Julian"),
|
||||
_("Hebrew"),
|
||||
_("French Republican"),
|
||||
_("Persian"),
|
||||
_("Islamic")]
|
||||
|
||||
def __init__(self,source=None):
|
||||
"""
|
||||
Creates a new Date instance.
|
||||
"""
|
||||
if source:
|
||||
self.calendar = source.calendar
|
||||
self.modifier = source.modifier
|
||||
self.quality = source.quality
|
||||
self.dateval = source.dateval
|
||||
self.text = source.text
|
||||
self.sortval = source.sortval
|
||||
else:
|
||||
self.calendar = CAL_GREGORIAN
|
||||
self.modifier = MOD_NONE
|
||||
self.quality = QUAL_NONE
|
||||
self.dateval = EMPTY
|
||||
self.text = u""
|
||||
self.sortval = 0
|
||||
|
||||
def copy(self,source):
|
||||
"""
|
||||
Copy all the attributes of the given Date instance
|
||||
to the present instance, without creating a new object.
|
||||
"""
|
||||
self.calendar = source.calendar
|
||||
self.modifier = source.modifier
|
||||
self.quality = source.quality
|
||||
self.dateval = source.dateval
|
||||
self.text = source.text
|
||||
self.sortval = source.sortval
|
||||
|
||||
def __cmp__(self,other):
|
||||
"""
|
||||
Comparison function. Allows the usage of equality tests.
|
||||
This allows you do run statements like 'date1 <= date2'
|
||||
"""
|
||||
if isinstance(other,Date):
|
||||
return cmp(self.sortval,other.sortval)
|
||||
else:
|
||||
return -1
|
||||
|
||||
def is_equal(self,other):
|
||||
"""
|
||||
Return 1 if the given Date instance is the same as the present
|
||||
instance IN ALL REGARDS. Needed, because the __cmp__ only looks
|
||||
at the sorting value, and ignores the modifiers/comments.
|
||||
"""
|
||||
if self.modifier == other.modifier and self.modifier == MOD_TEXTONLY:
|
||||
value = self.text == other.text
|
||||
else:
|
||||
value = (self.calendar == other.calendar and
|
||||
self.modifier == other.modifier and
|
||||
self.quality == other.quality and
|
||||
self.dateval == other.dateval)
|
||||
return value
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Produces a string representation of the Date object. If the
|
||||
date is not valid, the text representation is displayed. If
|
||||
the date is a range or a span, a string in the form of
|
||||
'YYYY-MM-DD - YYYY-MM-DD' is returned. Otherwise, a string in
|
||||
the form of 'YYYY-MM-DD' is returned.
|
||||
"""
|
||||
if self.quality == QUAL_ESTIMATED:
|
||||
qual = "est "
|
||||
elif self.quality == QUAL_CALCULATED:
|
||||
qual = "calc "
|
||||
else:
|
||||
qual = ""
|
||||
|
||||
if self.modifier == MOD_BEFORE:
|
||||
pref = "bef "
|
||||
elif self.modifier == MOD_AFTER:
|
||||
pref = "aft "
|
||||
elif self.modifier == MOD_ABOUT:
|
||||
pref = "abt "
|
||||
else:
|
||||
pref = ""
|
||||
|
||||
if self.calendar != CAL_GREGORIAN:
|
||||
cal = " (%s)" % self.calendar_names[self.calendar]
|
||||
else:
|
||||
cal = ""
|
||||
|
||||
|
||||
if self.modifier == MOD_TEXTONLY:
|
||||
val = self.text
|
||||
elif self.modifier == MOD_RANGE or self.modifier == MOD_SPAN:
|
||||
val = "%04d-%02d-%02d - %04d-%02d-%02d" % (
|
||||
self.dateval[_POS_YR],self.dateval[_POS_MON],self.dateval[_POS_DAY],
|
||||
self.dateval[_POS_RYR],self.dateval[_POS_RMON],self.dateval[_POS_RDAY])
|
||||
else:
|
||||
val = "%04d-%02d-%02d" % (
|
||||
self.dateval[_POS_YR],self.dateval[_POS_MON],self.dateval[_POS_DAY])
|
||||
return "%s%s%s%s" % (qual,pref,val,cal)
|
||||
|
||||
def get_sort_value(self):
|
||||
"""
|
||||
Returns the sort value of Date object. If the value is a
|
||||
text string, 0 is returned. Otherwise, the calculated sort
|
||||
date is returned. The sort date is rebuilt on every assignment.
|
||||
|
||||
The sort value is an integer representing the value. A date of
|
||||
March 5, 1990 would have the value of 19900305.
|
||||
"""
|
||||
return self.sortval
|
||||
|
||||
def get_modifier(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
MOD_NONE = no modifier (default)
|
||||
MOD_BEFORE = before
|
||||
MOD_AFTER = after
|
||||
MOD_ABOUT = about
|
||||
MOD_RANGE = date range
|
||||
MOD_SPAN = date span
|
||||
MOD_TEXTONLY = text only
|
||||
"""
|
||||
return self.modifier
|
||||
|
||||
def set_modifier(self,val):
|
||||
"""
|
||||
Sets the modifier for the date.
|
||||
"""
|
||||
if val not in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT,MOD_RANGE,MOD_SPAN,MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
self.modifier = val
|
||||
|
||||
def get_quality(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
QUAL_NONE = normal (default)
|
||||
QUAL_ESTIMATED = estimated
|
||||
QUAL_CALCULATED = calculated
|
||||
"""
|
||||
return self.quality
|
||||
|
||||
def set_quality(self,val):
|
||||
"""
|
||||
Sets the quality selected for the date.
|
||||
"""
|
||||
if val not in (QUAL_NONE,QUAL_ESTIMATED,QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
self.quality = val
|
||||
|
||||
def get_calendar(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
CAL_GREGORIAN - Gregorian calendar
|
||||
CAL_JULIAN - Julian calendar
|
||||
CAL_HEBREW - Hebrew (Jewish) calendar
|
||||
CAL_FRENCH - French Republican calendar
|
||||
CAL_PERSIAN - Persian calendar
|
||||
CAL_ISLAMIC - Islamic calendar
|
||||
"""
|
||||
return self.calendar
|
||||
|
||||
def set_calendar(self,val):
|
||||
"""
|
||||
Sets the calendar selected for the date.
|
||||
"""
|
||||
if val not in (CAL_GREGORIAN,CAL_JULIAN,CAL_HEBREW,CAL_FRENCH,CAL_PERSIAN,CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
self.calendar = val
|
||||
|
||||
def get_start_date(self):
|
||||
"""
|
||||
Returns a tuple representing the start date. If the date is a
|
||||
compound date (range or a span), it is the first part of the
|
||||
compound date. If the date is a text string, a tuple of
|
||||
(0,0,0,False) is returned. Otherwise, a date of (DD,MM,YY,slash)
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.modifier == MOD_TEXTONLY:
|
||||
val = EMPTY
|
||||
else:
|
||||
val = self.dateval[0:4]
|
||||
return val
|
||||
|
||||
def get_stop_date(self):
|
||||
"""
|
||||
Returns a tuple representing the second half of a compound date.
|
||||
If the date is not a compound date, (including text strings) a tuple
|
||||
of (0,0,0,False) is returned. Otherwise, a date of (DD,MM,YY,slash)
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.modifier == MOD_RANGE or self.modifier == MOD_SPAN:
|
||||
val = self.dateval[4:8]
|
||||
else:
|
||||
val = EMPTY
|
||||
return val
|
||||
|
||||
def _get_low_item(self,index):
|
||||
if self.modifier == MOD_TEXTONLY:
|
||||
val = 0
|
||||
else:
|
||||
val = self.dateval[index]
|
||||
return val
|
||||
|
||||
def _get_low_item_valid(self,index):
|
||||
if self.modifier == MOD_TEXTONLY:
|
||||
val = False
|
||||
else:
|
||||
val = self.dateval[index] != 0
|
||||
return val
|
||||
|
||||
def _get_high_item(self,index):
|
||||
if self.modifier == MOD_SPAN or self.modifier == MOD_RANGE:
|
||||
val = self.dateval[index]
|
||||
else:
|
||||
val = 0
|
||||
return val
|
||||
|
||||
def get_year(self):
|
||||
"""
|
||||
Returns the year associated with the date. If the year is
|
||||
not defined, a zero is returned. If the date is a compound
|
||||
date, the lower date year is returned.
|
||||
"""
|
||||
return self._get_low_item(_POS_YR)
|
||||
|
||||
def set_year(self,year):
|
||||
"""
|
||||
"""
|
||||
self.dateval = self.dateval[0:2] + (year,) + self.dateval[3:]
|
||||
self.calc_sort_value()
|
||||
|
||||
def get_year_valid(self):
|
||||
return self._get_low_item_valid(_POS_YR)
|
||||
|
||||
def get_month(self):
|
||||
"""
|
||||
Returns the month associated with the date. If the month is
|
||||
not defined, a zero is returned. If the date is a compound
|
||||
date, the lower date month is returned.
|
||||
"""
|
||||
return self._get_low_item(_POS_MON)
|
||||
|
||||
def get_month_valid(self):
|
||||
return self._get_low_item_valid(_POS_MON)
|
||||
|
||||
def get_day(self):
|
||||
"""
|
||||
Returns the day of the month associated with the date. If
|
||||
the day is not defined, a zero is returned. If the date is
|
||||
a compound date, the lower date day is returned.
|
||||
"""
|
||||
return self._get_low_item(_POS_DAY)
|
||||
|
||||
def get_day_valid(self):
|
||||
return self._get_low_item_valid(_POS_DAY)
|
||||
|
||||
def get_valid(self):
|
||||
""" Returns true if any part of the date is valid"""
|
||||
return self.modifier != MOD_TEXTONLY
|
||||
|
||||
def get_incomplete(self):
|
||||
pass
|
||||
|
||||
def get_stop_year(self):
|
||||
"""
|
||||
Returns the day of the year associated with the second
|
||||
part of a compound date. If the year is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(_POS_RYR)
|
||||
|
||||
def get_stop_month(self):
|
||||
"""
|
||||
Returns the month of the month associated with the second
|
||||
part of a compound date. If the month is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(_POS_RMON)
|
||||
|
||||
def get_stop_day(self):
|
||||
"""
|
||||
Returns the day of the month associated with the second
|
||||
part of a compound date. If the day is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(_POS_RDAY)
|
||||
|
||||
def get_high_year(self):
|
||||
"""
|
||||
Returns the high year estimate. For compound dates with non-zero
|
||||
stop year, the stop year is returned. Otherwise, the start year
|
||||
is returned.
|
||||
"""
|
||||
if self.is_compound():
|
||||
ret = self.get_stop_year()
|
||||
if ret:
|
||||
return ret
|
||||
else:
|
||||
return self.get_year()
|
||||
|
||||
def get_text(self):
|
||||
"""
|
||||
Returns the text value associated with an invalid date.
|
||||
"""
|
||||
return self.text
|
||||
|
||||
def set(self,quality,modifier,calendar,value,text=None):
|
||||
"""
|
||||
Sets the date to the specified value. Parameters are::
|
||||
|
||||
quality - The date quality for the date (see get_quality
|
||||
for more information)
|
||||
modified - The date modifier for the date (see get_modifier
|
||||
for more information)
|
||||
calendar - The calendar associated with the date (see
|
||||
get_calendar for more information).
|
||||
value - A tuple representing the date information. For a
|
||||
non-compound date, the format is (DD,MM,YY,slash)
|
||||
and for a compound date the tuple stores data as
|
||||
(DD,MM,YY,slash1,DD,MM,YY,slash2)
|
||||
text - A text string holding either the verbatim user input
|
||||
or a comment relating to the date.
|
||||
|
||||
The sort value is recalculated.
|
||||
"""
|
||||
|
||||
if modifier in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT) and len(value) < 4:
|
||||
raise DateError("Invalid value. Should be: (DD,MM,YY,slash)")
|
||||
if modifier in (MOD_RANGE,MOD_SPAN) and len(value) < 8:
|
||||
raise DateError("Invalid value. Should be: (DD,MM,YY,slash1,DD,MM,YY,slash2)")
|
||||
if modifier not in (MOD_NONE,MOD_BEFORE,MOD_AFTER,MOD_ABOUT,MOD_RANGE,MOD_SPAN,MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
if quality not in (QUAL_NONE,QUAL_ESTIMATED,QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
if calendar not in (CAL_GREGORIAN,CAL_JULIAN,CAL_HEBREW,CAL_FRENCH,CAL_PERSIAN,CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
|
||||
self.quality = quality
|
||||
self.modifier = modifier
|
||||
self.calendar = calendar
|
||||
self.dateval = value
|
||||
year = max(value[_POS_YR],1)
|
||||
month = max(value[_POS_MON],1)
|
||||
day = max(value[_POS_DAY],1)
|
||||
if year == 0 and month == 0 and day == 0:
|
||||
self.sortval = 0
|
||||
else:
|
||||
self.sortval = _calendar_convert[calendar](year,month,day)
|
||||
if text:
|
||||
self.text = text
|
||||
|
||||
def calc_sort_value(self):
|
||||
year = max(self.dateval[_POS_YR],1)
|
||||
month = max(self.dateval[_POS_MON],1)
|
||||
day = max(self.dateval[_POS_DAY],1)
|
||||
if year == 0 and month == 0 and day == 0:
|
||||
self.sortval = 0
|
||||
else:
|
||||
self.sortval = _calendar_convert[self.calendar](year,month,day)
|
||||
|
||||
def convert_calendar(self,calendar):
|
||||
"""
|
||||
Converts the date from the current calendar to the specified
|
||||
calendar.
|
||||
"""
|
||||
if calendar == self.calendar:
|
||||
return
|
||||
(y,m,d) = _calendar_change[calendar](self.sortval)
|
||||
if self.is_compound():
|
||||
ry = max(self.dateval[_POS_RYR],1)
|
||||
rm = max(self.dateval[_POS_RMON],1)
|
||||
rd = max(self.dateval[_POS_RDAY],1)
|
||||
sdn = _calendar_convert[self.calendar](ry,rm,rd)
|
||||
(ny,nm,nd) = _calendar_change[calendar](sdn)
|
||||
self.dateval = (d,m,y,self.dateval[_POS_SL],
|
||||
nd,nm,ny,self.dateval[_POS_RSL])
|
||||
else:
|
||||
self.dateval = (d,m,y,self.dateval[_POS_SL])
|
||||
self.calendar = calendar
|
||||
|
||||
def set_as_text(self,text):
|
||||
"""
|
||||
Sets the day to a text string, and assigns the sort value
|
||||
to zero.
|
||||
"""
|
||||
self.modifier = MOD_TEXTONLY
|
||||
self.text = text
|
||||
self.sortval = 0
|
||||
|
||||
def set_text_value(self,text):
|
||||
"""
|
||||
Sets the text string to a given text.
|
||||
"""
|
||||
self.text = text
|
||||
|
||||
def is_empty(self):
|
||||
"""
|
||||
Returns True if the date contains no information (empty text).
|
||||
"""
|
||||
return (self.modifier == MOD_TEXTONLY and not self.text) or \
|
||||
(self.get_start_date()==EMPTY and self.get_stop_date()==EMPTY)
|
||||
|
||||
def is_compound(self):
|
||||
"""
|
||||
Returns True if the date is a date range or a date span.
|
||||
"""
|
||||
return self.modifier == MOD_RANGE or self.modifier == MOD_SPAN
|
||||
|
||||
def is_regular(self):
|
||||
"""
|
||||
Returns True if the date is a regular date.
|
||||
|
||||
The regular date is a single exact date, i.e. not text-only, not
|
||||
a range or a span, not estimated/calculated, not about/before/after
|
||||
date, and having year, month, and day all non-zero.
|
||||
"""
|
||||
return self.modifier == MOD_NONE and self.quality == QUAL_NONE\
|
||||
and self.get_year_valid() and self.get_month_valid()\
|
||||
and self.get_day_valid()
|
||||
# FIXME: this module is only needed to to enable db upgrade
|
||||
from RelLib import Date
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -28,9 +28,8 @@ localized tasks.
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
import Date
|
||||
from gettext import gettext as _
|
||||
|
||||
from RelLib import Date
|
||||
import GrampsLocale
|
||||
|
||||
class DateDisplay:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2005 Donald N. Allingham
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -58,7 +58,7 @@ import gtk.glade
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
import DateHandler
|
||||
import const
|
||||
import Utils
|
||||
@ -130,11 +130,16 @@ class DateEdit:
|
||||
Check current date object and display LED indicating the validity.
|
||||
"""
|
||||
if self.date_obj.get_modifier() == Date.MOD_TEXTONLY:
|
||||
self.pixmap_obj.set_from_pixbuf(self.pixmap_obj.render_icon(gtk.STOCK_DIALOG_ERROR,gtk.ICON_SIZE_MENU))
|
||||
self.pixmap_obj.set_from_pixbuf(
|
||||
self.pixmap_obj.render_icon(gtk.STOCK_DIALOG_ERROR,
|
||||
gtk.ICON_SIZE_MENU))
|
||||
elif self.date_obj.is_regular():
|
||||
self.pixmap_obj.set_from_pixbuf(self.pixmap_obj.render_icon(gtk.STOCK_YES,gtk.ICON_SIZE_MENU))
|
||||
self.pixmap_obj.set_from_pixbuf(
|
||||
self.pixmap_obj.render_icon(gtk.STOCK_YES,gtk.ICON_SIZE_MENU))
|
||||
else:
|
||||
self.pixmap_obj.set_from_pixbuf(self.pixmap_obj.render_icon(gtk.STOCK_DIALOG_WARNING,gtk.ICON_SIZE_MENU))
|
||||
self.pixmap_obj.set_from_pixbuf(
|
||||
self.pixmap_obj.render_icon(gtk.STOCK_DIALOG_WARNING,
|
||||
gtk.ICON_SIZE_MENU))
|
||||
|
||||
def parse_and_check(self,obj,val):
|
||||
"""
|
||||
@ -185,7 +190,7 @@ class DateEditorDialog:
|
||||
"""
|
||||
|
||||
# Create self.date as a copy of the given Date object.
|
||||
self.date = Date.Date(date)
|
||||
self.date = Date(date)
|
||||
|
||||
self.top = gtk.glade.XML(const.gladeFile, "date_edit","gramps" )
|
||||
self.top_window = self.top.get_widget('date_edit')
|
||||
@ -194,7 +199,7 @@ class DateEditorDialog:
|
||||
Utils.set_titles(self.top_window,title,_('Date selection'))
|
||||
|
||||
self.calendar_box = self.top.get_widget('calendar_box')
|
||||
for name in Date.Date.ui_calendar_names:
|
||||
for name in Date.ui_calendar_names:
|
||||
self.calendar_box.append_text(name)
|
||||
self.calendar_box.set_active(self.date.get_calendar())
|
||||
self.calendar_box.connect('changed',self.switch_calendar)
|
||||
@ -263,7 +268,7 @@ class DateEditorDialog:
|
||||
elif response == gtk.RESPONSE_OK:
|
||||
(the_quality,the_modifier,the_calendar,the_value,the_text) = \
|
||||
self.build_date_from_ui()
|
||||
self.return_date = Date.Date(self.date)
|
||||
self.return_date = Date(self.date)
|
||||
self.return_date.set(
|
||||
quality=the_quality,
|
||||
modifier=the_modifier,
|
||||
@ -293,7 +298,7 @@ class DateEditorDialog:
|
||||
|
||||
if modifier == Date.MOD_TEXTONLY:
|
||||
return (Date.QUAL_NONE,Date.MOD_TEXTONLY,Date.CAL_GREGORIAN,
|
||||
Date.EMPTY,text)
|
||||
Date.EMPTY,text)
|
||||
|
||||
quality = QUAL_TEXT[self.quality_box.get_active()][0]
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -42,9 +42,9 @@ import calendar
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date, DateError
|
||||
import GrampsLocale
|
||||
from Errors import DateError
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Top-level module functions
|
||||
@ -497,7 +497,8 @@ class DateParser:
|
||||
if match:
|
||||
grps = match.groups()
|
||||
start = self._parse_subdate(grps[0])
|
||||
mod = self.modifier_after_to_int.get(grps[1].lower(),Date.MOD_NONE)
|
||||
mod = self.modifier_after_to_int.get(grps[1].lower(),
|
||||
Date.MOD_NONE)
|
||||
if bc:
|
||||
date.set(qual,mod,cal,self.invert_year(start))
|
||||
else:
|
||||
@ -558,7 +559,7 @@ class DateParser:
|
||||
"""
|
||||
Parses the text, returning a Date object.
|
||||
"""
|
||||
new_date = Date.Date()
|
||||
new_date = Date()
|
||||
try:
|
||||
self.set_date(new_date,text)
|
||||
except DateError:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import RelLib
|
||||
import GrampsMime
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import Date
|
||||
import ImgManip
|
||||
import DisplayState
|
||||
import GrampsDisplay
|
||||
@ -89,11 +88,11 @@ class EditMedia(DisplayState.ManagedWindow):
|
||||
self.db = self.state.db
|
||||
self.idle = None
|
||||
if obj:
|
||||
self.date_object = Date.Date(self.obj.get_date_object())
|
||||
self.date_object = RelLib.Date(self.obj.get_date_object())
|
||||
self.alist = self.obj.get_attribute_list()[:]
|
||||
self.refs = 0
|
||||
else:
|
||||
self.date_object = Date.Date()
|
||||
self.date_object = RelLib.Date()
|
||||
self.alist = []
|
||||
self.refs = 1
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -33,15 +33,6 @@ class FilterError(Exception):
|
||||
def messages(self):
|
||||
return (self.value,self.value2)
|
||||
|
||||
class DateError(Exception):
|
||||
"""Error used to report Date errors"""
|
||||
def __init__(self,value=""):
|
||||
Exception.__init__(self)
|
||||
self.value = value
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
class DatabaseError(Exception):
|
||||
"""Error used to report Date errors"""
|
||||
def __init__(self,value=""):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -49,7 +49,6 @@ import const
|
||||
import Utils
|
||||
import AutoComp
|
||||
import RelLib
|
||||
import Date
|
||||
from DateHandler import parser as _dp, displayer as _dd
|
||||
import DateEdit
|
||||
import GrampsDisplay
|
||||
@ -122,10 +121,10 @@ class EventEditor(DisplayState.ManagedWindow):
|
||||
|
||||
if event:
|
||||
self.srcreflist = self.event.get_source_references()
|
||||
self.date = Date.Date(self.event.get_date_object())
|
||||
self.date = RelLib.Date(self.event.get_date_object())
|
||||
else:
|
||||
self.srcreflist = []
|
||||
self.date = Date.Date(None)
|
||||
self.date = RelLib.Date(None)
|
||||
|
||||
self.top = gtk.glade.XML(const.gladeFile, "event_edit","gramps")
|
||||
self.gladeif = GladeIf(self.top)
|
||||
@ -454,7 +453,7 @@ class EventRefEditor(DisplayState.ManagedWindow):
|
||||
|
||||
if self.event:
|
||||
self.event_added = False
|
||||
self.date = Date.Date(self.event.get_date_object())
|
||||
self.date = RelLib.Date(self.event.get_date_object())
|
||||
if self.event_ref:
|
||||
if self.event_ref.get_role()[0] == default_role:
|
||||
self.expander.set_expanded(True)
|
||||
@ -468,7 +467,7 @@ class EventRefEditor(DisplayState.ManagedWindow):
|
||||
self.event.set_handle(self.db.create_id())
|
||||
self.event.set_gramps_id(self.db.find_next_event_gramps_id())
|
||||
self.event_added = True
|
||||
self.date = Date.Date(None)
|
||||
self.date = RelLib.Date(None)
|
||||
self.expander.set_expanded(True)
|
||||
self.warning.hide()
|
||||
|
||||
|
@ -54,7 +54,6 @@ import gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import RelLib
|
||||
import Date
|
||||
import DateHandler
|
||||
import NameDisplay
|
||||
from TransUtils import strip_context as __
|
||||
@ -71,9 +70,9 @@ def date_cmp(rule,value):
|
||||
od = value.get_start_date()
|
||||
cmp_rule = (sd[2],sd[1],sd[0])
|
||||
cmp_value = (od[2],od[1],od[0])
|
||||
if s == Date.MOD_BEFORE:
|
||||
if s == RelLib.Date.MOD_BEFORE:
|
||||
return cmp_rule > cmp_value
|
||||
elif s == Date.MOD_AFTER:
|
||||
elif s == RelLib.Date.MOD_AFTER:
|
||||
return cmp_rule < cmp_value
|
||||
else:
|
||||
return cmp_rule == cmp_value
|
||||
|
@ -59,7 +59,7 @@ _MINVERSION = 5
|
||||
_DBVERSION = 9
|
||||
|
||||
def find_surname(key,data):
|
||||
return str(data[3].surname)
|
||||
return str(data[3][3])
|
||||
|
||||
def find_idmap(key,data):
|
||||
return str(data[1])
|
||||
@ -980,7 +980,7 @@ class GrampsBSDDB(GrampsDbBase):
|
||||
self.env.txn_checkpoint()
|
||||
self.env.set_flags(db.DB_TXN_NOSYNC,1) # async txn
|
||||
|
||||
if not transaction.no_magic:
|
||||
if self.secondary_connected and not transaction.no_magic:
|
||||
# Disconnect unneeded secondary indices
|
||||
self.surnames.close()
|
||||
junk = db.DB(self.env)
|
||||
|
@ -395,7 +395,7 @@ class GrampsDbBase(GrampsDBCallback):
|
||||
if old_data:
|
||||
old_person = Person(old_data)
|
||||
if (old_data[2] != person.gender or
|
||||
old_data[3].first_name != person.primary_name.first_name):
|
||||
old_data[3][2]!= person.primary_name.first_name):
|
||||
self.genderStats.uncount_person(old_person)
|
||||
self.genderStats.count_person(person,self)
|
||||
else:
|
||||
|
@ -58,7 +58,6 @@ import gtk.glade
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import RelLib
|
||||
import Date
|
||||
import DateParser
|
||||
import NameDisplay
|
||||
import DisplayTrace
|
||||
@ -1856,7 +1855,7 @@ class GedcomParser:
|
||||
return None
|
||||
|
||||
def extract_date(self,text):
|
||||
dateobj = Date.Date()
|
||||
dateobj = RelLib.Date()
|
||||
try:
|
||||
match = rangeRegexp.match(text)
|
||||
if match:
|
||||
@ -1865,17 +1864,17 @@ class GedcomParser:
|
||||
pass
|
||||
|
||||
if cal1 == "FRENCH R":
|
||||
cal = Date.CAL_FRENCH
|
||||
cal = RelLib.Date.CAL_FRENCH
|
||||
elif cal1 == "JULIAN":
|
||||
cal = Date.CAL_JULIAN
|
||||
cal = RelLib.Date.CAL_JULIAN
|
||||
elif cal1 == "HEBREW":
|
||||
cal = Date.CAL_HEBREW
|
||||
cal = RelLib.Date.CAL_HEBREW
|
||||
else:
|
||||
cal = Date.CAL_GREGORIAN
|
||||
cal = RelLib.Date.CAL_GREGORIAN
|
||||
|
||||
start = self.dp.parse(data1)
|
||||
stop = self.dp.parse(data2)
|
||||
dateobj.set(Date.QUAL_NONE, Date.MOD_RANGE, cal,
|
||||
dateobj.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_RANGE, cal,
|
||||
start.get_start_date() + stop.get_start_date())
|
||||
return dateobj
|
||||
|
||||
@ -1886,17 +1885,17 @@ class GedcomParser:
|
||||
pass
|
||||
|
||||
if cal1 == "FRENCH R":
|
||||
cal = Date.CAL_FRENCH
|
||||
cal = RelLib.Date.CAL_FRENCH
|
||||
elif cal1 == "JULIAN":
|
||||
cal = Date.CAL_JULIAN
|
||||
cal = RelLib.Date.CAL_JULIAN
|
||||
elif cal1 == "HEBREW":
|
||||
cal = Date.CAL_HEBREW
|
||||
cal = RelLib.Date.CAL_HEBREW
|
||||
else:
|
||||
cal = Date.CAL_GREGORIAN
|
||||
cal = RelLib.Date.CAL_GREGORIAN
|
||||
|
||||
start = self.dp.parse(data1)
|
||||
stop = self.dp.parse(data2)
|
||||
dateobj.set(Date.QUAL_NONE, Date.MOD_SPAN, cal,
|
||||
dateobj.set(RelLib.Date.QUAL_NONE, RelLib.Date.MOD_SPAN, cal,
|
||||
start.get_start_date() + stop.get_start_date())
|
||||
return dateobj
|
||||
|
||||
@ -1905,11 +1904,11 @@ class GedcomParser:
|
||||
(abt,cal,data) = match.groups()
|
||||
dateobj = self.dp.parse("%s %s" % (abt, data))
|
||||
if cal == "FRENCH R":
|
||||
dateobj.set_calendar(Date.CAL_FRENCH)
|
||||
dateobj.set_calendar(RelLib.Date.CAL_FRENCH)
|
||||
elif cal == "JULIAN":
|
||||
dateobj.set_calendar(Date.CAL_JULIAN)
|
||||
dateobj.set_calendar(RelLib.Date.CAL_JULIAN)
|
||||
elif cal == "HEBREW":
|
||||
dateobj.set_calendar(Date.CAL_HEBREW)
|
||||
dateobj.set_calendar(RelLib.Date.CAL_HEBREW)
|
||||
return dateobj
|
||||
else:
|
||||
dval = self.dp.parse(text)
|
||||
@ -2384,7 +2383,7 @@ def create_id():
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
import hotshot, hotshot.stats
|
||||
import hotshot#, hotshot.stats
|
||||
import const
|
||||
from GrampsDb import gramps_db_factory, gramps_db_reader_factory
|
||||
|
||||
@ -2397,7 +2396,7 @@ if __name__ == "__main__":
|
||||
database = db_class()
|
||||
database.load("test.grdb",lambda x: None, mode="w")
|
||||
np = NoteParser(sys.argv[1],False)
|
||||
g = GedcomParser(database,sys.argv[1],callback, codeset, np.get_map(),np.get_lines())
|
||||
g = GedcomParser(database,sys.argv[1],callback, codeset, np.get_map(),np.get_lines(),np.get_persons())
|
||||
|
||||
if False:
|
||||
pr = hotshot.Profile('mystats.profile')
|
||||
@ -2405,12 +2404,12 @@ if __name__ == "__main__":
|
||||
pr.runcall(g.parse_gedcom_file,False)
|
||||
print "Finished"
|
||||
pr.close()
|
||||
print "Loading profile"
|
||||
stats = hotshot.stats.load('mystats.profile')
|
||||
print "done"
|
||||
stats.strip_dirs()
|
||||
stats.sort_stats('time','calls')
|
||||
stats.print_stats(100)
|
||||
## print "Loading profile"
|
||||
## stats = hotshot.stats.load('mystats.profile')
|
||||
## print "done"
|
||||
## stats.strip_dirs()
|
||||
## stats.sort_stats('time','calls')
|
||||
## stats.print_stats(100)
|
||||
else:
|
||||
import time
|
||||
t = time.time()
|
||||
|
@ -45,7 +45,6 @@ import gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from QuestionDialog import ErrorDialog, WarningDialog, MissingMediaDialog
|
||||
import Date
|
||||
import GrampsMime
|
||||
import RelLib
|
||||
import const
|
||||
@ -1144,22 +1143,22 @@ class GrampsParser:
|
||||
rd = 0
|
||||
|
||||
if attrs.has_key("cformat"):
|
||||
cal = Date.Date.calendar.index(attrs['calendar'])
|
||||
cal = RelLib.Date.calendar.index(attrs['calendar'])
|
||||
else:
|
||||
cal = Date.CAL_GREGORIAN
|
||||
cal = RelLib.Date.CAL_GREGORIAN
|
||||
|
||||
if attrs.has_key('quality'):
|
||||
val = attrs['quality']
|
||||
if val == 'estimated':
|
||||
qual = Date.QUAL_ESTIMATED
|
||||
qual = RelLib.Date.QUAL_ESTIMATED
|
||||
elif val == 'calculated':
|
||||
qual = Date.QUAL_CALCULATED
|
||||
qual = RelLib.Date.QUAL_CALCULATED
|
||||
else:
|
||||
qual = Date.QUAL_NONE
|
||||
qual = RelLib.Date.QUAL_NONE
|
||||
else:
|
||||
qual = Date.QUAL_NONE
|
||||
qual = RelLib.Date.QUAL_NONE
|
||||
|
||||
dv.set(qual,Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False))
|
||||
dv.set(qual,RelLib.Date.MOD_RANGE,cal,(d,m,y,False,rd,rm,ry,False))
|
||||
|
||||
def start_dateval(self,attrs):
|
||||
if self.source_ref:
|
||||
@ -1197,31 +1196,31 @@ class GrampsParser:
|
||||
d = 0
|
||||
|
||||
if attrs.has_key("cformat"):
|
||||
cal = Date.Date.calendar_names.index(attrs['cformat'])
|
||||
cal = RelLib.Date.calendar_names.index(attrs['cformat'])
|
||||
else:
|
||||
cal = Date.CAL_GREGORIAN
|
||||
cal = RelLib.Date.CAL_GREGORIAN
|
||||
|
||||
if attrs.has_key('type'):
|
||||
val = attrs['type']
|
||||
if val == "about":
|
||||
mod = Date.MOD_ABOUT
|
||||
mod = RelLib.Date.MOD_ABOUT
|
||||
elif val == "after":
|
||||
mod = Date.MOD_AFTER
|
||||
mod = RelLib.Date.MOD_AFTER
|
||||
else:
|
||||
mod = Date.MOD_BEFORE
|
||||
mod = RelLib.Date.MOD_BEFORE
|
||||
else:
|
||||
mod = Date.MOD_NONE
|
||||
mod = RelLib.Date.MOD_NONE
|
||||
|
||||
if attrs.has_key('quality'):
|
||||
val = attrs['quality']
|
||||
if val == 'estimated':
|
||||
qual = Date.QUAL_ESTIMATED
|
||||
qual = RelLib.Date.QUAL_ESTIMATED
|
||||
elif val == 'calculated':
|
||||
qual = Date.QUAL_CALCULATED
|
||||
qual = RelLib.Date.QUAL_CALCULATED
|
||||
else:
|
||||
qual = Date.QUAL_NONE
|
||||
qual = RelLib.Date.QUAL_NONE
|
||||
else:
|
||||
qual = Date.QUAL_NONE
|
||||
qual = RelLib.Date.QUAL_NONE
|
||||
|
||||
dv.set(qual,mod,cal,(d,m,y,False))
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -48,7 +48,6 @@ import gtk.glade
|
||||
import RelLib
|
||||
import GenericFilter
|
||||
import const
|
||||
import Date
|
||||
import _GedcomInfo as GedcomInfo
|
||||
import Errors
|
||||
import ansel_utf8
|
||||
@ -81,15 +80,15 @@ _month = [
|
||||
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
|
||||
|
||||
_calmap = {
|
||||
Date.CAL_HEBREW : (_hmonth, '@#HEBREW@'),
|
||||
Date.CAL_FRENCH : (_fmonth, '@#FRENCH R@'),
|
||||
Date.CAL_JULIAN : (_month, '@#JULIAN@'),
|
||||
RelLib.Date.CAL_HEBREW : (_hmonth, '@#HEBREW@'),
|
||||
RelLib.Date.CAL_FRENCH : (_fmonth, '@#FRENCH R@'),
|
||||
RelLib.Date.CAL_JULIAN : (_month, '@#JULIAN@'),
|
||||
}
|
||||
|
||||
_caldef = {
|
||||
Date.MOD_ABOUT : "ABT",
|
||||
Date.MOD_BEFORE : "BEF",
|
||||
Date.MOD_AFTER : "AFT",
|
||||
RelLib.Date.MOD_ABOUT : "ABT",
|
||||
RelLib.Date.MOD_BEFORE : "BEF",
|
||||
RelLib.Date.MOD_AFTER : "AFT",
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -1142,13 +1141,13 @@ class GedcomWriter:
|
||||
|
||||
def print_date(self,prefix,date):
|
||||
start = date.get_start_date()
|
||||
if start != Date.EMPTY:
|
||||
if start != RelLib.Date.EMPTY:
|
||||
cal = date.get_calendar()
|
||||
mod = date.get_modifier()
|
||||
if date.get_modifier() == Date.MOD_SPAN:
|
||||
if date.get_modifier() == RelLib.Date.MOD_SPAN:
|
||||
val = "FROM %s TO %s" % (make_date(start,cal,mod),
|
||||
make_date(date.get_stop_date(),cal,mod))
|
||||
elif date.get_modifier() == Date.MOD_RANGE:
|
||||
elif date.get_modifier() == RelLib.Date.MOD_RANGE:
|
||||
val = "BET %s AND %s" % (make_date(start,cal,mod),
|
||||
make_date(date.get_stop_date(),cal,mod))
|
||||
else:
|
||||
|
@ -50,7 +50,6 @@ import gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import RelLib
|
||||
import Date
|
||||
from QuestionDialog import ErrorDialog
|
||||
import _ConstXML
|
||||
from _GrampsDbBase import \
|
||||
@ -90,7 +89,9 @@ def exportData(database, filename, person, callback=None):
|
||||
|
||||
try:
|
||||
g = XmlWriter(database,callback,0,compress)
|
||||
t = time.time()
|
||||
ret = g.write(filename)
|
||||
print time.time()-t
|
||||
except:
|
||||
import DisplayTrace
|
||||
|
||||
@ -678,15 +679,15 @@ class XmlWriter:
|
||||
sp = ' '*indent
|
||||
|
||||
cal= date.get_calendar()
|
||||
if cal != Date.CAL_GREGORIAN:
|
||||
calstr = ' cformat="%s"' % Date.Date.calendar_names[cal]
|
||||
if cal != RelLib.Date.CAL_GREGORIAN:
|
||||
calstr = ' cformat="%s"' % RelLib.Date.calendar_names[cal]
|
||||
else:
|
||||
calstr = ''
|
||||
|
||||
qual = date.get_quality()
|
||||
if qual == Date.QUAL_ESTIMATED:
|
||||
if qual == RelLib.Date.QUAL_ESTIMATED:
|
||||
qual_str = ' quality="estimated"'
|
||||
elif qual == Date.QUAL_CALCULATED:
|
||||
elif qual == RelLib.Date.QUAL_CALCULATED:
|
||||
qual_str = ' quality="calculated"'
|
||||
else:
|
||||
qual_str = ""
|
||||
@ -699,16 +700,16 @@ class XmlWriter:
|
||||
if d1 != "" or d2 != "":
|
||||
self.g.write('%s<daterange start="%s" stop="%s"%s%s/>\n'
|
||||
% (sp,d1,d2,qual_str,calstr))
|
||||
elif mode != Date.MOD_TEXTONLY:
|
||||
elif mode != RelLib.Date.MOD_TEXTONLY:
|
||||
date_str = self.get_iso_date(date.get_start_date())
|
||||
if date_str == "":
|
||||
return
|
||||
|
||||
if mode == Date.MOD_BEFORE:
|
||||
if mode == RelLib.Date.MOD_BEFORE:
|
||||
mode_str = ' type="before"'
|
||||
elif mode == Date.MOD_AFTER:
|
||||
elif mode == RelLib.Date.MOD_AFTER:
|
||||
mode_str = ' type="after"'
|
||||
elif mode == Date.MOD_ABOUT:
|
||||
elif mode == RelLib.Date.MOD_ABOUT:
|
||||
mode_str = ' type="about"'
|
||||
else:
|
||||
mode_str = ""
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -57,7 +57,6 @@ import GrampsMime
|
||||
import Sources
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import Date
|
||||
import ImgManip
|
||||
import Spell
|
||||
import DisplayState
|
||||
@ -970,11 +969,11 @@ class GlobalMediaProperties(DisplayState.ManagedWindow):
|
||||
self.db = self.state.db
|
||||
self.idle = None
|
||||
if obj:
|
||||
self.date_object = Date.Date(self.obj.get_date_object())
|
||||
self.date_object = RelLib.Date(self.obj.get_date_object())
|
||||
self.alist = self.obj.get_attribute_list()[:]
|
||||
self.refs = 0
|
||||
else:
|
||||
self.date_object = Date.Date()
|
||||
self.date_object = RelLib.Date()
|
||||
self.alist = []
|
||||
self.refs = 1
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modiy
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -56,7 +56,6 @@ import DateHandler
|
||||
import Sources
|
||||
import GrampsKeys
|
||||
import NameDisplay
|
||||
import Date
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import Spell
|
||||
@ -240,7 +239,7 @@ class Marriage:
|
||||
lds_ord = self.family.get_lds_sealing()
|
||||
self.seal_stat = 0
|
||||
|
||||
self.lds_date_object = Date.Date()
|
||||
self.lds_date_object = RelLib.Date()
|
||||
if GrampsKeys.get_uselds() or lds_ord:
|
||||
if lds_ord:
|
||||
place_handle = lds_ord.get_place_handle()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import AutoComp
|
||||
import Sources
|
||||
import RelLib
|
||||
import NameDisplay
|
||||
import Date
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import Spell
|
||||
@ -101,7 +100,7 @@ class NameEditor(DisplayState.ManagedWindow):
|
||||
self.date_obj = self.name.get_date_object()
|
||||
else:
|
||||
self.srcreflist = []
|
||||
self.date_obj = Date.Date()
|
||||
self.date_obj = RelLib.Date()
|
||||
self.name = RelLib.Name()
|
||||
|
||||
self.date.set_text(DateHandler.displayer.display(self.date_obj))
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -158,7 +158,8 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
while node:
|
||||
n,d = node
|
||||
if n in flist:
|
||||
primary_name = d[_NAME_COL]
|
||||
primary_name = Name()
|
||||
primary_name.unserialize(d[_NAME_COL])
|
||||
surname = ngn(self.db,primary_name)
|
||||
self.sortnames[n] = nsn(primary_name)
|
||||
try:
|
||||
@ -307,7 +308,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return None
|
||||
|
||||
def column_sort_name(self,data,node):
|
||||
return data[_NAME_COL].get_sort_name()
|
||||
n = Name()
|
||||
n.unserialize(data[_NAME_COL])
|
||||
return n.get_sort_name()
|
||||
|
||||
def column_spouse(self,data,node):
|
||||
spouses_names = u""
|
||||
@ -326,7 +329,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return spouses_names
|
||||
|
||||
def column_name(self,data,node):
|
||||
return NameDisplay.displayer.sorted_name(data[_NAME_COL])
|
||||
n = Name()
|
||||
n.unserialize(data[_NAME_COL])
|
||||
return NameDisplay.displayer.sorted_name(n)
|
||||
|
||||
def column_id(self,data,node):
|
||||
return data[_ID_COL]
|
||||
@ -340,13 +345,17 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_birth_day(self,data,node):
|
||||
if data[_BIRTH_COL]:
|
||||
birth = self.db.get_event_from_handle(data[_BIRTH_COL].ref)
|
||||
b=EventRef()
|
||||
b.unserialize(data[_BIRTH_COL])
|
||||
birth = self.db.get_event_from_handle(b.ref)
|
||||
date_str = DateHandler.get_date(birth)
|
||||
if date_str != "":
|
||||
return cgi.escape(date_str)
|
||||
|
||||
for event_ref in data[_EVENT_COL]:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
er = EventRef()
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
date_str = DateHandler.get_date(event)
|
||||
if (etype in [Event.BAPTISM, Event.CHRISTEN]
|
||||
@ -357,13 +366,17 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_death_day(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
death = self.db.get_event_from_handle(data[_DEATH_COL].ref)
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
death = self.db.get_event_from_handle(dr.ref)
|
||||
date_str = DateHandler.get_date(death)
|
||||
if date_str != "":
|
||||
return cgi.escape(date_str)
|
||||
|
||||
for event_ref in data[_EVENT_COL]:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
er = EventRef()
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
date_str = DateHandler.get_date(event)
|
||||
if (etype in [Event.BURIAL, Event.CREMATION]
|
||||
@ -374,13 +387,17 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_cause_of_death(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
return self.db.get_event_from_handle(data[_DEATH_COL].ref).get_cause()
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
return self.db.get_event_from_handle(dr.ref).get_cause()
|
||||
else:
|
||||
return u""
|
||||
|
||||
def column_birth_place(self,data,node):
|
||||
if data[_BIRTH_COL]:
|
||||
event = self.db.get_event_from_handle(data[_BIRTH_COL].ref)
|
||||
br = EventRef()
|
||||
br.unserialize(data[_BIRTH_COL])
|
||||
event = self.db.get_event_from_handle(br.ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
@ -389,7 +406,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return cgi.escape(place_title)
|
||||
|
||||
for event_ref in data[_EVENT_COL]:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
er = EventRef()
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
if etype in [Event.BAPTISM, Event.CHRISTEN]:
|
||||
place_handle = event.get_place_handle()
|
||||
@ -402,7 +421,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
|
||||
def column_death_place(self,data,node):
|
||||
if data[_DEATH_COL]:
|
||||
event = self.db.get_event_from_handle(data[_DEATH_COL].ref)
|
||||
dr = EventRef()
|
||||
dr.unserialize(data[_DEATH_COL])
|
||||
event = self.db.get_event_from_handle(dr.ref)
|
||||
if event:
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
@ -411,7 +432,9 @@ class PeopleModel(gtk.GenericTreeModel):
|
||||
return cgi.escape(place_title)
|
||||
|
||||
for event_ref in data[_EVENT_COL]:
|
||||
event = self.db.get_event_from_handle(event_ref.ref)
|
||||
er = EventRef()
|
||||
er.unserialize(event_ref)
|
||||
event = self.db.get_event_from_handle(er.ref)
|
||||
etype = event.get_type()[0]
|
||||
if etype in [Event.BURIAL, Event.CREMATION]:
|
||||
place_handle = event.get_place_handle()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -53,6 +53,19 @@ class Address(PrivateSourceNote,DateBase,LocationBase):
|
||||
else:
|
||||
self.street = ""
|
||||
|
||||
def serialize(self):
|
||||
return (PrivateSourceNote.serialize(self),
|
||||
DateBase.serialize(self),
|
||||
self.city,self.state,
|
||||
self.country,self.postal,self.phone,self.street)
|
||||
|
||||
def unserialize(self,data):
|
||||
(psn,date,self.city,self.state,
|
||||
self.country,self.postal,self.phone,self.street) = data
|
||||
PrivateSourceNote.unserialize(self,psn)
|
||||
DateBase.unserialize(self,date)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -56,6 +56,12 @@ class AddressBase:
|
||||
else:
|
||||
self.address_list = []
|
||||
|
||||
def serialize(self):
|
||||
return [addr.serialize() for addr in self.address_list]
|
||||
|
||||
def unserialize(self,data):
|
||||
self.address_list = [Address().unserialize(item) for item in data]
|
||||
|
||||
def add_address(self,address):
|
||||
"""
|
||||
Adds the L{Address} instance to the object's list of addresses
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -67,6 +67,15 @@ class Attribute(PrivateSourceNote):
|
||||
self.type = (Attribute.CUSTOM,"")
|
||||
self.value = ""
|
||||
|
||||
def serialize(self):
|
||||
return (PrivateSourceNote.serialize(self),
|
||||
self.type,self.value)
|
||||
|
||||
def unserialize(self,data):
|
||||
(psn,self.type,self.value) = data
|
||||
PrivateSourceNote.unserialize(self,psn)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -56,6 +56,12 @@ class AttributeBase:
|
||||
else:
|
||||
self.attribute_list = []
|
||||
|
||||
def serialize(self):
|
||||
return [attr.serialize() for attr in self.attribute_list]
|
||||
|
||||
def unserialize(self,data):
|
||||
self.attribute_list = [Attribute().unserialize(item) for item in data]
|
||||
|
||||
def add_attribute(self,attribute):
|
||||
"""
|
||||
Adds the L{Attribute} instance to the object's list of attributes
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -48,6 +48,13 @@ class BaseObject:
|
||||
Initialize a BaseObject.
|
||||
"""
|
||||
pass
|
||||
|
||||
def serialize(self):
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
|
||||
def unserialize(self,data):
|
||||
assert False, "Needs to be overridden in the derived class"
|
||||
return self
|
||||
|
||||
def matches_string(self,pattern,case_sensitive=False):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -20,8 +20,18 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
import math
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import cmath
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_GRG_SDN_OFFSET = 32045
|
||||
_GRG_DAYS_PER_5_MONTHS = 153
|
||||
_GRG_DAYS_PER_4_YEARS = 1461
|
||||
@ -73,7 +83,8 @@ def _tishri1(metonic_year, molad_day, molad_halakim):
|
||||
if ((molad_halakim >= _HBR_NOON) or
|
||||
((not leap_year) and dow == _HBR_TUESDAY and
|
||||
molad_halakim >= _HBR_AM3_11_20) or
|
||||
(last_was_leap_year and dow == _HBR_MONDAY and molad_halakim >= _HBR_AM9_32_43)) :
|
||||
(last_was_leap_year and dow == _HBR_MONDAY
|
||||
and molad_halakim >= _HBR_AM9_32_43)) :
|
||||
tishri1 += 1
|
||||
dow += 1
|
||||
if dow == 7:
|
||||
@ -116,8 +127,8 @@ def _tishri_molad(inputDay):
|
||||
if moladDay > inputDay - 74:
|
||||
break
|
||||
|
||||
moladHalakim = moladHalakim + \
|
||||
(_HBR_HALAKIM_PER_LUNAR_CYCLE * _HBR_MONTHS_PER_YEAR[metonicYear])
|
||||
moladHalakim = moladHalakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||
* _HBR_MONTHS_PER_YEAR[metonicYear])
|
||||
moladDay = moladDay + (moladHalakim / _HBR_HALAKIM_PER_DAY)
|
||||
moladHalakim = moladHalakim % _HBR_HALAKIM_PER_DAY
|
||||
else:
|
||||
@ -136,7 +147,7 @@ def _molad_of_metonic_cycle(metonic_cycle):
|
||||
|
||||
r1 = r1 + (metonic_cycle * (_HBR_HALAKIM_PER_METONIC_CYCLE & 0xFFFF))
|
||||
r2 = r1 >> 16
|
||||
r2 = r2 + (metonic_cycle * ((_HBR_HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF))
|
||||
r2 = r2 + (metonic_cycle * ((_HBR_HALAKIM_PER_METONIC_CYCLE >> 16)&0xFFFF))
|
||||
|
||||
# Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1, the
|
||||
# upper 16 bits of the quotient will be in d2 and the lower 16 bits
|
||||
@ -159,7 +170,8 @@ def _start_of_year(year):
|
||||
metonic_year = (year - 1) % 19;
|
||||
(molad_day, molad_halakim) = _molad_of_metonic_cycle(metonic_cycle)
|
||||
|
||||
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE * _HBR_YEAR_OFFSET[metonic_year])
|
||||
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||
* _HBR_YEAR_OFFSET[metonic_year])
|
||||
molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
|
||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||
|
||||
@ -172,7 +184,8 @@ def hebrew_sdn(year, month, day):
|
||||
|
||||
if month == 1 or month == 2:
|
||||
# It is Tishri or Heshvan - don't need the year length.
|
||||
(metonic_cycle,metonic_year,molad_day,molad_halakim,tishri1) = _start_of_year(year)
|
||||
(metonic_cycle,metonic_year,
|
||||
molad_day,molad_halakim,tishri1) = _start_of_year(year)
|
||||
if month == 1:
|
||||
sdn = tishri1 + day - 1
|
||||
else:
|
||||
@ -181,13 +194,16 @@ def hebrew_sdn(year, month, day):
|
||||
# It is Kislev - must find the year length.
|
||||
|
||||
# Find the start of the year.
|
||||
(metonic_cycle,metonic_year,molad_day,molad_halakim,tishri1) = _start_of_year(year)
|
||||
(metonic_cycle,metonic_year,
|
||||
molad_day,molad_halakim,tishri1) = _start_of_year(year)
|
||||
|
||||
# Find the end of the year.
|
||||
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE*_HBR_MONTHS_PER_YEAR[metonic_year])
|
||||
molad_halakim = molad_halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||
*_HBR_MONTHS_PER_YEAR[metonic_year])
|
||||
molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY)
|
||||
molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY
|
||||
tishri1_after = _tishri1((metonic_year + 1) % 19, molad_day, molad_halakim)
|
||||
tishri1_after = _tishri1((metonic_year + 1)
|
||||
% 19, molad_day, molad_halakim)
|
||||
|
||||
year_length = tishri1_after - tishri1
|
||||
|
||||
@ -198,7 +214,8 @@ def hebrew_sdn(year, month, day):
|
||||
elif month == 4 or month == 5 or month == 6:
|
||||
# It is Tevet, Shevat or Adar I - don't need the year length
|
||||
|
||||
(metonic_cycle,metonic_year,molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
|
||||
(metonic_cycle,metonic_year,
|
||||
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
|
||||
|
||||
if _HBR_MONTHS_PER_YEAR[(year - 1) % 19] == 12:
|
||||
length_of_adarI_andII = 29
|
||||
@ -213,7 +230,8 @@ def hebrew_sdn(year, month, day):
|
||||
sdn = tishri1_after + day - length_of_adarI_andII - 178
|
||||
else:
|
||||
# It is Adar II or later - don't need the year length.
|
||||
(metonic_cycle,metonic_year,molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
|
||||
(metonic_cycle,metonic_year,
|
||||
molad_day,molad_halakim,tishri1_after) = _start_of_year(year+1)
|
||||
|
||||
if month == 7:
|
||||
sdn = tishri1_after + day - 207
|
||||
@ -257,7 +275,8 @@ def hebrew_ymd(sdn):
|
||||
# We need the length of the year to figure this out, so find
|
||||
# Tishri 1 of the next year. */
|
||||
|
||||
halakim = halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE * _HBR_MONTHS_PER_YEAR[metonicYear])
|
||||
halakim = halakim + (_HBR_HALAKIM_PER_LUNAR_CYCLE
|
||||
* _HBR_MONTHS_PER_YEAR[metonicYear])
|
||||
day = day + (halakim / _HBR_HALAKIM_PER_DAY)
|
||||
halakim = halakim % _HBR_HALAKIM_PER_DAY;
|
||||
tishri1After = _tishri1((metonicYear + 1) % 19, day, halakim);
|
||||
@ -463,24 +482,24 @@ def persian_sdn(year, month, day):
|
||||
v1 = (month - 1) * 31
|
||||
else:
|
||||
v1 = ((month - 1) * 30) + 6
|
||||
v2 = math.floor(((epyear * 682) - 110) / 2816)
|
||||
v2 = cmath.floor(((epyear * 682) - 110) / 2816)
|
||||
v3 = (epyear - 1) * 365 + day
|
||||
v4 = math.floor(epbase / 2820) * 1029983
|
||||
v4 = cmath.floor(epbase / 2820) * 1029983
|
||||
|
||||
return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
|
||||
return int(cmath.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1))
|
||||
|
||||
def persian_ymd(sdn):
|
||||
sdn = math.floor(sdn) + 0.5
|
||||
sdn = cmath.floor(sdn) + 0.5
|
||||
|
||||
depoch = sdn - 2121446
|
||||
cycle = math.floor(depoch / 1029983)
|
||||
cycle = cmath.floor(depoch / 1029983)
|
||||
cyear = depoch % 1029983
|
||||
if cyear == 1029982:
|
||||
ycycle = 2820
|
||||
else:
|
||||
aux1 = math.floor(cyear / 366)
|
||||
aux1 = cmath.floor(cyear / 366)
|
||||
aux2 = cyear % 366
|
||||
ycycle = math.floor(((2134*aux1)+(2816*aux2)+2815)/1028522) + aux1 + 1;
|
||||
ycycle = cmath.floor(((2134*aux1)+(2816*aux2)+2815)/1028522) + aux1 + 1
|
||||
|
||||
year = ycycle + (2820 * cycle) + 474
|
||||
if year <= 0:
|
||||
@ -488,23 +507,22 @@ def persian_ymd(sdn):
|
||||
|
||||
yday = sdn - persian_sdn(year, 1, 1) + 1
|
||||
if yday < 186:
|
||||
month = math.ceil(yday / 31)
|
||||
month = cmath.ceil(yday / 31)
|
||||
else:
|
||||
month = math.ceil((yday - 6) / 30)
|
||||
month = cmath.ceil((yday - 6) / 30)
|
||||
day = (sdn - persian_sdn(year, month, 1)) + 1
|
||||
return (int(year), int(month), int(day))
|
||||
|
||||
def islamic_sdn(year, month, day):
|
||||
v1 = math.ceil(29.5 * (month - 1))
|
||||
v1 = cmath.ceil(29.5 * (month - 1))
|
||||
v2 = (year - 1) * 354
|
||||
v3 = math.floor((3 + (11 *year)) / 30)
|
||||
v3 = cmath.floor((3 + (11 *year)) / 30)
|
||||
|
||||
return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
|
||||
return int(cmath.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1))
|
||||
|
||||
def islamic_ymd(sdn):
|
||||
sdn = math.floor(sdn) + 0.5
|
||||
year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631))
|
||||
month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year,1,1)))/29.5) + 1))
|
||||
sdn = cmath.floor(sdn) + 0.5
|
||||
year = int(cmath.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631))
|
||||
month = int(min(12, cmath.ceil((sdn-(29+islamic_sdn(year,1,1)))/29.5) + 1))
|
||||
day = int((sdn - islamic_sdn(year,month,1)) + 1)
|
||||
return (year,month,day)
|
||||
|
565
gramps2/src/RelLib/_Date.py
Normal file
565
gramps2/src/RelLib/_Date.py
Normal file
@ -0,0 +1,565 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"Support for dates"
|
||||
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
from gettext import gettext as _
|
||||
from _CalSdn import *
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# DateError exception
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateError(Exception):
|
||||
"""Error used to report Date errors"""
|
||||
def __init__(self,value=""):
|
||||
Exception.__init__(self)
|
||||
self.value = value
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Date class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Date:
|
||||
"""
|
||||
The core date handling class for GRAMPs. Supports partial dates,
|
||||
compound dates and alternate calendars.
|
||||
"""
|
||||
|
||||
MOD_NONE = 0
|
||||
MOD_BEFORE = 1
|
||||
MOD_AFTER = 2
|
||||
MOD_ABOUT = 3
|
||||
MOD_RANGE = 4
|
||||
MOD_SPAN = 5
|
||||
MOD_TEXTONLY = 6
|
||||
|
||||
QUAL_NONE = 0
|
||||
QUAL_ESTIMATED = 1
|
||||
QUAL_CALCULATED= 2
|
||||
|
||||
CAL_GREGORIAN = 0
|
||||
CAL_JULIAN = 1
|
||||
CAL_HEBREW = 2
|
||||
CAL_FRENCH = 3
|
||||
CAL_PERSIAN = 4
|
||||
CAL_ISLAMIC = 5
|
||||
|
||||
EMPTY = (0,0,0,False)
|
||||
|
||||
_POS_DAY = 0
|
||||
_POS_MON = 1
|
||||
_POS_YR = 2
|
||||
_POS_SL = 3
|
||||
_POS_RDAY = 4
|
||||
_POS_RMON = 5
|
||||
_POS_RYR = 6
|
||||
_POS_RSL = 7
|
||||
|
||||
_calendar_convert = [
|
||||
gregorian_sdn,
|
||||
julian_sdn,
|
||||
hebrew_sdn,
|
||||
french_sdn,
|
||||
persian_sdn,
|
||||
islamic_sdn,
|
||||
]
|
||||
|
||||
_calendar_change = [
|
||||
gregorian_ymd,
|
||||
julian_ymd,
|
||||
hebrew_ymd,
|
||||
french_ymd,
|
||||
persian_ymd,
|
||||
islamic_ymd,
|
||||
]
|
||||
|
||||
calendar_names = ["Gregorian",
|
||||
"Julian",
|
||||
"Hebrew",
|
||||
"French Republican",
|
||||
"Persian",
|
||||
"Islamic"]
|
||||
|
||||
|
||||
ui_calendar_names = [_("Gregorian"),
|
||||
_("Julian"),
|
||||
_("Hebrew"),
|
||||
_("French Republican"),
|
||||
_("Persian"),
|
||||
_("Islamic")]
|
||||
|
||||
def __init__(self,source=None):
|
||||
"""
|
||||
Creates a new Date instance.
|
||||
"""
|
||||
if source:
|
||||
self.calendar = source.calendar
|
||||
self.modifier = source.modifier
|
||||
self.quality = source.quality
|
||||
self.dateval = source.dateval
|
||||
self.text = source.text
|
||||
self.sortval = source.sortval
|
||||
else:
|
||||
self.calendar = Date.CAL_GREGORIAN
|
||||
self.modifier = Date.MOD_NONE
|
||||
self.quality = Date.QUAL_NONE
|
||||
self.dateval = Date.EMPTY
|
||||
self.text = u""
|
||||
self.sortval = 0
|
||||
|
||||
def serialize(self):
|
||||
return (self.calendar,self.modifier,self.quality,
|
||||
self.dateval,self.text,self.sortval)
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.calendar,self.modifier,self.quality,
|
||||
self.dateval,self.text,self.sortval) = data
|
||||
return self
|
||||
|
||||
def copy(self,source):
|
||||
"""
|
||||
Copy all the attributes of the given Date instance
|
||||
to the present instance, without creating a new object.
|
||||
"""
|
||||
self.calendar = source.calendar
|
||||
self.modifier = source.modifier
|
||||
self.quality = source.quality
|
||||
self.dateval = source.dateval
|
||||
self.text = source.text
|
||||
self.sortval = source.sortval
|
||||
|
||||
def __cmp__(self,other):
|
||||
"""
|
||||
Comparison function. Allows the usage of equality tests.
|
||||
This allows you do run statements like 'date1 <= date2'
|
||||
"""
|
||||
if isinstance(other,Date):
|
||||
return cmp(self.sortval,other.sortval)
|
||||
else:
|
||||
return -1
|
||||
|
||||
def is_equal(self,other):
|
||||
"""
|
||||
Return 1 if the given Date instance is the same as the present
|
||||
instance IN ALL REGARDS. Needed, because the __cmp__ only looks
|
||||
at the sorting value, and ignores the modifiers/comments.
|
||||
"""
|
||||
if self.modifier == other.modifier \
|
||||
and self.modifier == Date.MOD_TEXTONLY:
|
||||
value = self.text == other.text
|
||||
else:
|
||||
value = (self.calendar == other.calendar and
|
||||
self.modifier == other.modifier and
|
||||
self.quality == other.quality and
|
||||
self.dateval == other.dateval)
|
||||
return value
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
Produces a string representation of the Date object. If the
|
||||
date is not valid, the text representation is displayed. If
|
||||
the date is a range or a span, a string in the form of
|
||||
'YYYY-MM-DD - YYYY-MM-DD' is returned. Otherwise, a string in
|
||||
the form of 'YYYY-MM-DD' is returned.
|
||||
"""
|
||||
if self.quality == Date.QUAL_ESTIMATED:
|
||||
qual = "est "
|
||||
elif self.quality == Date.QUAL_CALCULATED:
|
||||
qual = "calc "
|
||||
else:
|
||||
qual = ""
|
||||
|
||||
if self.modifier == Date.MOD_BEFORE:
|
||||
pref = "bef "
|
||||
elif self.modifier == Date.MOD_AFTER:
|
||||
pref = "aft "
|
||||
elif self.modifier == Date.MOD_ABOUT:
|
||||
pref = "abt "
|
||||
else:
|
||||
pref = ""
|
||||
|
||||
if self.calendar != Date.CAL_GREGORIAN:
|
||||
cal = " (%s)" % Date.calendar_names[self.calendar]
|
||||
else:
|
||||
cal = ""
|
||||
|
||||
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = self.text
|
||||
elif self.modifier == Date.MOD_RANGE or self.modifier == Date.MOD_SPAN:
|
||||
val = "%04d-%02d-%02d - %04d-%02d-%02d" % (
|
||||
self.dateval[Date._POS_YR],self.dateval[Date._POS_MON],
|
||||
self.dateval[Date._POS_DAY],self.dateval[Date._POS_RYR],
|
||||
self.dateval[Date._POS_RMON],self.dateval[Date._POS_RDAY])
|
||||
else:
|
||||
val = "%04d-%02d-%02d" % (
|
||||
self.dateval[Date._POS_YR],self.dateval[Date._POS_MON],
|
||||
self.dateval[Date._POS_DAY])
|
||||
return "%s%s%s%s" % (qual,pref,val,cal)
|
||||
|
||||
def get_sort_value(self):
|
||||
"""
|
||||
Returns the sort value of Date object. If the value is a
|
||||
text string, 0 is returned. Otherwise, the calculated sort
|
||||
date is returned. The sort date is rebuilt on every assignment.
|
||||
|
||||
The sort value is an integer representing the value. A date of
|
||||
March 5, 1990 would have the value of 19900305.
|
||||
"""
|
||||
return self.sortval
|
||||
|
||||
def get_modifier(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
MOD_NONE = no modifier (default)
|
||||
MOD_BEFORE = before
|
||||
MOD_AFTER = after
|
||||
MOD_ABOUT = about
|
||||
MOD_RANGE = date range
|
||||
MOD_SPAN = date span
|
||||
MOD_TEXTONLY = text only
|
||||
"""
|
||||
return self.modifier
|
||||
|
||||
def set_modifier(self,val):
|
||||
"""
|
||||
Sets the modifier for the date.
|
||||
"""
|
||||
if val not in (Date.MOD_NONE,Date.MOD_BEFORE,Date.MOD_AFTER,
|
||||
Date.MOD_ABOUT,Date.MOD_RANGE,Date.MOD_SPAN,
|
||||
Date.MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
self.modifier = val
|
||||
|
||||
def get_quality(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
QUAL_NONE = normal (default)
|
||||
QUAL_ESTIMATED = estimated
|
||||
QUAL_CALCULATED = calculated
|
||||
"""
|
||||
return self.quality
|
||||
|
||||
def set_quality(self,val):
|
||||
"""
|
||||
Sets the quality selected for the date.
|
||||
"""
|
||||
if val not in (Date.QUAL_NONE,Date.QUAL_ESTIMATED,
|
||||
Date.QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
self.quality = val
|
||||
|
||||
def get_calendar(self):
|
||||
"""
|
||||
Returns an integer indicating the calendar selected. The valid
|
||||
values are::
|
||||
|
||||
CAL_GREGORIAN - Gregorian calendar
|
||||
CAL_JULIAN - Julian calendar
|
||||
CAL_HEBREW - Hebrew (Jewish) calendar
|
||||
CAL_FRENCH - French Republican calendar
|
||||
CAL_PERSIAN - Persian calendar
|
||||
CAL_ISLAMIC - Islamic calendar
|
||||
"""
|
||||
return self.calendar
|
||||
|
||||
def set_calendar(self,val):
|
||||
"""
|
||||
Sets the calendar selected for the date.
|
||||
"""
|
||||
if val not in (Date.CAL_GREGORIAN,Date.CAL_JULIAN,Date.CAL_HEBREW,
|
||||
Date.CAL_FRENCH,Date.CAL_PERSIAN,Date.CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
self.calendar = val
|
||||
|
||||
def get_start_date(self):
|
||||
"""
|
||||
Returns a tuple representing the start date. If the date is a
|
||||
compound date (range or a span), it is the first part of the
|
||||
compound date. If the date is a text string, a tuple of
|
||||
(0,0,0,False) is returned. Otherwise, a date of (DD,MM,YY,slash)
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = Date.EMPTY
|
||||
else:
|
||||
val = self.dateval[0:4]
|
||||
return val
|
||||
|
||||
def get_stop_date(self):
|
||||
"""
|
||||
Returns a tuple representing the second half of a compound date.
|
||||
If the date is not a compound date, (including text strings) a tuple
|
||||
of (0,0,0,False) is returned. Otherwise, a date of (DD,MM,YY,slash)
|
||||
is returned. If slash is True, then the date is in the form of 1530/1.
|
||||
"""
|
||||
if self.modifier == Date.MOD_RANGE or self.modifier == Date.MOD_SPAN:
|
||||
val = self.dateval[4:8]
|
||||
else:
|
||||
val = Date.EMPTY
|
||||
return val
|
||||
|
||||
def _get_low_item(self,index):
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = 0
|
||||
else:
|
||||
val = self.dateval[index]
|
||||
return val
|
||||
|
||||
def _get_low_item_valid(self,index):
|
||||
if self.modifier == Date.MOD_TEXTONLY:
|
||||
val = False
|
||||
else:
|
||||
val = self.dateval[index] != 0
|
||||
return val
|
||||
|
||||
def _get_high_item(self,index):
|
||||
if self.modifier == Date.MOD_SPAN or self.modifier == Date.MOD_RANGE:
|
||||
val = self.dateval[index]
|
||||
else:
|
||||
val = 0
|
||||
return val
|
||||
|
||||
def get_year(self):
|
||||
"""
|
||||
Returns the year associated with the date. If the year is
|
||||
not defined, a zero is returned. If the date is a compound
|
||||
date, the lower date year is returned.
|
||||
"""
|
||||
return self._get_low_item(Date._POS_YR)
|
||||
|
||||
def set_year(self,year):
|
||||
"""
|
||||
"""
|
||||
self.dateval = self.dateval[0:2] + (year,) + self.dateval[3:]
|
||||
self.calc_sort_value()
|
||||
|
||||
def get_year_valid(self):
|
||||
return self._get_low_item_valid(Date._POS_YR)
|
||||
|
||||
def get_month(self):
|
||||
"""
|
||||
Returns the month associated with the date. If the month is
|
||||
not defined, a zero is returned. If the date is a compound
|
||||
date, the lower date month is returned.
|
||||
"""
|
||||
return self._get_low_item(Date._POS_MON)
|
||||
|
||||
def get_month_valid(self):
|
||||
return self._get_low_item_valid(Date._POS_MON)
|
||||
|
||||
def get_day(self):
|
||||
"""
|
||||
Returns the day of the month associated with the date. If
|
||||
the day is not defined, a zero is returned. If the date is
|
||||
a compound date, the lower date day is returned.
|
||||
"""
|
||||
return self._get_low_item(Date._POS_DAY)
|
||||
|
||||
def get_day_valid(self):
|
||||
return self._get_low_item_valid(Date._POS_DAY)
|
||||
|
||||
def get_valid(self):
|
||||
""" Returns true if any part of the date is valid"""
|
||||
return self.modifier != Date.MOD_TEXTONLY
|
||||
|
||||
def get_incomplete(self):
|
||||
pass
|
||||
|
||||
def get_stop_year(self):
|
||||
"""
|
||||
Returns the day of the year associated with the second
|
||||
part of a compound date. If the year is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(Date._POS_RYR)
|
||||
|
||||
def get_stop_month(self):
|
||||
"""
|
||||
Returns the month of the month associated with the second
|
||||
part of a compound date. If the month is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(Date._POS_RMON)
|
||||
|
||||
def get_stop_day(self):
|
||||
"""
|
||||
Returns the day of the month associated with the second
|
||||
part of a compound date. If the day is not defined, a zero
|
||||
is returned.
|
||||
"""
|
||||
return self._get_high_item(Date._POS_RDAY)
|
||||
|
||||
def get_high_year(self):
|
||||
"""
|
||||
Returns the high year estimate. For compound dates with non-zero
|
||||
stop year, the stop year is returned. Otherwise, the start year
|
||||
is returned.
|
||||
"""
|
||||
if self.is_compound():
|
||||
ret = self.get_stop_year()
|
||||
if ret:
|
||||
return ret
|
||||
else:
|
||||
return self.get_year()
|
||||
|
||||
def get_text(self):
|
||||
"""
|
||||
Returns the text value associated with an invalid date.
|
||||
"""
|
||||
return self.text
|
||||
|
||||
def set(self,quality,modifier,calendar,value,text=None):
|
||||
"""
|
||||
Sets the date to the specified value. Parameters are::
|
||||
|
||||
quality - The date quality for the date (see get_quality
|
||||
for more information)
|
||||
modified - The date modifier for the date (see get_modifier
|
||||
for more information)
|
||||
calendar - The calendar associated with the date (see
|
||||
get_calendar for more information).
|
||||
value - A tuple representing the date information. For a
|
||||
non-compound date, the format is (DD,MM,YY,slash)
|
||||
and for a compound date the tuple stores data as
|
||||
(DD,MM,YY,slash1,DD,MM,YY,slash2)
|
||||
text - A text string holding either the verbatim user input
|
||||
or a comment relating to the date.
|
||||
|
||||
The sort value is recalculated.
|
||||
"""
|
||||
|
||||
if modifier in (Date.MOD_NONE,Date.MOD_BEFORE,
|
||||
Date.MOD_AFTER,Date.MOD_ABOUT) and len(value) < 4:
|
||||
raise DateError("Invalid value. Should be: (DD,MM,YY,slash)")
|
||||
if modifier in (Date.MOD_RANGE,Date.MOD_SPAN) and len(value) < 8:
|
||||
raise DateError(
|
||||
"Invalid value. Should be: (DD,MM,YY,slash1,DD,MM,YY,slash2)")
|
||||
if modifier not in (Date.MOD_NONE,Date.MOD_BEFORE,Date.MOD_AFTER,
|
||||
Date.MOD_ABOUT,Date.MOD_RANGE,Date.MOD_SPAN,
|
||||
Date.MOD_TEXTONLY):
|
||||
raise DateError("Invalid modifier")
|
||||
if quality not in (Date.QUAL_NONE,Date.QUAL_ESTIMATED,
|
||||
Date.QUAL_CALCULATED):
|
||||
raise DateError("Invalid quality")
|
||||
if calendar not in (Date.CAL_GREGORIAN,Date.CAL_JULIAN,Date.CAL_HEBREW,
|
||||
Date.CAL_FRENCH,Date.CAL_PERSIAN,Date.CAL_ISLAMIC):
|
||||
raise DateError("Invalid calendar")
|
||||
|
||||
self.quality = quality
|
||||
self.modifier = modifier
|
||||
self.calendar = calendar
|
||||
self.dateval = value
|
||||
year = max(value[Date._POS_YR],1)
|
||||
month = max(value[Date._POS_MON],1)
|
||||
day = max(value[Date._POS_DAY],1)
|
||||
if year == 0 and month == 0 and day == 0:
|
||||
self.sortval = 0
|
||||
else:
|
||||
self.sortval = Date._calendar_convert[calendar](year,month,day)
|
||||
if text:
|
||||
self.text = text
|
||||
|
||||
def calc_sort_value(self):
|
||||
year = max(self.dateval[Date._POS_YR],1)
|
||||
month = max(self.dateval[Date._POS_MON],1)
|
||||
day = max(self.dateval[Date._POS_DAY],1)
|
||||
if year == 0 and month == 0 and day == 0:
|
||||
self.sortval = 0
|
||||
else:
|
||||
self.sortval = Date._calendar_convert[self.calendar](year,month,day)
|
||||
|
||||
def convert_calendar(self,calendar):
|
||||
"""
|
||||
Converts the date from the current calendar to the specified
|
||||
calendar.
|
||||
"""
|
||||
if calendar == self.calendar:
|
||||
return
|
||||
(y,m,d) = Date._calendar_change[calendar](self.sortval)
|
||||
if self.is_compound():
|
||||
ry = max(self.dateval[Date._POS_RYR],1)
|
||||
rm = max(self.dateval[Date._POS_RMON],1)
|
||||
rd = max(self.dateval[_POS_RDAY],1)
|
||||
sdn = Date._calendar_convert[self.calendar](ry,rm,rd)
|
||||
(ny,nm,nd) = Date._calendar_change[calendar](sdn)
|
||||
self.dateval = (d,m,y,self.dateval[Date._POS_SL],
|
||||
nd,nm,ny,self.dateval[Date._POS_RSL])
|
||||
else:
|
||||
self.dateval = (d,m,y,self.dateval[Date._POS_SL])
|
||||
self.calendar = calendar
|
||||
|
||||
def set_as_text(self,text):
|
||||
"""
|
||||
Sets the day to a text string, and assigns the sort value
|
||||
to zero.
|
||||
"""
|
||||
self.modifier = Date.MOD_TEXTONLY
|
||||
self.text = text
|
||||
self.sortval = 0
|
||||
|
||||
def set_text_value(self,text):
|
||||
"""
|
||||
Sets the text string to a given text.
|
||||
"""
|
||||
self.text = text
|
||||
|
||||
def is_empty(self):
|
||||
"""
|
||||
Returns True if the date contains no information (empty text).
|
||||
"""
|
||||
return (self.modifier == Date.MOD_TEXTONLY and not self.text) or \
|
||||
(self.get_start_date()==Date.EMPTY
|
||||
and self.get_stop_date()==Date.EMPTY)
|
||||
|
||||
def is_compound(self):
|
||||
"""
|
||||
Returns True if the date is a date range or a date span.
|
||||
"""
|
||||
return self.modifier == Date.MOD_RANGE \
|
||||
or self.modifier == Date.MOD_SPAN
|
||||
|
||||
def is_regular(self):
|
||||
"""
|
||||
Returns True if the date is a regular date.
|
||||
|
||||
The regular date is a single exact date, i.e. not text-only, not
|
||||
a range or a span, not estimated/calculated, not about/before/after
|
||||
date, and having year, month, and day all non-zero.
|
||||
"""
|
||||
return self.modifier == Date.MOD_NONE \
|
||||
and self.quality == Date.QUAL_NONE \
|
||||
and self.get_year_valid() and self.get_month_valid() \
|
||||
and self.get_day_valid()
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -29,7 +29,7 @@ DateBase class for GRAMPS
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from _Date import Date
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -49,10 +49,23 @@ class DateBase:
|
||||
@type source: DateBase
|
||||
"""
|
||||
if source:
|
||||
self.date = Date.Date(source.date)
|
||||
self.date = Date(source.date)
|
||||
else:
|
||||
self.date = None
|
||||
|
||||
def serialize(self):
|
||||
if self.date == None:
|
||||
date = None
|
||||
else:
|
||||
date = self.date.serialize()
|
||||
return date
|
||||
|
||||
def unserialize(self,data):
|
||||
if data == None:
|
||||
self.date = None
|
||||
else:
|
||||
self.date = Date().unserialize(data)
|
||||
|
||||
# def set_date(self, date) :
|
||||
# """
|
||||
# Sets the date of the DateBase instance.
|
||||
@ -103,7 +116,7 @@ class DateBase:
|
||||
@rtype: L{Date}
|
||||
"""
|
||||
if not self.date:
|
||||
self.date = Date.Date()
|
||||
self.date = Date()
|
||||
return self.date
|
||||
|
||||
def set_date_object(self,date):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -142,9 +142,11 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase):
|
||||
be considered persistent.
|
||||
@rtype: tuple
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.type, self.date,
|
||||
return (self.handle, self.gramps_id, self.type,
|
||||
DateBase.serialize(self),
|
||||
self.description, self.place, self.cause,
|
||||
self.source_list, self.note, self.media_list,
|
||||
SourceNote.serialize(self),
|
||||
MediaBase.serialize(self),
|
||||
self.change, self.marker, self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
@ -156,9 +158,13 @@ class Event(PrimaryObject,SourceNote,MediaBase,DateBase,PlaceBase):
|
||||
Person object
|
||||
@type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.type, self.date,
|
||||
self.description, self.place, self.cause, self.source_list, self.note,
|
||||
self.media_list, self.change, self.marker, self.private) = data
|
||||
(self.handle, self.gramps_id, self.type, date,
|
||||
self.description, self.place, self.cause, sn,
|
||||
media_list, self.change, self.marker, self.private) = data
|
||||
|
||||
DateBase.unserialize(self,date)
|
||||
MediaBase.unserialize(self,media_list)
|
||||
SourceNote.unserialize(self,sn)
|
||||
|
||||
def _has_handle_reference(self,classname,handle):
|
||||
if classname == 'Place':
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -77,6 +77,14 @@ class EventRef(BaseObject,PrivacyBase,NoteBase):
|
||||
self.ref = None
|
||||
self.role = (EventRef.CUSTOM,"")
|
||||
|
||||
def serialize(self):
|
||||
return (self.private,NoteBase.serialize(self),self.ref,self.role)
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.private,nb,self.ref,self.role) = data
|
||||
NoteBase.unserialize(self,nb)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -109,10 +109,16 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
|
||||
be considered persistent.
|
||||
@rtype: tuple
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.father_handle, self.mother_handle,
|
||||
self.child_list, self.type, self.event_ref_list,
|
||||
self.media_list, self.attribute_list, self.lds_seal,
|
||||
self.complete, self.source_list, self.note,
|
||||
if self.lds_seal == None:
|
||||
lds_seal = None
|
||||
else:
|
||||
lds_seal = self.lds_seal.serialize()
|
||||
return (self.handle, self.gramps_id, self.father_handle,
|
||||
self.mother_handle,self.child_list, self.type,
|
||||
[er.serialize() for er in self.event_ref_list],
|
||||
MediaBase.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
lds_seal,SourceNote.serialize(self),
|
||||
self.change, self.marker, self.private)
|
||||
|
||||
def unserialize(self, data):
|
||||
@ -121,10 +127,15 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
|
||||
back into the data in a Family structure.
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.father_handle, self.mother_handle,
|
||||
self.child_list, self.type, self.event_ref_list,
|
||||
self.media_list, self.attribute_list, self.lds_seal,
|
||||
self.complete, self.source_list, self.note, self.change,
|
||||
self.marker, self.private) = data
|
||||
self.child_list, self.type,
|
||||
event_ref_list, media_list, attribute_list, lds_seal, sn,
|
||||
self.change,self.marker, self.private) = data
|
||||
|
||||
self.event_ref_list = [EventRef().unserialize(er)
|
||||
for er in event_ref_list]
|
||||
MediaBase.unserialize(self,media_list)
|
||||
AttributeBase.unserialize(self,attribute_list)
|
||||
SourceNote.unserialize(self,sn)
|
||||
|
||||
def _has_handle_reference(self,classname,handle):
|
||||
if classname == 'Event':
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -61,6 +61,17 @@ class LdsOrd(SourceNote,DateBase,PlaceBase):
|
||||
self.temple = ""
|
||||
self.status = 0
|
||||
|
||||
def serialize(self):
|
||||
return (SourceNote.serialize(self),
|
||||
DateBase.serialize(self),self.place,
|
||||
self.famc,self.temple,self.status)
|
||||
|
||||
def unserialize(self,data):
|
||||
(sn,date,self.place,
|
||||
self.famc,self.temple,self.status) = data
|
||||
SourceNote.unserialize(self,sn)
|
||||
DateBase.unserialize(self,date)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -60,6 +60,14 @@ class Location(BaseObject,LocationBase):
|
||||
self.parish = ""
|
||||
self.county = ""
|
||||
|
||||
def serialize(self):
|
||||
return (LocationBase.serialize(self),self.parish,self.county)
|
||||
|
||||
def unserialize(self,data):
|
||||
(lb,self.parish,self.county) = data
|
||||
LocationBase.unserialize(self,lb)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -52,6 +52,13 @@ class LocationBase:
|
||||
self.postal = ""
|
||||
self.phone = ""
|
||||
|
||||
def serialize(self):
|
||||
return (self.city,self.state,self.country,self.postal,self.phone)
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.city,self.state,self.country,self.postal,self.phone) = data
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -54,6 +54,12 @@ class MediaBase:
|
||||
else:
|
||||
self.media_list = []
|
||||
|
||||
def serialize(self):
|
||||
return [mref.serialize() for mref in self.media_list]
|
||||
|
||||
def unserialize(self,data):
|
||||
self.media_list = [MediaRef().unserialize(item) for item in data]
|
||||
|
||||
def add_media_reference(self,media_ref):
|
||||
"""
|
||||
Adds a L{MediaRef} instance to the object's media list.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -69,11 +69,13 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
self.path = source.path
|
||||
self.mime = source.mime
|
||||
self.desc = source.desc
|
||||
# FIXME: thumb is not currently being serialized!
|
||||
self.thumb = source.thumb
|
||||
else:
|
||||
self.path = ""
|
||||
self.mime = ""
|
||||
self.desc = ""
|
||||
# FIXME: thumb is not currently being serialized!
|
||||
self.thumb = None
|
||||
|
||||
def serialize(self):
|
||||
@ -92,9 +94,11 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
be considered persistent.
|
||||
@rtype: tuple
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.path, self.mime,
|
||||
self.desc, self.attribute_list, self.source_list, self.note,
|
||||
self.change, self.date, self.marker, self.private)
|
||||
return (self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
AttributeBase.serialize(self),
|
||||
SourceNote.serialize(self),
|
||||
self.change,
|
||||
DateBase.serialize(self), self.marker, self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -105,8 +109,12 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
|
||||
@type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
self.attribute_list, self.source_list, self.note, self.change,
|
||||
self.date, self.marker, self.private) = data
|
||||
attribute_list, sn, self.change,
|
||||
date, self.marker, self.private) = data
|
||||
|
||||
AttributeBase.unserialize(self,attribute_list)
|
||||
SourceNote.unserialize(self,sn)
|
||||
DateBase.unserialize(self,date)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -51,6 +51,17 @@ class MediaRef(PrivateSourceNote,AttributeBase):
|
||||
self.ref = None
|
||||
self.rect = None
|
||||
|
||||
def serialize(self):
|
||||
return (PrivateSourceNote.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
self.ref,self.rect)
|
||||
|
||||
def unserialize(self,data):
|
||||
(psn,attribute_list,self.ref,self.rect) = data
|
||||
PrivateSourceNote.unserialize(self,psn)
|
||||
AttributeBase.unserialize(self,attribute_list)
|
||||
return self
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Returns the list of child objects that may carry textual data.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -93,6 +93,22 @@ class Name(PrivateSourceNote,DateBase):
|
||||
self.sort_as = self.DEF
|
||||
self.display_as = self.DEF
|
||||
|
||||
def serialize(self):
|
||||
return (PrivateSourceNote.serialize(self),
|
||||
DateBase.serialize(self),
|
||||
self.first_name,self.surname,self.suffix,self.title,
|
||||
self.type,self.prefix,self.patronymic,self.sname,
|
||||
self.group_as,self.sort_as,self.display_as)
|
||||
|
||||
def unserialize(self,data):
|
||||
(psn,date,
|
||||
self.first_name,self.surname,self.suffix,self.title,
|
||||
self.type,self.prefix,self.patronymic,self.sname,
|
||||
self.group_as,self.sort_as,self.display_as) = data
|
||||
PrivateSourceNote.unserialize(self,psn)
|
||||
DateBase.unserialize(self,date)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -53,6 +53,13 @@ class Note(BaseObject):
|
||||
self.text = text
|
||||
self.format = 0
|
||||
|
||||
def serialize(self):
|
||||
return (self.text,self.format)
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.text,self.format) = data
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -53,6 +53,19 @@ class NoteBase:
|
||||
else:
|
||||
self.note = None
|
||||
|
||||
def serialize(self):
|
||||
if self.note == None:
|
||||
note = None
|
||||
else:
|
||||
note = self.note.serialize()
|
||||
return note
|
||||
|
||||
def unserialize(self,data):
|
||||
if data == None:
|
||||
self.note = None
|
||||
else:
|
||||
self.note = Note().unserialize(data)
|
||||
|
||||
def set_note(self,text):
|
||||
"""
|
||||
Assigns the specified text to the associated note.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -44,6 +44,7 @@ from _AddressBase import AddressBase
|
||||
from _UrlBase import UrlBase
|
||||
from _Name import Name
|
||||
from _EventRef import EventRef
|
||||
from _LdsOrd import LdsOrd
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -94,27 +95,27 @@ class Person(PrimaryObject,SourceNote,
|
||||
data items have empty or null values, including the database
|
||||
handle.
|
||||
"""
|
||||
PrimaryObject.__init__(self)
|
||||
SourceNote.__init__(self)
|
||||
MediaBase.__init__(self)
|
||||
AttributeBase.__init__(self)
|
||||
AddressBase.__init__(self)
|
||||
UrlBase.__init__(self)
|
||||
self.primary_name = Name()
|
||||
self.event_ref_list = []
|
||||
self.family_list = []
|
||||
self.parent_family_list = []
|
||||
self.nickname = ""
|
||||
self.alternate_names = []
|
||||
self.gender = Person.UNKNOWN
|
||||
self.death_ref = None
|
||||
self.birth_ref = None
|
||||
self.lds_bapt = None
|
||||
self.lds_endow = None
|
||||
self.lds_seal = None
|
||||
|
||||
if data:
|
||||
self.unserialize(data)
|
||||
else:
|
||||
PrimaryObject.__init__(self)
|
||||
SourceNote.__init__(self)
|
||||
MediaBase.__init__(self)
|
||||
AttributeBase.__init__(self)
|
||||
AddressBase.__init__(self)
|
||||
UrlBase.__init__(self)
|
||||
self.primary_name = Name()
|
||||
self.event_ref_list = []
|
||||
self.family_list = []
|
||||
self.parent_family_list = []
|
||||
self.nickname = ""
|
||||
self.alternate_names = []
|
||||
self.gender = Person.UNKNOWN
|
||||
self.death_ref = None
|
||||
self.birth_ref = None
|
||||
self.lds_bapt = None
|
||||
self.lds_endow = None
|
||||
self.lds_seal = None
|
||||
|
||||
# We hold a reference to the GrampsDB so that we can maintain
|
||||
# its genderStats. It doesn't get set here, but from
|
||||
@ -136,13 +137,40 @@ class Person(PrimaryObject,SourceNote,
|
||||
be considered persistent.
|
||||
@rtype: tuple
|
||||
"""
|
||||
if self.birth_ref == None:
|
||||
birth_ref = None
|
||||
else:
|
||||
birth_ref = self.birth_ref.serialize()
|
||||
if self.death_ref == None:
|
||||
death_ref = None
|
||||
else:
|
||||
death_ref = self.death_ref.serialize()
|
||||
if self.lds_bapt == None:
|
||||
lds_bapt = None
|
||||
else:
|
||||
lds_bapt = self.lds_bapt.serialize()
|
||||
if self.lds_endow == None:
|
||||
lds_endow = None
|
||||
else:
|
||||
lds_endow = self.lds_endow.serialize()
|
||||
if self.lds_seal == None:
|
||||
lds_seal = None
|
||||
else:
|
||||
lds_seal = self.lds_seal.serialize()
|
||||
|
||||
return (self.handle, self.gramps_id, self.gender,
|
||||
self.primary_name, self.alternate_names,
|
||||
unicode(self.nickname), self.death_ref, self.birth_ref,
|
||||
self.event_ref_list, self.family_list, self.parent_family_list,
|
||||
self.media_list, self.address_list, self.attribute_list,
|
||||
self.urls, self.lds_bapt, self.lds_endow, self.lds_seal,
|
||||
self.source_list, self.note, self.change, self.marker,
|
||||
self.primary_name.serialize(),
|
||||
[name.serialize() for name in self.alternate_names],
|
||||
unicode(self.nickname), death_ref, birth_ref,
|
||||
[er.serialize() for er in self.event_ref_list],
|
||||
self.family_list,self.parent_family_list,
|
||||
MediaBase.serialize(self),
|
||||
AddressBase.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
UrlBase.serialize(self),
|
||||
lds_bapt, lds_endow, lds_seal,
|
||||
SourceNote.serialize(self),
|
||||
self.change, self.marker,
|
||||
self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
@ -154,13 +182,34 @@ class Person(PrimaryObject,SourceNote,
|
||||
Person object
|
||||
@type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.gender, self.primary_name,
|
||||
self.alternate_names, self.nickname, self.death_ref,
|
||||
self.birth_ref, self.event_ref_list, self.family_list,
|
||||
self.parent_family_list, self.media_list, self.address_list,
|
||||
self.attribute_list, self.urls, self.lds_bapt, self.lds_endow,
|
||||
self.lds_seal, self.source_list, self.note, self.change,
|
||||
self.marker, self.private) = (data + (False,))[0:23]
|
||||
(self.handle, self.gramps_id, self.gender, primary_name,
|
||||
alternate_names, self.nickname, death_ref,
|
||||
birth_ref, event_ref_list, self.family_list,
|
||||
self.parent_family_list, media_list, address_list,
|
||||
attribute_list, urls, lds_bapt, lds_endow,
|
||||
lds_seal, sn, self.change,
|
||||
self.marker, self.private) = (data + (False,))[0:22]
|
||||
|
||||
self.primary_name.unserialize(primary_name)
|
||||
if death_ref:
|
||||
self.death_ref = EventRef().unserialize(death_ref)
|
||||
if birth_ref:
|
||||
self.birth_ref = EventRef().unserialize(birth_ref)
|
||||
if lds_bapt:
|
||||
self.lds_bapt = LdsOrd().unserialize(lds_bapt)
|
||||
if lds_endow:
|
||||
self.lds_endow = LdsOrd().unserialize(lds_endow)
|
||||
if lds_seal:
|
||||
self.lds_seal = LdsOrd().unserialize(lds_seal)
|
||||
self.alternate_names = [Name().unserialize(name)
|
||||
for name in alternate_names]
|
||||
self.event_ref_list = [EventRef().unserialize(er)
|
||||
for er in event_ref_list]
|
||||
MediaBase.unserialize(self,media_list)
|
||||
AddressBase.unserialize(self,address_list)
|
||||
AttributeBase.unserialize(self,attribute_list)
|
||||
UrlBase.unserialize(self,urls)
|
||||
SourceNote.unserialize(self,sn)
|
||||
|
||||
def _has_handle_reference(self,classname,handle):
|
||||
if classname == 'Event':
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -63,9 +63,7 @@ class Place(PrimaryObject,SourceNote,MediaBase,UrlBase):
|
||||
self.lat = source.lat
|
||||
self.title = source.title
|
||||
self.main_loc = Location(source.main_loc)
|
||||
self.alt_loc = []
|
||||
for loc in source.alt_loc:
|
||||
self.alt_loc = Location(loc)
|
||||
self.alt_loc = [Location(loc) for loc in source.alt_loc]
|
||||
else:
|
||||
self.long = ""
|
||||
self.lat = ""
|
||||
@ -89,10 +87,17 @@ class Place(PrimaryObject,SourceNote,MediaBase,UrlBase):
|
||||
be considered persistent.
|
||||
@rtype: tuple
|
||||
"""
|
||||
if self.main_loc == None:
|
||||
main_loc = None
|
||||
else:
|
||||
main_loc = self.main_loc.serialize()
|
||||
|
||||
return (self.handle, self.gramps_id, self.title, self.long, self.lat,
|
||||
self.main_loc, self.alt_loc, self.urls, self.media_list,
|
||||
self.source_list, self.note, self.change, self.marker,
|
||||
self.private)
|
||||
main_loc, [al.serialize() for al in self.alt_loc],
|
||||
UrlBase.serialize(self),
|
||||
MediaBase.serialize(self),
|
||||
SourceNote.serialize(self),
|
||||
self.change, self.marker,self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -104,10 +109,18 @@ class Place(PrimaryObject,SourceNote,MediaBase,UrlBase):
|
||||
@type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.title, self.long, self.lat,
|
||||
self.main_loc, self.alt_loc, self.urls, self.media_list,
|
||||
self.source_list, self.note, self.change, self.marker,
|
||||
self.private) = data
|
||||
|
||||
main_loc, alt_loc, urls, media_list, sn,
|
||||
self.change, self.marker, self.private) = data
|
||||
|
||||
if main_loc == None:
|
||||
self.main_loc = None
|
||||
else:
|
||||
self.main.loc = Location().unserialize(main_loc)
|
||||
self.alt_loc = [Location().unserialize(al) for al in alt_loc]
|
||||
UrlBase.unserialize(self,urls)
|
||||
MediaBase.unserialize(self,media_list)
|
||||
SourceNote.unserialize(self,sn)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -51,3 +51,10 @@ class PrivateSourceNote(SourceNote,PrivacyBase):
|
||||
"""
|
||||
SourceNote.__init__(self,source)
|
||||
PrivacyBase.__init__(self,source)
|
||||
|
||||
def serialize(self):
|
||||
return (self.private,SourceNote.serialize(self))
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.private,sn) = data
|
||||
SourceNote.unserialize(self,sn)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -69,6 +69,14 @@ class RepoRef(BaseObject,NoteBase):
|
||||
self.call_number = ""
|
||||
self.media_type = (RepoRef.CUSTOM,"")
|
||||
|
||||
def serialize(self):
|
||||
return (NoteBase.serialize(self),
|
||||
self.ref,self.call_number,self.media_type)
|
||||
|
||||
def unserialize(self,data):
|
||||
(note,self.ref,self.call_number,self.media_type) = data
|
||||
NoteBase.unserialize(self,note)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -72,16 +72,22 @@ class Repository(PrimaryObject,NoteBase,AddressBase,UrlBase):
|
||||
|
||||
def serialize(self):
|
||||
return (self.handle, self.gramps_id, self.type, unicode(self.name),
|
||||
self.note, self.address_list, self.urls,self.marker,
|
||||
self.private)
|
||||
NoteBase.serialize(self),
|
||||
AddressBase.serialize(self),
|
||||
UrlBase.serialize(self),
|
||||
self.marker, self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
Converts the data held in a tuple created by the serialize method
|
||||
back into the data in an Repository structure.
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.type, self.name, self.note,
|
||||
self.address_list, self.urls ,self.marker, self.private) = data
|
||||
(self.handle, self.gramps_id, self.type, self.name, note,
|
||||
address_list, urls ,self.marker, self.private) = data
|
||||
|
||||
NoteBase.unserialize(self,note)
|
||||
AddressBase.unserialize(self,address_list)
|
||||
UrlBase.unserialize(self,urls)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -33,6 +33,7 @@ from _PrimaryObject import PrimaryObject
|
||||
from _MediaBase import MediaBase
|
||||
from _NoteBase import NoteBase
|
||||
from _Note import Note
|
||||
from _RepoRef import RepoRef
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -58,9 +59,11 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
def serialize(self):
|
||||
return (self.handle, self.gramps_id, unicode(self.title),
|
||||
unicode(self.author), unicode(self.pubinfo),
|
||||
self.note, self.media_list, unicode(self.abbrev),
|
||||
self.change,self.datamap,self.reporef_list, self.marker,
|
||||
self.private)
|
||||
NoteBase.serialize(self),
|
||||
MediaBase.serialize(self), unicode(self.abbrev),
|
||||
self.change,self.datamap,
|
||||
[rr.serialize() for rr in self.reporef_list],
|
||||
self.marker,self.private)
|
||||
|
||||
def unserialize(self,data):
|
||||
"""
|
||||
@ -68,9 +71,13 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
back into the data in an Event structure.
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.title, self.author,
|
||||
self.pubinfo, self.note, self.media_list,
|
||||
self.abbrev, self.change, self.datamap, self.reporef_list,
|
||||
self.pubinfo, note, media_list,
|
||||
self.abbrev, self.change, self.datamap, reporef_list,
|
||||
self.marker, self.private) = data
|
||||
|
||||
NoteBase.unserialize(self,note)
|
||||
MediaBase.unserialize(self,media_list)
|
||||
self.reporef_list = [RepoRef().unserialize(rr) for rr in reporef_list]
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
@ -79,10 +86,9 @@ class Source(PrimaryObject,MediaBase,NoteBase):
|
||||
@return: Returns the list of all textual attributes of the object.
|
||||
@rtype: list
|
||||
"""
|
||||
return [self.title,self.author,self.pubinfo,self.abbrev,self.gramps_id]\
|
||||
+ self.datamap.keys() + self.datamap.values()
|
||||
|
||||
|
||||
return [self.title,self.author,self.pubinfo,self.abbrev,
|
||||
self.gramps_id] + self.datamap.keys() + self.datamap.values()
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Returns the list of child objects that may carry textual data.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -57,6 +57,16 @@ class SourceNote(BaseObject,NoteBase):
|
||||
else:
|
||||
self.source_list = []
|
||||
|
||||
def serialize(self):
|
||||
return (NoteBase.serialize(self),
|
||||
[sref.serialize() for sref in self.source_list])
|
||||
|
||||
def unserialize(self,data):
|
||||
(note,source_list) = data
|
||||
NoteBase.unserialize(self,note)
|
||||
self.source_list = [SourceRef().unserialize(item)
|
||||
for item in source_list]
|
||||
|
||||
def add_source_reference(self,src_ref) :
|
||||
"""
|
||||
Adds a source reference to this object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -68,6 +68,18 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
|
||||
self.note = Note()
|
||||
self.text = ""
|
||||
|
||||
def serialize(self):
|
||||
return (DateBase.serialize(self),self.private,
|
||||
NoteBase.serialize(self),
|
||||
self.confidence,self.ref,self.page,self.text)
|
||||
|
||||
def unserialize(self,data):
|
||||
(date,self.private,nb,
|
||||
self.confidence,self.ref,self.page,self.text) = data
|
||||
DateBase.unserialize(self,date)
|
||||
NoteBase.unserialize(self,nb)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -68,6 +68,13 @@ class Url(BaseObject,PrivacyBase):
|
||||
self.desc = ""
|
||||
self.type = (Url.CUSTOM,"")
|
||||
|
||||
def serialize(self):
|
||||
return (self.private,self.path,self.desc,self.type)
|
||||
|
||||
def unserialize(self,data):
|
||||
(self.private,self.path,self.desc,self.type) = data
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Returns the list of all textual attributes of the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -55,6 +55,12 @@ class UrlBase:
|
||||
else:
|
||||
self.urls = []
|
||||
|
||||
def serialize(self):
|
||||
return [url.serialize() for url in self.urls]
|
||||
|
||||
def unserialize(self,data):
|
||||
self.urls = [Url().unserialize(item) for item in data]
|
||||
|
||||
def get_url_list(self):
|
||||
"""
|
||||
Returns the list of L{Url} instances associated with the object.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -25,6 +25,9 @@
|
||||
__author__ = "Donald N. Allingham"
|
||||
__version__ = "$Revision$"
|
||||
|
||||
# Dates
|
||||
from _Date import Date, DateError
|
||||
|
||||
# Secondary objects
|
||||
from _Address import Address
|
||||
from _Location import Location
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -30,7 +30,6 @@ A collection of utilities to aid in the generation of reports.
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import Date
|
||||
import DateHandler
|
||||
import RelLib
|
||||
from NameDisplay import displayer as _nd
|
||||
@ -1040,14 +1039,14 @@ def estimate_age(db, person, end_handle=None, start_handle=None):
|
||||
else:
|
||||
return high[2] - low[2]
|
||||
|
||||
if bstop == Date.EMPTY and dstop == Date.EMPTY:
|
||||
if bstop == RelLib.Date.EMPTY and dstop == RelLib.Date.EMPTY:
|
||||
lower = _calc_diff(bstart,dstart)
|
||||
age = (lower, lower)
|
||||
elif bstop == Date.EMPTY:
|
||||
elif bstop == RelLib.Date.EMPTY:
|
||||
lower = _calc_diff(bstart,dstart)
|
||||
upper = _calc_diff(bstart,dstop)
|
||||
age = (lower,upper)
|
||||
elif dstop == Date.EMPTY:
|
||||
elif dstop == RelLib.Date.EMPTY:
|
||||
lower = _calc_diff(bstop,dstart)
|
||||
upper = _calc_diff(bstart,dstart)
|
||||
age = (lower,upper)
|
||||
@ -1316,7 +1315,7 @@ def get_birth_death_strings(database,person,empty_date="",empty_place=""):
|
||||
bplace = database.get_place_from_handle(bplace_handle).get_title()
|
||||
bdate_obj = birth.get_date_object()
|
||||
bdate_full = bdate_obj and bdate_obj.get_day_valid()
|
||||
bdate_mod = bdate_obj and bdate_obj.get_modifier() != Date.MOD_NONE
|
||||
bdate_mod = bdate_obj and bdate_obj.get_modifier() != RelLib.Date.MOD_NONE
|
||||
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref and death_ref.ref:
|
||||
@ -1329,7 +1328,7 @@ def get_birth_death_strings(database,person,empty_date="",empty_place=""):
|
||||
dplace = database.get_place_from_handle(dplace_handle).get_title()
|
||||
ddate_obj = death.get_date_object()
|
||||
ddate_full = ddate_obj and ddate_obj.get_day_valid()
|
||||
ddate_mod = ddate_obj and ddate_obj.get_modifier() != Date.MOD_NONE
|
||||
ddate_mod = ddate_obj and ddate_obj.get_modifier() != RelLib.Date.MOD_NONE
|
||||
|
||||
return (bdate,bplace,bdate_full,bdate_mod,ddate,dplace,ddate_full,ddate_mod)
|
||||
|
||||
@ -1594,7 +1593,7 @@ def married_str(database,person,spouse,event,endnotes=None,
|
||||
|
||||
dobj = event.get_date_object()
|
||||
|
||||
if dobj.get_modifier() != Date.MOD_NONE:
|
||||
if dobj.get_modifier() != RelLib.Date.MOD_NONE:
|
||||
date_full = 2
|
||||
elif dobj and dobj.get_day_valid():
|
||||
date_full = 1
|
||||
@ -1980,7 +1979,7 @@ def buried_str(database,person,person_name=None,empty_date="",empty_place=""):
|
||||
bplace = database.get_place_from_handle(bplace_handle).get_title()
|
||||
bdate_obj = burial.get_date_object()
|
||||
bdate_full = bdate_obj and bdate_obj.get_day_valid()
|
||||
bdate_mod = bdate_obj and bdate_obj.get_modifier() != Date.MOD_NONE
|
||||
bdate_mod = bdate_obj and bdate_obj.get_modifier() != RelLib.Date.MOD_NONE
|
||||
else:
|
||||
return text
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +46,6 @@ import cPickle as pickle
|
||||
import const
|
||||
import Utils
|
||||
import RelLib
|
||||
import Date
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import AutoComp
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -49,7 +49,6 @@ import PeopleModel
|
||||
import NameDisplay
|
||||
import AutoComp
|
||||
import GenericFilter
|
||||
import Date
|
||||
import GrampsDisplay
|
||||
from QuestionDialog import ErrorDialog
|
||||
from WindowUtils import GladeIf
|
||||
@ -337,7 +336,7 @@ class LikelyFilter(GenericFilter.Rule):
|
||||
person = db.get_person_from_handle(self.list[0])
|
||||
if person.birth_handle:
|
||||
birth = db.get_event_from_handle(person.birth_handle)
|
||||
dateobj = Date.Date(birth.date)
|
||||
dateobj = RelLib.Date(birth.date)
|
||||
year = dateobj.get_year()
|
||||
dateobj.set_year(year+10)
|
||||
self.lower = dateobj.sortval
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -39,7 +39,7 @@ import locale
|
||||
# GRAMPS Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from NameDisplay import displayer as _nd
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -103,13 +103,13 @@ class Sort:
|
||||
if birth_handle1:
|
||||
date1 = self.database.get_event_from_handle(birth_handle1).get_date_object()
|
||||
else:
|
||||
date1 = Date.Date()
|
||||
date1 = Date()
|
||||
|
||||
birth_handle2 = second.get_birth_handle()
|
||||
if birth_handle2:
|
||||
date2 = self.database.get_event_from_handle(birth_handle2).get_date_object()
|
||||
else:
|
||||
date2 = Date.Date()
|
||||
date2 = Date()
|
||||
|
||||
dsv1 = date1.get_sort_value()
|
||||
dsv2 = date2.get_sort_value()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import cPickle as pickle
|
||||
import const
|
||||
import Utils
|
||||
import RelLib
|
||||
import Date
|
||||
import DateEdit
|
||||
import DateHandler
|
||||
import GrampsDisplay
|
||||
@ -402,7 +401,7 @@ class SourceEditor(DisplayState.ManagedWindow):
|
||||
self.date_entry_field.set_text(date_str)
|
||||
self.private.set_active(self.source_ref.get_privacy())
|
||||
else:
|
||||
self.date_obj = Date.Date()
|
||||
self.date_obj = RelLib.Date()
|
||||
self.active_source = None
|
||||
|
||||
date_stat = self.get_widget("date_stat")
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import gtk.gdk
|
||||
import const
|
||||
import GrampsMime
|
||||
import NameDisplay
|
||||
import Date
|
||||
import RelLib
|
||||
import Errors
|
||||
|
||||
@ -791,7 +790,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
# things are simple.
|
||||
if person.death_ref:
|
||||
death = db.get_event_from_handle(person.death_ref.ref)
|
||||
if death.get_date_object().get_start_date() != Date.EMPTY:
|
||||
if death.get_date_object().get_start_date() != RelLib.Date.EMPTY:
|
||||
death_year = death.get_date_object().get_year()
|
||||
if death_year - limit < current_year:
|
||||
return False
|
||||
@ -804,7 +803,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
RelLib.Event.CREMATION]:
|
||||
if not death_year:
|
||||
death_year = ev.get_date_object().get_year()
|
||||
if ev.get_date_object().get_start_date() != Date.EMPTY:
|
||||
if ev.get_date_object().get_start_date() != RelLib.Date.EMPTY:
|
||||
if ev.get_date_object().get_year() - limit < current_year:
|
||||
return False
|
||||
# For any other event of this person, check whether it happened
|
||||
@ -817,7 +816,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
# assume they are alive (we already know they are not dead).
|
||||
if person.birth_ref:
|
||||
birth = db.get_event_from_handle(person.birth_ref.ref)
|
||||
if birth.get_date_object().get_start_date() != Date.EMPTY:
|
||||
if birth.get_date_object().get_start_date() != RelLib.Date.EMPTY:
|
||||
if not birth_year:
|
||||
birth_year = birth.get_date_object().get_year()
|
||||
# Check whether the birth event is too old because the
|
||||
@ -846,8 +845,8 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if child.birth_ref:
|
||||
child_birth = db.get_event_from_handle(child.birth_ref.ref)
|
||||
dobj = child_birth.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
d = Date.Date(dobj)
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
d = RelLib.Date(dobj)
|
||||
val = d.get_start_date()
|
||||
val = d.get_year() - years
|
||||
d.set_year(val)
|
||||
@ -857,7 +856,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if child.death_ref:
|
||||
child_death = db.get_event_from_handle(child.death_ref.ref)
|
||||
dobj = child_death.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
if not not_too_old (dobj,current_year):
|
||||
return True
|
||||
|
||||
@ -890,7 +889,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if father.birth_ref:
|
||||
father_birth = db.get_event_from_handle(father.birth_ref.ref)
|
||||
dobj = father_birth.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
if not not_too_old (dobj,year - average_generation_gap):
|
||||
#print father.get_primary_name().get_name(), " father of ", person.get_primary_name().get_name(), " is too old by birth. birth year ", dobj.get_year(), " test year ", year - average_generation_gap
|
||||
return True
|
||||
@ -901,7 +900,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if father.death_ref:
|
||||
father_death = db.get_event_from_handle(father.death_ref.ref)
|
||||
dobj = father_death.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
if dobj.get_year() < year - average_generation_gap:
|
||||
#print father.get_primary_name().get_name(), " father of ", person.get_primary_name().get_name(), " is too old by death."
|
||||
return True
|
||||
@ -915,7 +914,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if mother.birth_ref:
|
||||
mother_birth = db.get_event_from_handle(mother.birth_ref.ref)
|
||||
dobj = mother_birth.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
if not not_too_old (dobj,year - average_generation_gap):
|
||||
#print mother.get_primary_name().get_name(), " mother of ", person.get_primary_name().get_name(), " is too old by birth. birth year ", dobj.get_year(), " test year ", year - average_generation_gap
|
||||
return True
|
||||
@ -926,7 +925,7 @@ def probably_alive(person,db,current_year=None,limit=0):
|
||||
if mother.death_ref:
|
||||
mother_death = db.get_event_from_handle(mother.death_ref.ref)
|
||||
dobj = mother_death.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
if dobj.get_start_date() != RelLib.Date.EMPTY:
|
||||
if dobj.get_year() < year - average_generation_gap:
|
||||
#print mother.get_primary_name().get_name(), " mother of ", person.get_primary_name().get_name(), " is too old by death."
|
||||
return True
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -43,7 +43,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -37,7 +37,7 @@ import re
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from RelLib import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004 Martin Hawlisch
|
||||
# Copyright (C) 2005 Donald N. Allingham
|
||||
# Copyright (C) 2005-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +46,7 @@ import gtk.glade
|
||||
import GenericFilter
|
||||
import const
|
||||
import Utils
|
||||
import Date
|
||||
from RelLib import Date
|
||||
import Errors
|
||||
from gettext import gettext as _
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004 Martin Hawlisch
|
||||
# Copyright (C) 2005 Donald N. Allingham
|
||||
# Copyright (C) 2005-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@ import gtk.glade
|
||||
#-------------------------------------------------------------------------
|
||||
import GenericFilter
|
||||
import const
|
||||
import Date
|
||||
from RelLib import Date
|
||||
import Errors
|
||||
from gettext import gettext as _
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
@ -46,7 +46,6 @@ import gtk.glade
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import RelLib
|
||||
import Date
|
||||
import const
|
||||
from QuestionDialog import ErrorDialog
|
||||
from DateHandler import parser as _dp
|
||||
@ -56,15 +55,15 @@ _date_parse = re.compile('([~?<>]+)?([0-9/]+)([J|H|F])?(\.\.)?([0-9/]+)?([J|H|F]
|
||||
_text_parse = re.compile('0\((.*)\)')
|
||||
|
||||
_mod_map = {
|
||||
'>' : Date.MOD_AFTER,
|
||||
'<' : Date.MOD_BEFORE,
|
||||
'~' : Date.MOD_ABOUT,
|
||||
'>' : RelLib.Date.MOD_AFTER,
|
||||
'<' : RelLib.Date.MOD_BEFORE,
|
||||
'~' : RelLib.Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
_cal_map = {
|
||||
'J' : Date.CAL_JULIAN,
|
||||
'H' : Date.CAL_HEBREW,
|
||||
'F' : Date.CAL_FRENCH,
|
||||
'J' : RelLib.Date.CAL_JULIAN,
|
||||
'H' : RelLib.Date.CAL_HEBREW,
|
||||
'F' : RelLib.Date.CAL_FRENCH,
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -650,27 +649,27 @@ class GeneWebParser:
|
||||
def parse_date(self,field):
|
||||
if field == "0":
|
||||
return None
|
||||
date = Date.Date()
|
||||
date = RelLib.Date()
|
||||
matches = _text_parse.match(field)
|
||||
if matches:
|
||||
groups = matches.groups()
|
||||
date.set_as_text(groups[0])
|
||||
date.set_modifier(Date.MOD_TEXTONLY)
|
||||
date.set_modifier(RelLib.Date.MOD_TEXTONLY)
|
||||
return date
|
||||
|
||||
matches = _date_parse.match(field)
|
||||
if matches:
|
||||
groups = matches.groups()
|
||||
mod = _mod_map.get(groups[0],Date.MOD_NONE)
|
||||
mod = _mod_map.get(groups[0],RelLib.Date.MOD_NONE)
|
||||
if groups[3] == "..":
|
||||
mod = Date.MOD_SPAN
|
||||
cal2 = _cal_map.get(groups[5],Date.CAL_GREGORIAN)
|
||||
mod = RelLib.Date.MOD_SPAN
|
||||
cal2 = _cal_map.get(groups[5],RelLib.Date.CAL_GREGORIAN)
|
||||
sub2 = self.sub_date(groups[4])
|
||||
else:
|
||||
sub2 = (0,0,0)
|
||||
cal1 = _cal_map.get(groups[2],Date.CAL_GREGORIAN)
|
||||
cal1 = _cal_map.get(groups[2],RelLib.Date.CAL_GREGORIAN)
|
||||
sub1 = self.sub_date(groups[1])
|
||||
date.set(Date.QUAL_NONE,mod, cal1,
|
||||
date.set(RelLib.Date.QUAL_NONE,mod, cal1,
|
||||
(sub1[0],sub1[1],sub1[2],None,sub2[0],sub2[1],sub2[2],None))
|
||||
return date
|
||||
else:
|
||||
|
@ -47,7 +47,6 @@ import gtk.glade
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import Date
|
||||
import RelLib
|
||||
import Tool
|
||||
import const
|
||||
@ -647,61 +646,71 @@ class TestcaseGenerator(Tool.Tool):
|
||||
def generate_date_tests(self):
|
||||
dates = []
|
||||
# first some valid dates
|
||||
calendar = Date.CAL_GREGORIAN
|
||||
for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED):
|
||||
for modifier in (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER, Date.MOD_ABOUT):
|
||||
calendar = RelLib.Date.CAL_GREGORIAN
|
||||
for quality in (RelLib.Date.QUAL_NONE, RelLib.Date.QUAL_ESTIMATED,
|
||||
RelLib.Date.QUAL_CALCULATED):
|
||||
for modifier in (RelLib.Date.MOD_NONE, RelLib.Date.MOD_BEFORE,
|
||||
RelLib.Date.MOD_AFTER, RelLib.Date.MOD_ABOUT):
|
||||
for slash1 in (False,True):
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
d.set(quality,modifier,calendar,(4,7,1789,slash1),"Text comment")
|
||||
dates.append( d)
|
||||
for modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||
for modifier in (RelLib.Date.MOD_RANGE, RelLib.Date.MOD_SPAN):
|
||||
for slash1 in (False,True):
|
||||
for slash2 in (False,True):
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
d.set(quality,modifier,calendar,(4,7,1789,slash1,5,8,1876,slash2),"Text comment")
|
||||
dates.append( d)
|
||||
modifier = Date.MOD_TEXTONLY
|
||||
d = Date.Date()
|
||||
d.set(quality,modifier,calendar,Date.EMPTY,"This is a textual date")
|
||||
modifier = RelLib.Date.MOD_TEXTONLY
|
||||
d = RelLib.Date()
|
||||
d.set(quality,modifier,calendar,RelLib.Date.EMPTY,
|
||||
"This is a textual date")
|
||||
dates.append( d)
|
||||
|
||||
# test invalid dates
|
||||
dateval = (4,7,1789,False,5,8,1876,False)
|
||||
for l in range(1,len(dateval)):
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
try:
|
||||
d.set(Date.QUAL_NONE,Date.MOD_NONE,Date.CAL_GREGORIAN,dateval[:l],"Text comment")
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_NONE,
|
||||
RelLib.Date.CAL_GREGORIAN,dateval[:l],"Text comment")
|
||||
dates.append( d)
|
||||
except Errors.DateError, e:
|
||||
d.set_as_text("Date identified value correctly as invalid.\n%s" % e)
|
||||
dates.append( d)
|
||||
except:
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
||||
dates.append( d)
|
||||
for l in range(1,len(dateval)):
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
try:
|
||||
d.set(Date.QUAL_NONE,Date.MOD_SPAN,Date.CAL_GREGORIAN,dateval[:l],"Text comment")
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_SPAN,RelLib.Date.CAL_GREGORIAN,dateval[:l],"Text comment")
|
||||
dates.append( d)
|
||||
except Errors.DateError, e:
|
||||
d.set_as_text("Date identified value correctly as invalid.\n%s" % e)
|
||||
dates.append( d)
|
||||
except:
|
||||
d = Date.Date()
|
||||
d = RelLib.Date()
|
||||
d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
||||
dates.append( d)
|
||||
d = Date.Date()
|
||||
d.set(Date.QUAL_NONE,Date.MOD_NONE,Date.CAL_GREGORIAN,(44,7,1789,False),"Text comment")
|
||||
d = RelLib.Date()
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_NONE,
|
||||
RelLib.Date.CAL_GREGORIAN,(44,7,1789,False),"Text comment")
|
||||
dates.append( d)
|
||||
d = Date.Date()
|
||||
d.set(Date.QUAL_NONE,Date.MOD_NONE,Date.CAL_GREGORIAN,(4,77,1789,False),"Text comment")
|
||||
d = RelLib.Date()
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_NONE,
|
||||
RelLib.Date.CAL_GREGORIAN,(4,77,1789,False),"Text comment")
|
||||
dates.append( d)
|
||||
d = Date.Date()
|
||||
d.set(Date.QUAL_NONE,Date.MOD_SPAN,Date.CAL_GREGORIAN,(4,7,1789,False,55,8,1876,False),"Text comment")
|
||||
d = RelLib.Date()
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_SPAN,
|
||||
RelLib.Date.CAL_GREGORIAN,
|
||||
(4,7,1789,False,55,8,1876,False),"Text comment")
|
||||
dates.append( d)
|
||||
d = Date.Date()
|
||||
d.set(Date.QUAL_NONE,Date.MOD_SPAN,Date.CAL_GREGORIAN,(4,7,1789,False,5,88,1876,False),"Text comment")
|
||||
d = RelLib.Date()
|
||||
d.set(RelLib.Date.QUAL_NONE,RelLib.Date.MOD_SPAN,
|
||||
RelLib.Date.CAL_GREGORIAN,
|
||||
(4,7,1789,False,5,88,1876,False),"Text comment")
|
||||
dates.append( d)
|
||||
|
||||
# now add them as birth to new persons
|
||||
@ -721,16 +730,17 @@ class TestcaseGenerator(Tool.Tool):
|
||||
try:
|
||||
ndate = _dp.parse( datestr)
|
||||
if not ndate:
|
||||
ndate = Date.Date()
|
||||
ndate = RelLib.Date()
|
||||
ndate.set_as_text("DateParser None")
|
||||
except:
|
||||
ndate = Date.Date()
|
||||
ndate = RelLib.Date()
|
||||
ndate.set_as_text("DateParser Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
||||
except:
|
||||
ndate = Date.Date()
|
||||
ndate = RelLib.Date()
|
||||
ndate.set_as_text("DateDisplay Exception: %s" % ("".join(traceback.format_exception(*sys.exc_info())),))
|
||||
|
||||
if dateval.get_modifier() != Date.MOD_TEXTONLY and ndate.get_modifier() == Date.MOD_TEXTONLY:
|
||||
if dateval.get_modifier() != RelLib.Date.MOD_TEXTONLY \
|
||||
and ndate.get_modifier() == RelLib.Date.MOD_TEXTONLY:
|
||||
# parser was unable to correctly parse the string
|
||||
ndate.set_as_text( "TEXTONLY: "+ndate.get_text())
|
||||
|
||||
@ -1029,7 +1039,7 @@ class TestcaseGenerator(Tool.Tool):
|
||||
start = end - randint(0,100)
|
||||
year = randint(start,end)
|
||||
|
||||
ndate = Date.Date()
|
||||
ndate = RelLib.Date()
|
||||
if randint(0,10) == 1:
|
||||
# Some get a textual date
|
||||
ndate.set_as_text( choice((self.rand_text(self.SHORT),"Unknown","??","Don't know","TODO!")))
|
||||
@ -1039,17 +1049,23 @@ class TestcaseGenerator(Tool.Tool):
|
||||
pass
|
||||
else:
|
||||
# regular dates
|
||||
calendar = Date.CAL_GREGORIAN
|
||||
quality = choice( (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED))
|
||||
modifier = choice( (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER,\
|
||||
Date.MOD_ABOUT, Date.MOD_RANGE, Date.MOD_SPAN))
|
||||
calendar = RelLib.Date.CAL_GREGORIAN
|
||||
quality = choice( (RelLib.Date.QUAL_NONE,
|
||||
RelLib.Date.QUAL_ESTIMATED,
|
||||
RelLib.Date.QUAL_CALCULATED))
|
||||
modifier = choice( (RelLib.Date.MOD_NONE,
|
||||
RelLib.Date.MOD_BEFORE,
|
||||
RelLib.Date.MOD_AFTER,\
|
||||
RelLib.Date.MOD_ABOUT,
|
||||
RelLib.Date.MOD_RANGE,
|
||||
RelLib.Date.MOD_SPAN))
|
||||
day = randint(0,28)
|
||||
if day > 0: # avoid days without month
|
||||
month = randint(1,12)
|
||||
else:
|
||||
month = randint(0,12)
|
||||
|
||||
if modifier in (Date.MOD_RANGE, Date.MOD_SPAN):
|
||||
if modifier in (RelLib.Date.MOD_RANGE, RelLib.Date.MOD_SPAN):
|
||||
day2 = randint(0,28)
|
||||
if day2 > 0:
|
||||
month2 = randint(1,12)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2000-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import GrampsDisplay
|
||||
#------------------------------------------------------------------------
|
||||
import RelLib
|
||||
import Utils
|
||||
import Date
|
||||
import Tool
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -160,8 +159,8 @@ class Verify(Tool.Tool):
|
||||
event = self.db.get_event_from_handle(event_handle)
|
||||
dateObj = event.get_date_object()
|
||||
if dateObj:
|
||||
if dateObj.get_calendar() != Date.CAL_GREGORIAN:
|
||||
dateObj.set_calendar(Date.CAL_GREGORIAN)
|
||||
if dateObj.get_calendar() != RelLib.Date.CAL_GREGORIAN:
|
||||
dateObj.set_calendar(RelLib.Date.CAL_GREGORIAN)
|
||||
year = dateObj.get_year()
|
||||
return year
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004 Martin Hawlisch
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
# Copyright (C) 2004-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -47,7 +47,6 @@ import RelLib
|
||||
import GenericFilter
|
||||
import const
|
||||
import Utils
|
||||
import Date
|
||||
import Errors
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
@ -528,19 +527,19 @@ class GeneWebWriter:
|
||||
(day,month,year,sl) = subdate
|
||||
|
||||
cal_type = ""
|
||||
if cal == Date.CAL_HEBREW:
|
||||
if cal == RelLib.Date.CAL_HEBREW:
|
||||
cal_type = "H"
|
||||
elif cal == Date.CAL_FRENCH:
|
||||
elif cal == RelLib.Date.CAL_FRENCH:
|
||||
cal_type = "F"
|
||||
elif cal == Date.CAL_JULIAN:
|
||||
elif cal == RelLib.Date.CAL_JULIAN:
|
||||
cal_type = "J"
|
||||
|
||||
mode_prefix = ""
|
||||
if mode == Date.MOD_ABOUT:
|
||||
if mode == RelLib.Date.MOD_ABOUT:
|
||||
mode_prefix = "~"
|
||||
elif mode == Date.MOD_BEFORE:
|
||||
elif mode == RelLib.Date.MOD_BEFORE:
|
||||
mode_prefix = "<"
|
||||
elif mode == Date.MOD_AFTER:
|
||||
elif mode == RelLib.Date.MOD_AFTER:
|
||||
mode_prefix = ">"
|
||||
|
||||
if year > 0:
|
||||
@ -563,9 +562,10 @@ class GeneWebWriter:
|
||||
elif not date.is_empty():
|
||||
mod = date.get_modifier()
|
||||
cal = cal = date.get_calendar()
|
||||
if mod == Date.MOD_SPAN or mod == Date.MOD_RANGE:
|
||||
retval = "%s..%s" % (self.format_single_date(date.get_start_date(), cal,mod),
|
||||
self.format_single_date(date.get_stop_date(),cal,mod))
|
||||
if mod == RelLib.Date.MOD_SPAN or mod == RelLib.Date.MOD_RANGE:
|
||||
retval = "%s..%s" % (
|
||||
self.format_single_date(date.get_start_date(), cal,mod),
|
||||
self.format_single_date(date.get_stop_date(),cal,mod))
|
||||
else:
|
||||
retval = self.format_single_date(date.get_start_date(),cal,mod)
|
||||
return retval
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2003-2005 Donald N. Allingham
|
||||
# Copyright (C) 2003-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -31,7 +31,6 @@
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
import RelLib
|
||||
import Date
|
||||
import Relationship
|
||||
from PluginMgr import register_relcalc
|
||||
import types
|
||||
@ -155,7 +154,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator):
|
||||
other_birth_event = other_person.get_birth()
|
||||
other_birth_date = other_birth_event.get_date_object()
|
||||
if (orig_birth_date == "")or(other_birth_date == "") :return 0
|
||||
else :return Date.compare_dates(orig_birth_date,other_birth_date)
|
||||
else :return RelLib.Date.compare_dates(orig_birth_date,other_birth_date)
|
||||
|
||||
|
||||
def get_age_brother (self,level):
|
||||
|
Loading…
x
Reference in New Issue
Block a user