Calendar enhancements
svn: r1235
This commit is contained in:
parent
ddf9ef9389
commit
1c902e0eef
1207
src/Calendar.py
1207
src/Calendar.py
File diff suppressed because it is too large
Load Diff
580
src/Date.py
580
src/Date.py
@ -42,68 +42,18 @@ from intl import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Calendar Mappings
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
GREGORIAN = 0
|
||||
JULIAN = 1
|
||||
HEBREW = 2
|
||||
FRENCH = 3
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Month mappings
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_fmonth = [
|
||||
unicode("Vendémiaire",'latin-1'), unicode("Brumaire",'latin-1'),
|
||||
unicode("Frimaire",'latin-1'), unicode("Nivôse",'latin-1'),
|
||||
unicode("Pluviôse",'latin-1'), unicode("Ventôse",'latin-1'),
|
||||
unicode("Germinal",'latin-1'), unicode("Floréal",'latin-1'),
|
||||
unicode("Prairial",'latin-1'), unicode("Messidor",'latin-1'),
|
||||
unicode("Thermidor",'latin-1'), unicode("Fructidor",'latin-1'),
|
||||
unicode("Extra",'latin-1'),
|
||||
]
|
||||
|
||||
_fmonth2num = {
|
||||
"vend" : 0, "brum" : 1, "frim" : 2, "nivo" : 3, "pluv" : 4, "vent" : 5,
|
||||
"germ" : 6, "flor" : 7, "prai" : 8, "mess" : 9, "ther" :10, "fruc" :11,
|
||||
"extr" : 12,"comp" :12, unicode("nivô",'latin-1') : 3
|
||||
}
|
||||
|
||||
_hmonth = [
|
||||
"Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI",
|
||||
"AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av",
|
||||
"Elul",
|
||||
]
|
||||
|
||||
_hmonth2num = {
|
||||
"tishri" : 0, "heshvan" : 1, "kislev" : 2, "tevet" : 3,
|
||||
"shevat" : 4, "adari" : 5, "adarii" : 6, "nisan" : 7,
|
||||
"iyyar" : 8, "sivan" : 9, "tammuz" :10, "av" : 11,
|
||||
"elul" : 12,"tsh" : 0, "csh" : 1, "ksl" : 2,
|
||||
"tvt" : 3, "shv" : 4, "adr" : 5, "ads" : 6,
|
||||
"nsn" : 7, "iyr" : 8, "svn" : 9, "tmz" : 10,
|
||||
"aav" :11, "ell" :12,
|
||||
}
|
||||
|
||||
_mname = [
|
||||
_("January"), _("February"), _("March"), _("April"),
|
||||
_("May"), _("June"), _("July"), _("August"),
|
||||
_("September"), _("October"), _("November"), _("December")
|
||||
]
|
||||
|
||||
_m2num = {
|
||||
string.lower(_mname[0][0:3]): 0, string.lower(_mname[1][0:3]): 1,
|
||||
string.lower(_mname[2][0:3]): 2, string.lower(_mname[3][0:3]): 3,
|
||||
string.lower(_mname[4][0:3]): 4, string.lower(_mname[5][0:3]): 5,
|
||||
string.lower(_mname[6][0:3]): 6, string.lower(_mname[7][0:3]): 7,
|
||||
string.lower(_mname[8][0:3]): 8, string.lower(_mname[9][0:3]): 9,
|
||||
string.lower(_mname[10][0:3]): 10, string.lower(_mname[11][0:3]): 11
|
||||
}
|
||||
|
||||
UNDEF = -999999
|
||||
|
||||
_calendar_val = [
|
||||
Calendar.Gregorian,
|
||||
Calendar.Julian,
|
||||
Calendar.Hebrew,
|
||||
Calendar.FrenchRepublic,
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Date class
|
||||
@ -115,7 +65,6 @@ class Date:
|
||||
date ranges, and alternate calendars.
|
||||
"""
|
||||
formatCode = 0
|
||||
entryCode = 0
|
||||
|
||||
Error = "Illegal Date"
|
||||
|
||||
@ -139,13 +88,26 @@ class Date:
|
||||
self.stop = None
|
||||
self.range = 0
|
||||
self.text = ""
|
||||
self.calendar = GREGORIAN
|
||||
self.calendar = Calendar.Gregorian()
|
||||
|
||||
def get_calendar(self):
|
||||
return self.calendar
|
||||
|
||||
def set_calendar(self,val):
|
||||
self.calendar = val()
|
||||
self.start.convert_to(val)
|
||||
if self.stop:
|
||||
self.stop.convert_to(val)
|
||||
|
||||
def set_calendar_obj(self,val):
|
||||
self.calendar = val
|
||||
self.start.convert_to_obj(val)
|
||||
if self.stop:
|
||||
self.stop.convert_to_obj(val)
|
||||
|
||||
def set_calendar_val(self,integer):
|
||||
val = _calendar_val[integer]
|
||||
self.calendar = val()
|
||||
self.start.convert_to(val)
|
||||
if self.stop:
|
||||
self.stop.convert_to(val)
|
||||
@ -252,61 +214,28 @@ class Date:
|
||||
def set_range(self,val):
|
||||
self.range = val
|
||||
|
||||
def get_fmt(self,func):
|
||||
if self.range == 0:
|
||||
return func(self.start)
|
||||
elif self.range == -1:
|
||||
return self.text
|
||||
else:
|
||||
d1 = func(self.start)
|
||||
d2 = func(self.stop)
|
||||
return _("from %(start_date)s to %(stop_date)s") % {
|
||||
'start_date' : d1,
|
||||
'stop_date' : d2 }
|
||||
|
||||
def getDate(self):
|
||||
return self.get_fmt(SingleDate.getDate)
|
||||
if self.range == 0:
|
||||
return self.start.getDate()
|
||||
elif self.range == -1:
|
||||
return "%s" % self.text
|
||||
else:
|
||||
return _("from %(start_date)s to %(stop_date)s") % {
|
||||
'start_date' : self.start.getDate(),
|
||||
'stop_date' : self.stop.getDate() }
|
||||
|
||||
def getQuoteDate(self):
|
||||
if self.calendar == GREGORIAN:
|
||||
return self.getGregorianQuoteDate()
|
||||
elif self.calendar == JULIAN:
|
||||
return self.get_quote_date(_mname,_("Julian"))
|
||||
elif self.calendar == HEBREW:
|
||||
return self.get_quote_date(_hmonth,_("Hebrew"))
|
||||
else:
|
||||
return self.get_quote_date(_fmonth,_("French"))
|
||||
|
||||
def getGregorianQuoteDate(self):
|
||||
if self.range == 0:
|
||||
return _func(self.start)
|
||||
return self.start.getQuoteDate()
|
||||
elif self.range == -1:
|
||||
if self.text:
|
||||
return '"%s"' % self.text
|
||||
else:
|
||||
return ''
|
||||
else:
|
||||
d1 = _func(self.start)
|
||||
d2 = _func(self.stop)
|
||||
return _("from %(start_date)s to %(stop_date)s") % {
|
||||
'start_date' : d1,
|
||||
'stop_date' : d2 }
|
||||
|
||||
def get_quote_date(self,month_map,cal_str):
|
||||
if self.range == 0:
|
||||
return "%s (%s)" % (self.start.display_calendar(month_map),cal_str)
|
||||
elif self.range == -1:
|
||||
if self.text:
|
||||
return '"%s (%s)"' % (self.text,cal_str)
|
||||
else:
|
||||
return ''
|
||||
else:
|
||||
d1 = self.start.display_calendar(month_map)
|
||||
d2 = self.stop.display_calendar(month_map)
|
||||
return _("from %(start_date)s to %(stop_date)s (%(calendar)s)") % {
|
||||
'start_date' : d1,
|
||||
'stop_data' :d2,
|
||||
'calendar' : cal_str}
|
||||
'start_date' : self.start.getQuoteDate(),
|
||||
'stop_date' : self.stop.getQuoteDate() }
|
||||
|
||||
def isEmpty(self):
|
||||
s = self.start
|
||||
@ -344,62 +273,6 @@ def get_format_code():
|
||||
class SingleDate:
|
||||
"Date handling"
|
||||
|
||||
exact = 0
|
||||
about = 1
|
||||
before = 2
|
||||
after = 3
|
||||
|
||||
emname =[
|
||||
'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
|
||||
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'
|
||||
]
|
||||
|
||||
em2num ={
|
||||
"jan" : 0, "feb" : 1, "mar" : 2, "apr" : 3,
|
||||
"may" : 4, "jun" : 5, "jul" : 6, "aug" : 7,
|
||||
"sep" : 8, "oct" : 9, "nov" : 10,"dec" : 11
|
||||
}
|
||||
|
||||
m2v = {
|
||||
_("abt") : about , _("about") : about,
|
||||
_("abt.") : about, _("est") : about ,
|
||||
_("est.") : about , _("circa") : about,
|
||||
_("around") : about, _("before") : before,
|
||||
_("bef") : before, _("bef.") : before,
|
||||
_("after") : after, _("aft.") : after,
|
||||
_("aft") : after,
|
||||
# And the untranslated versions for reading saved data from XML.
|
||||
"abt" : about, "about" : about,
|
||||
"bef" : before, "bef." : before,
|
||||
"aft." : after, "abt." : about,
|
||||
"est." : about, "est" : about,
|
||||
"after" : after, "before": before,
|
||||
"aft" : after,
|
||||
}
|
||||
|
||||
modifiers = '(' + \
|
||||
_("abt\.?") + '|' + \
|
||||
_("about") + '|' + \
|
||||
_("est\.?") + '|' + \
|
||||
_("circa") + '|' + \
|
||||
_("around") + '|' + \
|
||||
_("before") + '|' + \
|
||||
_("after") + '|' + \
|
||||
_("aft\.?") + '|' + \
|
||||
_("bef\.?") + \
|
||||
'|abt|aft|after|before|bef)'
|
||||
|
||||
start = "^\s*" + modifiers + "?\s*"
|
||||
|
||||
fmt1 = compile(start+"(\S+)(\s+\d+\s*,)?\s*([?\d]+)?\s*$", IGNORECASE)
|
||||
fmt2 = compile(start+"(\d+)\.?\s+(\S+)(\s+\d+)?\s*$", IGNORECASE)
|
||||
fmt3 = compile(start+r"([?\d]+)\s*[./-]\s*([?\d]+)\s*[./-]\s*([?\d]+)\s*$",
|
||||
IGNORECASE)
|
||||
fmt7 = compile(start+r"([?\d]+)\s*[./-]\s*([?\d]+)\s*$", IGNORECASE)
|
||||
fmt4 = compile(start+"(\S+)\s+(\d+)\s*$", IGNORECASE)
|
||||
fmt5 = compile(start+"(\d+)\s*$", IGNORECASE)
|
||||
fmt6 = compile(start+"(\S+)\s*$", IGNORECASE)
|
||||
|
||||
def __init__(self,source=None):
|
||||
if source:
|
||||
self.month = source.month
|
||||
@ -411,49 +284,32 @@ class SingleDate:
|
||||
self.month = UNDEF
|
||||
self.day = UNDEF
|
||||
self.year = UNDEF
|
||||
self.mode = SingleDate.exact
|
||||
self.calendar = GREGORIAN
|
||||
self.mode = Calendar.EXACT
|
||||
self.calendar = Calendar.Gregorian()
|
||||
|
||||
def setMode(self,val):
|
||||
if not val:
|
||||
self.mode = SingleDate.exact
|
||||
else:
|
||||
try:
|
||||
self.mode = SingleDate.m2v[string.lower(val)]
|
||||
except KeyError:
|
||||
raise Date.Error,val
|
||||
self.mode = self.calendar.set_mode_value(val)
|
||||
|
||||
def setMonth(self,val):
|
||||
if val > 14 or val < 0:
|
||||
self.month = UNDEF
|
||||
else:
|
||||
self.month = val - 1
|
||||
self.month = val
|
||||
|
||||
def setMonthVal(self,s):
|
||||
try:
|
||||
val = int(s)
|
||||
self.month = val - 1
|
||||
except:
|
||||
self.month = UNDEF
|
||||
self.month = self.calendar.set_value(s)
|
||||
|
||||
def setDayVal(self,s):
|
||||
try:
|
||||
val = int(s)
|
||||
self.day = val
|
||||
except:
|
||||
self.day = UNDEF
|
||||
self.day = self.calendar.set_value(s)
|
||||
|
||||
def setYearVal(self,s):
|
||||
try:
|
||||
val = int(s)
|
||||
self.year = val
|
||||
except:
|
||||
if s:
|
||||
self.year = self.calendar.set_value(s)
|
||||
else:
|
||||
self.year = UNDEF
|
||||
|
||||
def getMonth(self):
|
||||
if self.month == UNDEF:
|
||||
return UNDEF
|
||||
return self.month + 1
|
||||
return self.month
|
||||
|
||||
def getMonthValid(self):
|
||||
return self.month != UNDEF
|
||||
@ -481,17 +337,7 @@ class SingleDate:
|
||||
return self.year != UNDEF or self.month != UNDEF or self.day != UNDEF
|
||||
|
||||
def setMonthStr(self,text):
|
||||
try:
|
||||
self.month = _m2num[string.lower(text[0:3])]
|
||||
except KeyError:
|
||||
self.setMonthStrEng(text)
|
||||
|
||||
def setMonthStrEng(self,text):
|
||||
try:
|
||||
self.month = SingleDate.em2num[string.lower(text[0:3])]
|
||||
except KeyError:
|
||||
self.month = UNDEF
|
||||
raise Date.Error,text
|
||||
self.calendar.set_month_string(text)
|
||||
|
||||
def getMonthStr(self):
|
||||
return _mname[self.month]
|
||||
@ -539,11 +385,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%s %d, %d" % (month,self.day,self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = _("about") + ' ' + retval
|
||||
elif self.mode == SingleDate.before:
|
||||
elif self.mode == Calendar.BEFORE:
|
||||
retval = _("before") + ' ' + retval
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = _("after") + ' ' + retval
|
||||
return retval
|
||||
|
||||
@ -568,11 +414,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = str(self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("abt"),retval)
|
||||
elif self.mode == SingleDate.before:
|
||||
elif self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("before"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("after"),retval)
|
||||
|
||||
return retval
|
||||
@ -598,11 +444,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%d %s %d" % (self.day,string.upper(month[0:3]),self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("ABOUT"),retval)
|
||||
elif self.mode == SingleDate.before:
|
||||
elif self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("BEFORE"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("AFTER"),retval)
|
||||
return retval
|
||||
|
||||
@ -626,11 +472,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%d. %s %d" % (self.day,month,self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("ABOUT"),retval)
|
||||
elif self.mode == SingleDate.before:
|
||||
elif self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("BEFORE"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("AFTER"),retval)
|
||||
|
||||
return retval
|
||||
@ -653,11 +499,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%02d%s%02d%s%04d" % (self.month+1,sep,self.day,sep,self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("ABOUT"),retval)
|
||||
elif self.mode == SingleDate.before:
|
||||
elif self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("BEFORE"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("AFTER"),retval)
|
||||
|
||||
return retval
|
||||
@ -682,13 +528,13 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%02d%s%02d%s%02d" % (self.year,sep,self.month+1,sep,self.day)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
retval = "%s %s" % (_("ABOUT"),retval)
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("about"),retval)
|
||||
|
||||
if self.mode == SingleDate.before:
|
||||
retval = "%s %s" % (_("BEFORE"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
retval = "%s %s" % (_("AFTER"),retval)
|
||||
if self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("before"),retval)
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("after"),retval)
|
||||
|
||||
return retval
|
||||
|
||||
@ -721,11 +567,11 @@ class SingleDate:
|
||||
else:
|
||||
retval = "%02d%s%02d%s%04d" % (self.day,sep,self.month+1,sep,self.year)
|
||||
|
||||
if self.mode == SingleDate.about:
|
||||
if self.mode == Calendar.ABOUT:
|
||||
retval = "%s %s" % (_("ABOUT"),retval)
|
||||
if self.mode == SingleDate.before:
|
||||
if self.mode == Calendar.BEFORE:
|
||||
retval = "%s %s" % (_("BEFORE"),retval)
|
||||
elif self.mode == SingleDate.after:
|
||||
elif self.mode == Calendar.AFTER:
|
||||
retval = "%s %s" % (_("AFTER"),retval)
|
||||
|
||||
return retval
|
||||
@ -757,38 +603,14 @@ class SingleDate:
|
||||
_format7, _format8, _format9, _format10, _format11, _format12,
|
||||
_format13]
|
||||
|
||||
def display_calendar(self,month_map):
|
||||
d = ''
|
||||
if self.year==UNDEF:
|
||||
if self.month == UNDEF:
|
||||
d = ""
|
||||
elif self.day == UNDEF:
|
||||
d = month_map[self.month]
|
||||
else:
|
||||
d = "%02d %s" % (self.day,month_map[self.month])
|
||||
elif self.month == UNDEF:
|
||||
d = str(self.year)
|
||||
elif self.day == UNDEF:
|
||||
d = "%s %d" % (month_map[self.month],self.year)
|
||||
else:
|
||||
d = "%02d %s %d" % (self.day,month_map[self.month],self.year)
|
||||
if self.mode == SingleDate.about:
|
||||
d = _("about") + ' ' + d
|
||||
elif self.mode == SingleDate.before:
|
||||
d = _("before") + ' ' + d
|
||||
elif self.mode == SingleDate.after:
|
||||
d = _("after") + ' ' + d
|
||||
return d
|
||||
|
||||
def getDate(self):
|
||||
if self.calendar == GREGORIAN:
|
||||
return _func(self)
|
||||
elif self.calendar == JULIAN:
|
||||
return self.display_calendar(_mname)
|
||||
elif self.calendar == HEBREW:
|
||||
return self.display_calendar(_hmonth)
|
||||
return self.calendar.display(self.year, self.month, self.day, self.mode)
|
||||
|
||||
def getQuoteDate(self):
|
||||
if self.year == UNDEF and self.month == UNDEF and self.day == UNDEF:
|
||||
return ""
|
||||
else:
|
||||
return self.display_calendar(_fmonth)
|
||||
return self.calendar.quote_display(self.year, self.month, self.day, self.mode)
|
||||
|
||||
def setIsoDate(self,v):
|
||||
data = string.split(v)
|
||||
@ -799,9 +621,13 @@ class SingleDate:
|
||||
vals = string.split(v,'-')
|
||||
self.setYearVal(vals[0])
|
||||
if len(vals) > 1:
|
||||
self.setMonthVal(vals[1])
|
||||
self.setMonthVal(int(vals[1])-1)
|
||||
else:
|
||||
self.month = UNDEF
|
||||
if len(vals) > 2:
|
||||
self.setDayVal(vals[2])
|
||||
else:
|
||||
self.day = UNDEF
|
||||
|
||||
def getModeVal(self):
|
||||
return self.mode
|
||||
@ -810,198 +636,17 @@ class SingleDate:
|
||||
self.mode = val
|
||||
|
||||
def set(self,text):
|
||||
if self.calendar == GREGORIAN:
|
||||
self.set_gregorian(text)
|
||||
elif self.calendar == JULIAN:
|
||||
self.set_calendar(text,_m2num,3)
|
||||
elif self.calendar == HEBREW:
|
||||
self.set_calendar(text,_hmonth2num,0)
|
||||
else:
|
||||
self.set_calendar(text,_fmonth2num,4)
|
||||
|
||||
def set_calendar(self,text,month_map,l):
|
||||
match = SingleDate.fmt2.match(text)
|
||||
if match:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
monthstr = unicode(matches[2]).lower()
|
||||
if l == 0:
|
||||
mon = monthstr
|
||||
else:
|
||||
mon = monthstr[0:l]
|
||||
self.setYear(int(matches[3]))
|
||||
if month_map.has_key(mon):
|
||||
self.setMonth(month_map[mon]+1)
|
||||
else:
|
||||
self.setMonth(UNDEF)
|
||||
self.setDay(int(matches[1]))
|
||||
return
|
||||
match = SingleDate.fmt3.match(text)
|
||||
if match:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.setYearVal(matches[3])
|
||||
self.setMonthVal(matches[2])
|
||||
self.setDayVal(matches[1])
|
||||
return
|
||||
|
||||
match = SingleDate.fmt4.match(text)
|
||||
if match:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
if l == 0:
|
||||
mon = string.lower(matches[1])
|
||||
else:
|
||||
mon = string.lower(matches[1])[0:l]
|
||||
self.setYearVal(matches[2])
|
||||
self.setMonthStr(mon)
|
||||
self.day = UNDEF
|
||||
return
|
||||
|
||||
match = SingleDate.fmt5.match(text)
|
||||
if match:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.setYearVal(matches[1])
|
||||
self.month = UNDEF
|
||||
self.day = UNDEF
|
||||
return
|
||||
|
||||
self.year = UNDEF
|
||||
self.month = UNDEF
|
||||
self.day = UNDEF
|
||||
|
||||
def set_gregorian(self,text):
|
||||
match = SingleDate.fmt2.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.setMonthStr(matches[2])
|
||||
self.day = int(matches[1])
|
||||
if len(matches) == 4 and matches[3] != None:
|
||||
self.setYearVal(matches[3])
|
||||
else:
|
||||
self.year = UNDEF
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt5.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.month = UNDEF
|
||||
self.day = UNDEF
|
||||
self.year = int(matches[1])
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt7.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
if Date.entryCode == 2:
|
||||
self.setMonthVal(matches[2])
|
||||
self.setYearVal(matches[1])
|
||||
else:
|
||||
self.setMonthVal(matches[1])
|
||||
self.setYearVal(matches[2])
|
||||
if self.getMonth() > 13:
|
||||
raise Date.Error
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt3.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
if Date.entryCode == 0:
|
||||
self.setMonthVal(matches[1])
|
||||
self.setDayVal(matches[2])
|
||||
self.setYearVal(matches[3])
|
||||
elif Date.entryCode == 1:
|
||||
self.setMonthVal(matches[2])
|
||||
self.setDayVal(matches[1])
|
||||
self.setYearVal(matches[3])
|
||||
else:
|
||||
self.setMonthVal(matches[2])
|
||||
self.setDayVal(matches[3])
|
||||
self.setYearVal(matches[1])
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt1.match(text)
|
||||
if match != None:
|
||||
(mode,mon,day,year) = match.groups()
|
||||
self.setMode(mode)
|
||||
self.setMonthStr(mon)
|
||||
if day:
|
||||
self.setDayVal(int(string.replace(day,',','')))
|
||||
else:
|
||||
self.day = UNDEF
|
||||
self.setYearVal(year)
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt4.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.setMonthStr(matches[1])
|
||||
self.day = UNDEF
|
||||
if len(matches) == 4:
|
||||
self.setYearVal(matches[3])
|
||||
return 1
|
||||
|
||||
match = SingleDate.fmt6.match(text)
|
||||
if match != None:
|
||||
matches = match.groups()
|
||||
self.setMode(matches[0])
|
||||
self.setMonthVal(matches[1])
|
||||
self.day = UNDEF
|
||||
self.year = UNDEF
|
||||
return 1
|
||||
|
||||
raise Date.Error,text
|
||||
|
||||
def get_sdn(self):
|
||||
if self.year == UNDEF:
|
||||
return 0
|
||||
if self.month == UNDEF:
|
||||
month = 1
|
||||
else:
|
||||
month = self.month + 1
|
||||
if self.day == UNDEF:
|
||||
day = 1
|
||||
else:
|
||||
day = self.day
|
||||
|
||||
if self.calendar == GREGORIAN:
|
||||
sdn = Calendar.gregorian_to_sdn(self.year,month,day)
|
||||
elif self.calendar == FRENCH:
|
||||
sdn = Calendar.french_to_sdn(self.year,month,day)
|
||||
if self.calendar == HEBREW:
|
||||
sdn = Calendar.jewish_to_sdn(self.year,month,day)
|
||||
if self.calendar == JULIAN:
|
||||
sdn = Calendar.julian_to_sdn(self.year,month,day)
|
||||
return sdn
|
||||
self.year, self.month, self.day, self.mode = self.calendar.set(text)
|
||||
|
||||
def convert_to(self,val):
|
||||
if val == GREGORIAN:
|
||||
self.convert_calendar(Calendar.sdn_to_gregorian,val)
|
||||
elif val == JULIAN:
|
||||
self.convert_calendar(Calendar.sdn_to_julian,val)
|
||||
elif val == HEBREW:
|
||||
self.convert_calendar(Calendar.sdn_to_jewish,val)
|
||||
else:
|
||||
self.convert_calendar(Calendar.sdn_to_french,val)
|
||||
sdn = self.calendar.get_sdn(self.year, self.month, self.day)
|
||||
self.calendar = val()
|
||||
(self.year, self.month, self.day) = self.calendar.get_ymd(sdn)
|
||||
|
||||
def convert_calendar(self,func,mode):
|
||||
sdn = self.get_sdn()
|
||||
(y,m,d) = func(sdn)
|
||||
self.calendar = mode
|
||||
if y == 0 and m == 0 and d == 0:
|
||||
self.year = UNDEF
|
||||
self.month = UNDEF
|
||||
self.day = UNDEF
|
||||
else:
|
||||
self.year = y
|
||||
self.month = m-1
|
||||
self.day = d
|
||||
def convert_to_obj(self,val):
|
||||
sdn = self.calendar.get_sdn(self.year, self.month, self.day)
|
||||
self.calendar = val
|
||||
(self.year, self.month, self.day) = self.calendar.get_ymd(sdn)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -1021,7 +666,7 @@ def not_too_old(date):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def compare_dates(f,s):
|
||||
if f.calendar != s.calendar:
|
||||
if f.calendar.NAME != s.calendar.NAME:
|
||||
return 1
|
||||
if f.range == -1 and s.range == -1:
|
||||
return cmp(f.text,s.text)
|
||||
@ -1048,3 +693,52 @@ def compare_dates(f,s):
|
||||
|
||||
_func = SingleDate.fmtFunc[0]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
a = Date()
|
||||
a.set("24 May 1961")
|
||||
print "Gregorian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Gregorian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Julian)
|
||||
print "Julian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Julian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Gregorian)
|
||||
print "Gregorian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Gregorian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Hebrew)
|
||||
print "Hebrew : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Hebrew : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Gregorian)
|
||||
print "Gregorian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Gregorian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Persian)
|
||||
print "Persian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Persian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Gregorian)
|
||||
print "Gregorian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Gregorian : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Islamic)
|
||||
print "Islamic : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Islamic : ", a.getDate()
|
||||
|
||||
a.set_calendar(Calendar.Gregorian)
|
||||
print "Gregorian : ", a.getDate()
|
||||
a.set(a.getDate())
|
||||
print "Gregorian : ", a.getDate()
|
||||
|
||||
|
@ -67,6 +67,10 @@ class DateEdit:
|
||||
self.text_obj.connect('focus-out-event',self.check)
|
||||
self.check(None,None)
|
||||
|
||||
def set_calendar(self,cobj):
|
||||
self.checkval.set_calendar_obj(cobj)
|
||||
self.check(None,None)
|
||||
|
||||
def check(self,obj,val):
|
||||
"""Called with the text box loses focus. If the string contains a
|
||||
valid date, sets the appropriate pixmap"""
|
||||
|
@ -103,44 +103,6 @@ class EditPerson:
|
||||
self.attr_delete_btn = self.top.get_widget('attr_delete_btn')
|
||||
self.addr_delete_btn = self.top.get_widget('addr_delete_btn')
|
||||
|
||||
self.top.signal_autoconnect({
|
||||
"destroy_passed_object" : self.on_cancel_edit,
|
||||
"on_up_clicked" : self.on_up_clicked,
|
||||
"on_down_clicked" : self.on_down_clicked,
|
||||
"on_add_address_clicked" : self.on_add_addr_clicked,
|
||||
"on_add_aka_clicked" : self.on_add_aka_clicked,
|
||||
"on_add_attr_clicked" : self.on_add_attr_clicked,
|
||||
"on_add_url_clicked" : self.on_add_url_clicked,
|
||||
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
|
||||
"on_aka_delete_clicked" : self.on_aka_delete_clicked,
|
||||
"on_aka_update_clicked" : self.on_aka_update_clicked,
|
||||
"on_apply_person_clicked" : self.on_apply_person_clicked,
|
||||
"on_edit_birth_clicked" : self.on_edit_birth_clicked,
|
||||
"on_edit_death_clicked" : self.on_edit_death_clicked,
|
||||
"on_delete_address_clicked" : self.on_delete_addr_clicked,
|
||||
"on_delete_attr_clicked" : self.on_delete_attr_clicked,
|
||||
"on_delete_event" : self.on_delete_event,
|
||||
"on_delete_url_clicked" : self.on_delete_url_clicked,
|
||||
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
|
||||
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
||||
"on_editperson_switch_page" : self.on_switch_page,
|
||||
"on_event_add_clicked" : self.on_event_add_clicked,
|
||||
"on_event_delete_clicked" : self.on_event_delete_clicked,
|
||||
"on_event_update_clicked" : self.on_event_update_clicked,
|
||||
"on_name_note_clicked" : self.on_name_note_clicked,
|
||||
"on_ldsbap_note_clicked" : self.on_ldsbap_note_clicked,
|
||||
"on_ldsendow_note_clicked" : self.on_ldsendow_note_clicked,
|
||||
"on_ldsseal_note_clicked" : self.on_ldsseal_note_clicked,
|
||||
"on_ldsbap_src_clicked" : self.on_ldsbap_source_clicked,
|
||||
"on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked,
|
||||
"on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked,
|
||||
"on_name_source_clicked" : self.on_primary_name_source_clicked,
|
||||
"on_update_address_clicked" : self.on_update_addr_clicked,
|
||||
"on_update_attr_clicked" : self.on_update_attr_clicked,
|
||||
"on_update_url_clicked" : self.on_update_url_clicked,
|
||||
"on_web_go_clicked" : self.on_web_go_clicked,
|
||||
})
|
||||
|
||||
self.window = self.get_widget("editPerson")
|
||||
self.notes_field = self.get_widget("personNotes")
|
||||
self.event_name_field = self.get_widget("eventName")
|
||||
@ -278,8 +240,6 @@ class EditPerson:
|
||||
self.is_unknown.set_active(1)
|
||||
|
||||
self.nick.set_text(person.getNickName())
|
||||
self.update_birth_death()
|
||||
|
||||
self.load_person_image()
|
||||
|
||||
# set notes data
|
||||
@ -314,6 +274,52 @@ class EditPerson:
|
||||
self.addr_list.connect('drag_data_received',
|
||||
self.ad_drag_data_received)
|
||||
|
||||
self.bdate_check = DateEdit(self.bdate,self.get_widget("birth_stat"))
|
||||
self.bdate_check.set_calendar(self.birth.getDateObj().get_calendar())
|
||||
|
||||
self.ddate_check = DateEdit(self.ddate,self.get_widget("death_stat"))
|
||||
self.ddate_check.set_calendar(self.death.getDateObj().get_calendar())
|
||||
|
||||
self.top.signal_autoconnect({
|
||||
"destroy_passed_object" : self.on_cancel_edit,
|
||||
"on_up_clicked" : self.on_up_clicked,
|
||||
"on_down_clicked" : self.on_down_clicked,
|
||||
"on_add_address_clicked" : self.on_add_addr_clicked,
|
||||
"on_add_aka_clicked" : self.on_add_aka_clicked,
|
||||
"on_add_attr_clicked" : self.on_add_attr_clicked,
|
||||
"on_add_url_clicked" : self.on_add_url_clicked,
|
||||
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
|
||||
"on_aka_delete_clicked" : self.on_aka_delete_clicked,
|
||||
"on_aka_update_clicked" : self.on_aka_update_clicked,
|
||||
"on_apply_person_clicked" : self.on_apply_person_clicked,
|
||||
"on_edit_birth_clicked" : self.on_edit_birth_clicked,
|
||||
"on_edit_death_clicked" : self.on_edit_death_clicked,
|
||||
"on_delete_address_clicked" : self.on_delete_addr_clicked,
|
||||
"on_delete_attr_clicked" : self.on_delete_attr_clicked,
|
||||
"on_delete_event" : self.on_delete_event,
|
||||
"on_delete_url_clicked" : self.on_delete_url_clicked,
|
||||
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
|
||||
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
||||
"on_editperson_switch_page" : self.on_switch_page,
|
||||
"on_event_add_clicked" : self.on_event_add_clicked,
|
||||
"on_event_delete_clicked" : self.on_event_delete_clicked,
|
||||
"on_event_update_clicked" : self.on_event_update_clicked,
|
||||
"on_name_note_clicked" : self.on_name_note_clicked,
|
||||
"on_ldsbap_note_clicked" : self.on_ldsbap_note_clicked,
|
||||
"on_ldsendow_note_clicked" : self.on_ldsendow_note_clicked,
|
||||
"on_ldsseal_note_clicked" : self.on_ldsseal_note_clicked,
|
||||
"on_ldsbap_src_clicked" : self.on_ldsbap_source_clicked,
|
||||
"on_ldsendow_src_clicked" : self.on_ldsendow_source_clicked,
|
||||
"on_ldsseal_src_clicked" : self.on_ldsseal_source_clicked,
|
||||
"on_name_source_clicked" : self.on_primary_name_source_clicked,
|
||||
"on_update_address_clicked" : self.on_update_addr_clicked,
|
||||
"on_update_attr_clicked" : self.on_update_attr_clicked,
|
||||
"on_update_url_clicked" : self.on_update_url_clicked,
|
||||
"on_web_go_clicked" : self.on_web_go_clicked,
|
||||
})
|
||||
|
||||
self.update_birth_death()
|
||||
|
||||
self.redraw_event_list()
|
||||
self.redraw_attr_list()
|
||||
self.redraw_addr_list()
|
||||
@ -459,6 +465,7 @@ class EditPerson:
|
||||
self.seal_stat = obj.get_data("val")
|
||||
|
||||
def ev_drag_data_received(self,widget,context,x,y,sel_data,info,time):
|
||||
print context, info, time
|
||||
if sel_data and sel_data.data:
|
||||
exec 'data = %s' % sel_data.data
|
||||
exec 'mytype = "%s"' % data[0]
|
||||
@ -478,7 +485,8 @@ class EditPerson:
|
||||
self.redraw_event_list()
|
||||
|
||||
def ev_drag_data_get(self,widget, context, sel_data, info, time):
|
||||
ev = widget.get_row_data(widget.focus_row)
|
||||
store, iter = widget.get_selection().get_selected()
|
||||
ev = store.get_value(iter,4)
|
||||
|
||||
bits_per = 8; # we're going to pass a string
|
||||
pickled = pickle.dumps(ev);
|
||||
@ -625,14 +633,12 @@ class EditPerson:
|
||||
self.update_birth = 0
|
||||
self.update_birth_info()
|
||||
self.dplace.set_text(prev_dtext)
|
||||
self.bdate_check = DateEdit(self.bdate,self.get_widget("birth_stat"))
|
||||
|
||||
# Update death with new values, make sure birth values don't change
|
||||
if self.update_death:
|
||||
self.update_death = 0
|
||||
self.update_death_info()
|
||||
self.bplace.set_text(prev_btext)
|
||||
self.ddate_check = DateEdit(self.ddate,self.get_widget("death_stat"))
|
||||
|
||||
def on_add_addr_clicked(self,obj):
|
||||
"""Invokes the address editor to add a new address"""
|
||||
@ -899,7 +905,9 @@ class EditPerson:
|
||||
def update_birth_death(self):
|
||||
self.bdate.set_text(self.birth.getDate())
|
||||
self.bplace.set_text(self.birth.getPlaceName())
|
||||
self.bdate_check.set_calendar(self.birth.getDateObj().get_calendar())
|
||||
self.ddate.set_text(self.death.getDate())
|
||||
self.ddate_check.set_calendar(self.death.getDateObj().get_calendar())
|
||||
self.dplace.set_text(self.death.getPlaceName())
|
||||
self.dplace.set_text(self.death.getPlaceName())
|
||||
# self.bdate.set_position(0)
|
||||
|
@ -38,6 +38,7 @@ import const
|
||||
import Utils
|
||||
import GrampsCfg
|
||||
import AutoComp
|
||||
import Calendar
|
||||
|
||||
from DateEdit import DateEdit
|
||||
from Date import compare_dates
|
||||
@ -132,14 +133,17 @@ class EventEditor:
|
||||
})
|
||||
|
||||
menu = gtk.Menu()
|
||||
names = [ _("Gregorian"), _("Julian"), _("Hebrew"), ("French") ]
|
||||
for index in range(0,len(names)):
|
||||
item = gtk.MenuItem(names[index])
|
||||
item.set_data("d",index)
|
||||
index = 0
|
||||
for cobj in Calendar.calendar_names():
|
||||
item = gtk.MenuItem(cobj.TNAME)
|
||||
item.set_data("d",cobj)
|
||||
item.connect("activate",self.on_menu_changed)
|
||||
item.show()
|
||||
menu.append(item)
|
||||
menu.set_active(self.date.get_calendar())
|
||||
if self.date.get_calendar().NAME == cobj.NAME:
|
||||
menu.set_active(index)
|
||||
self.date_check.set_calendar(cobj())
|
||||
index = index + 1
|
||||
self.calendar.set_menu(menu)
|
||||
|
||||
def add_source(self,obj):
|
||||
@ -149,9 +153,11 @@ class EventEditor:
|
||||
pass
|
||||
|
||||
def on_menu_changed(self,obj):
|
||||
cobj = obj.get_data("d")
|
||||
self.date.set(self.date_field.get_text())
|
||||
self.date.set_calendar(obj.get_data("d"))
|
||||
self.date.set_calendar(cobj)
|
||||
self.date_field.set_text(self.date.getDate())
|
||||
self.date_check.set_calendar(cobj())
|
||||
|
||||
def get_place(self,field,makenew=0):
|
||||
text = strip(field.get_text())
|
||||
|
@ -267,7 +267,7 @@ class FamilyView:
|
||||
if not self.person:
|
||||
return
|
||||
|
||||
n = "%s\n\tb. %s\n\td. %s" % (self.person.getPrimaryName().getName(),
|
||||
n = "%s\n\tb. %s\n\td. %s " % (self.person.getPrimaryName().getName(),
|
||||
self.person.getBirth().getDate(),
|
||||
self.person.getDeath().getDate())
|
||||
self.ap_data.set_text(n,len(n))
|
||||
@ -275,6 +275,7 @@ class FamilyView:
|
||||
self.selected_spouse = None
|
||||
self.spouse_model.clear()
|
||||
self.child_model.clear()
|
||||
self.sp_parents_model.clear()
|
||||
splist = self.person.getFamilyList()
|
||||
f = None
|
||||
first_family = None
|
||||
|
@ -22,6 +22,7 @@ from RelLib import *
|
||||
from Date import SingleDate
|
||||
|
||||
import string
|
||||
import Calendar
|
||||
import Utils
|
||||
import xml.parsers.expat
|
||||
|
||||
@ -421,7 +422,10 @@ class GrampsParser:
|
||||
d = self.event.getDateObj()
|
||||
|
||||
if attrs.has_key("calendar"):
|
||||
d.set_calendar(int(attrs['calendar']))
|
||||
d.set_calendar_val(int(attrs['calendar']))
|
||||
|
||||
if attrs.has_key("cformat"):
|
||||
d.set_calendar(Calendar.find_calendar(attrs['calendar']))
|
||||
|
||||
d.get_start_date().setIsoDate(attrs['start'])
|
||||
d.get_stop_date().setIsoDate(attrs['stop'])
|
||||
@ -438,7 +442,10 @@ class GrampsParser:
|
||||
d = self.event.getDateObj()
|
||||
|
||||
if attrs.has_key("calendar"):
|
||||
d.set_calendar(int(attrs['calendar']))
|
||||
d.set_calendar_val(int(attrs['calendar']))
|
||||
|
||||
if attrs.has_key("cformat"):
|
||||
d.set_calendar(Calendar.find_calendar(attrs['calendar']))
|
||||
|
||||
d.get_start_date().setIsoDate(attrs['val'])
|
||||
|
||||
|
@ -68,6 +68,9 @@ class ListModel:
|
||||
self.double_click = event_func
|
||||
self.tree.connect('event',self.button_press)
|
||||
|
||||
def set_reorderable(self,order):
|
||||
self.tree.set_reorderable(order)
|
||||
|
||||
def new_model(self):
|
||||
self.model = gtk.ListStore(*self.mylist)
|
||||
|
||||
|
@ -40,7 +40,7 @@ import gnome.ui
|
||||
#-------------------------------------------------------------------------
|
||||
from RelLib import *
|
||||
from GrampsParser import GrampsParser, GrampsImportParser
|
||||
from QuestionDialog import ErrorDialog
|
||||
from QuestionDialog import ErrorDialog, WarningDialog
|
||||
from intl import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -99,6 +99,16 @@ def importData(database, filename, callback):
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return 0
|
||||
except ValueError,msg:
|
||||
if str(msg)[0:16] == "Incorrect length":
|
||||
WarningDialog(_("Your database has encountered an error in the library "
|
||||
"that compresses the data.\nYour data should be okay, but "
|
||||
"you may want to consider disabling compression.\n"
|
||||
"This can be disabled in the Properties dialog."))
|
||||
else:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
return 0
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
@ -39,8 +39,8 @@ import os
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
import GrampsCfg
|
||||
import Calendar
|
||||
from RelLib import *
|
||||
from Date import SingleDate
|
||||
from intl import gettext as _
|
||||
from QuestionDialog import ErrorDialog
|
||||
|
||||
@ -65,7 +65,7 @@ def exportData(database, filename, callback):
|
||||
if os.path.isfile(filename):
|
||||
shutil.copy(filename, filename + ".bak")
|
||||
|
||||
compress = GrampsCfg.uncompress ==0 and _gzip_ok == 1
|
||||
compress = GrampsCfg.uncompress == 0 and _gzip_ok == 1
|
||||
|
||||
try:
|
||||
g = XmlWriter(database,callback,0,compress)
|
||||
@ -454,9 +454,8 @@ class XmlWriter:
|
||||
if date.isEmpty():
|
||||
return
|
||||
|
||||
cal = date.get_calendar()
|
||||
if cal != 0:
|
||||
calstr = ' calendar="%s"' % self.fix(str(cal))
|
||||
calstr = ' cformat="%s"' % date.get_calendar().NAME
|
||||
else:
|
||||
calstr = ''
|
||||
|
||||
@ -469,11 +468,11 @@ class XmlWriter:
|
||||
mode = d1.getModeVal()
|
||||
dstr = d1.getIsoDate()
|
||||
|
||||
if mode == SingleDate.before:
|
||||
if mode == Calendar.BEFORE:
|
||||
pref = ' type="before"'
|
||||
elif mode == SingleDate.after:
|
||||
elif mode == Calendar.AFTER:
|
||||
pref = ' type="after"'
|
||||
elif mode == SingleDate.about:
|
||||
elif mode == Calendar.ABOUT:
|
||||
pref = ' type="about"'
|
||||
else:
|
||||
pref = ""
|
||||
|
@ -886,6 +886,7 @@ class Gramps:
|
||||
|
||||
def goto_active_person(self):
|
||||
if not self.active_person:
|
||||
self.ptabs.set_current_page(0)
|
||||
return
|
||||
id = self.active_person.getId()
|
||||
if self.id2col.has_key(id):
|
||||
@ -1176,7 +1177,7 @@ class Gramps:
|
||||
def add_to_person_list(self,person,change):
|
||||
key = person.getId()
|
||||
val = self.db.getPersonDisplay(person.getId())
|
||||
pg = val[5]
|
||||
pg = unicode(val[5])
|
||||
pg = pg[0]
|
||||
if self.DataFilter.compare(person):
|
||||
|
||||
@ -1346,7 +1347,7 @@ class Gramps:
|
||||
for key in self.db.getPersonKeys():
|
||||
person = self.db.getPerson(key)
|
||||
val = self.db.getPersonDisplay(key)
|
||||
pg = val[5]
|
||||
pg = unicode(val[5])
|
||||
if pg:
|
||||
pg = pg[0]
|
||||
if datacomp(person):
|
||||
|
@ -22,6 +22,6 @@ def utf8_to_latin(s):
|
||||
return s.encode('iso-8859-1','replace')
|
||||
|
||||
def latin_to_utf8(s):
|
||||
return unicode(s,'latin-1')
|
||||
return unicode(s)
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ callback = None
|
||||
UNEXPECTED_EOF = "Unexpected End of File"
|
||||
|
||||
def nocnv(s):
|
||||
return s
|
||||
return unicode(s)
|
||||
|
||||
photo_types = [ "jpeg", "bmp", "pict", "pntg", "tpic", "png", "gif",
|
||||
"jpg", "tiff", "pcx" ]
|
||||
@ -1406,8 +1406,7 @@ class GedcomParser:
|
||||
self.gedsource = self.gedmap.get_from_source_tag(matches[2])
|
||||
self.broken_conc = self.gedsource.get_conc()
|
||||
elif matches[1] == "CHAR":
|
||||
if matches[2] == "UNICODE" or matches[2] == "UTF-8" or \
|
||||
matches[2] == "UTF8":
|
||||
if matches[2] == "UNICODE" or matches[2] == "UTF-8" or matches[2] == "UTF8":
|
||||
self.code = UNICODE
|
||||
self.cnv = nocnv
|
||||
elif matches[2] == "ANSEL":
|
||||
|
@ -736,7 +736,7 @@ class GedcomWriter:
|
||||
else:
|
||||
self.g.write("1 EVEN\n")
|
||||
self.g.write("2 TYPE %s\n" % self.cnvtxt(name))
|
||||
self.g.write("2 PLAC %s\n" % self.cnvtxt(attr.getValue()))
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(attr.getValue()),'\r',' '))
|
||||
if attr.getNote():
|
||||
self.write_long_text("NOTE",2,self.cnvtxt(attr.getNote()))
|
||||
for srcref in attr.getSourceRefList():
|
||||
@ -764,7 +764,7 @@ class GedcomWriter:
|
||||
text = addr_append(text,addr.getPostal())
|
||||
text = addr_append(text,addr.getCountry())
|
||||
if text:
|
||||
self.g.write("2 PLAC %s\n" % text)
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(text)),'\r',' ')
|
||||
if addr.getNote():
|
||||
self.write_long_text("NOTE",3,self.cnvtxt(addr.getNote()))
|
||||
for srcref in addr.getSourceRefList():
|
||||
@ -861,7 +861,7 @@ class GedcomWriter:
|
||||
dateobj = event.getDateObj()
|
||||
self.print_date("2 DATE",dateobj)
|
||||
if event.getPlaceName():
|
||||
self.g.write("2 PLAC %s\n" % self.cnvtxt(event.getPlaceName()))
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(event.getPlaceName()),'\r',' '))
|
||||
if event.getCause():
|
||||
self.g.write("2 CAUS %s\n" % self.cnvtxt(event.getCause()))
|
||||
if event.getNote():
|
||||
@ -879,7 +879,7 @@ class GedcomWriter:
|
||||
if ord.getTemple():
|
||||
self.g.write('%d TEMP %s\n' % (index+1,ord.getTemple()))
|
||||
if ord.getPlaceName():
|
||||
self.g.write("2 PLAC %s\n" % self.cnvtxt(ord.getPlaceName()))
|
||||
self.g.write("2 PLAC %s\n" % string.replace(self.cnvtxt(ord.getPlaceName()),'\r',' '))
|
||||
if ord.getStatus() != 0:
|
||||
self.g.write("2 STAT %s\n" % self.cnvtxt(statlist[ord.getStatus()]))
|
||||
if ord.getNote():
|
||||
|
Loading…
Reference in New Issue
Block a user