Upgrade the database some more for version 14: new int on dates for newyear
svn: r10495
This commit is contained in:
parent
a79a82faf5
commit
1644727587
@ -499,7 +499,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
|||||||
|
|
||||||
if callback:
|
if callback:
|
||||||
callback(25)
|
callback(25)
|
||||||
self.metadata = self.__open_table(self.full_name, META)
|
self.metadata = self.__open_table(self.full_name, META)
|
||||||
|
|
||||||
# If we cannot work with this DB version,
|
# If we cannot work with this DB version,
|
||||||
# it makes no sense to go further
|
# it makes no sense to go further
|
||||||
@ -1712,11 +1712,32 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
|||||||
the_txn.commit()
|
the_txn.commit()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
# modifies dates: adds an integer for newyear code.
|
||||||
|
length = len(self.event_map)
|
||||||
|
self.set_total(length)
|
||||||
|
for handle in self.event_map.keys():
|
||||||
|
event = self.event_map[handle]
|
||||||
|
(junk_handle, gramps_id, the_type, date, description, place,
|
||||||
|
source_list, note_list, media_list, attribute_list,
|
||||||
|
change, marker, private) = event
|
||||||
|
if date != None:
|
||||||
|
(calendar, modifier, quality, dateval, text, sortval) = date
|
||||||
|
newyear = 0
|
||||||
|
new_date = (calendar, modifier, quality, dateval,text,sortval,
|
||||||
|
newyear)
|
||||||
|
new_event = (junk_handle, gramps_id, the_type, new_date,
|
||||||
|
description, place, source_list, note_list,
|
||||||
|
media_list, attribute_list, change,marker,private)
|
||||||
|
the_txn = self.env.txn_begin()
|
||||||
|
self.event_map.put(str(handle), new_event, txn=the_txn)
|
||||||
|
the_txn.commit()
|
||||||
|
self.update()
|
||||||
|
|
||||||
# Bump up database version. Separate transaction to save metadata.
|
# Bump up database version. Separate transaction to save metadata.
|
||||||
the_txn = self.env.txn_begin()
|
the_txn = self.env.txn_begin()
|
||||||
self.metadata.put('version', 14, txn=the_txn)
|
self.metadata.put('version', 14, txn=the_txn)
|
||||||
the_txn.commit()
|
the_txn.commit()
|
||||||
|
|
||||||
def write_version(self, name):
|
def write_version(self, name):
|
||||||
"""Write version number for a newly created DB."""
|
"""Write version number for a newly created DB."""
|
||||||
full_name = os.path.abspath(name)
|
full_name = os.path.abspath(name)
|
||||||
@ -1753,7 +1774,6 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback):
|
|||||||
self.metadata.close()
|
self.metadata.close()
|
||||||
self.env.close()
|
self.env.close()
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# BdbTransaction
|
# BdbTransaction
|
||||||
|
@ -80,7 +80,7 @@ class Date:
|
|||||||
|
|
||||||
Supports partial dates, compound dates and alternate calendars.
|
Supports partial dates, compound dates and alternate calendars.
|
||||||
"""
|
"""
|
||||||
MOD_NONE = 0
|
MOD_NONE = 0 # CODE
|
||||||
MOD_BEFORE = 1
|
MOD_BEFORE = 1
|
||||||
MOD_AFTER = 2
|
MOD_AFTER = 2
|
||||||
MOD_ABOUT = 3
|
MOD_ABOUT = 3
|
||||||
@ -88,17 +88,23 @@ class Date:
|
|||||||
MOD_SPAN = 5
|
MOD_SPAN = 5
|
||||||
MOD_TEXTONLY = 6
|
MOD_TEXTONLY = 6
|
||||||
|
|
||||||
QUAL_NONE = 0
|
QUAL_NONE = 0 # BITWISE
|
||||||
QUAL_ESTIMATED = 1
|
QUAL_ESTIMATED = 1
|
||||||
QUAL_CALCULATED = 2
|
QUAL_CALCULATED = 2
|
||||||
|
QUAL_INTERPRETED = 4
|
||||||
|
|
||||||
CAL_GREGORIAN = 0
|
CAL_GREGORIAN = 0 # CODE
|
||||||
CAL_JULIAN = 1
|
CAL_JULIAN = 1
|
||||||
CAL_HEBREW = 2
|
CAL_HEBREW = 2
|
||||||
CAL_FRENCH = 3
|
CAL_FRENCH = 3
|
||||||
CAL_PERSIAN = 4
|
CAL_PERSIAN = 4
|
||||||
CAL_ISLAMIC = 5
|
CAL_ISLAMIC = 5
|
||||||
|
|
||||||
|
NEWYEAR_JAN1 = 0 # CODE
|
||||||
|
NEWYEAR_MAR1 = 1
|
||||||
|
NEWYEAR_MAR25 = 2
|
||||||
|
NEWYEAR_SEP1 = 3
|
||||||
|
|
||||||
EMPTY = (0, 0, 0, False)
|
EMPTY = (0, 0, 0, False)
|
||||||
|
|
||||||
_POS_DAY = 0
|
_POS_DAY = 0
|
||||||
@ -181,6 +187,7 @@ class Date:
|
|||||||
self.dateval = Date.EMPTY
|
self.dateval = Date.EMPTY
|
||||||
self.text = u""
|
self.text = u""
|
||||||
self.sortval = 0
|
self.sortval = 0
|
||||||
|
self.newyear = 0
|
||||||
self.set_yr_mon_day(*source)
|
self.set_yr_mon_day(*source)
|
||||||
elif type(source) == str:
|
elif type(source) == str:
|
||||||
if (calendar != None or
|
if (calendar != None or
|
||||||
@ -196,6 +203,7 @@ class Date:
|
|||||||
self.dateval = source.dateval
|
self.dateval = source.dateval
|
||||||
self.text = source.text
|
self.text = source.text
|
||||||
self.sortval = source.sortval
|
self.sortval = source.sortval
|
||||||
|
self.newyear = source.newyear
|
||||||
elif source:
|
elif source:
|
||||||
self.calendar = source.calendar
|
self.calendar = source.calendar
|
||||||
self.modifier = source.modifier
|
self.modifier = source.modifier
|
||||||
@ -203,6 +211,7 @@ class Date:
|
|||||||
self.dateval = source.dateval
|
self.dateval = source.dateval
|
||||||
self.text = source.text
|
self.text = source.text
|
||||||
self.sortval = source.sortval
|
self.sortval = source.sortval
|
||||||
|
self.newyear = source.newyear
|
||||||
else:
|
else:
|
||||||
self.calendar = Date.CAL_GREGORIAN
|
self.calendar = Date.CAL_GREGORIAN
|
||||||
self.modifier = Date.MOD_NONE
|
self.modifier = Date.MOD_NONE
|
||||||
@ -210,6 +219,7 @@ class Date:
|
|||||||
self.dateval = Date.EMPTY
|
self.dateval = Date.EMPTY
|
||||||
self.text = u""
|
self.text = u""
|
||||||
self.sortval = 0
|
self.sortval = 0
|
||||||
|
self.newyear = Date.NEWYEAR_JAN1
|
||||||
|
|
||||||
def serialize(self, no_text_date=False):
|
def serialize(self, no_text_date=False):
|
||||||
"""
|
"""
|
||||||
@ -221,14 +231,14 @@ class Date:
|
|||||||
text = self.text
|
text = self.text
|
||||||
|
|
||||||
return (self.calendar, self.modifier, self.quality,
|
return (self.calendar, self.modifier, self.quality,
|
||||||
self.dateval, text, self.sortval)
|
self.dateval, text, self.sortval, self.newyear)
|
||||||
|
|
||||||
def unserialize(self, data):
|
def unserialize(self, data):
|
||||||
"""
|
"""
|
||||||
Load from the format created by serialize.
|
Load from the format created by serialize.
|
||||||
"""
|
"""
|
||||||
(self.calendar, self.modifier, self.quality,
|
(self.calendar, self.modifier, self.quality,
|
||||||
self.dateval, self.text, self.sortval) = data
|
self.dateval, self.text, self.sortval, self.newyear) = data
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def copy(self, source):
|
def copy(self, source):
|
||||||
@ -242,6 +252,7 @@ class Date:
|
|||||||
self.dateval = source.dateval
|
self.dateval = source.dateval
|
||||||
self.text = source.text
|
self.text = source.text
|
||||||
self.sortval = source.sortval
|
self.sortval = source.sortval
|
||||||
|
self.newyear = source.newyear
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user