Better calendar handling, XML parsing in TextDoc
svn: r579
This commit is contained in:
parent
6202d3eb76
commit
ad07469a59
@ -43,14 +43,14 @@ FRENCH = 3
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
_fmonth = [
|
_fmonth = [
|
||||||
"Vendemiaire", "Brumaire", "Frimaire", "Nivose", "Pluviose",
|
"Vendémiaire", "Brumaire", "Frimaire", "Nivôse", "Pluviôse",
|
||||||
"Ventose", "Germinal", "Floreal", "Prairial", "Messidor", "Thermidor",
|
"Ventôse", "Germinal", "Floréal", "Prairial", "Messidor", "Thermidor",
|
||||||
"Fructidor", "Extra", ]
|
"Fructidor", "Extra", ]
|
||||||
|
|
||||||
_fmonth2num = {
|
_fmonth2num = {
|
||||||
"VEND" : 1, "BRUM" : 2, "FRIM" : 3, "NIVO" : 4, "PLUV" : 5,
|
"vend" : 0, "brum" : 1, "frim" : 2, "nivo" : 3, "pluv" : 4,
|
||||||
"VENT" : 6, "GERM" : 7, "FLOR" : 8, "PRAI" : 8, "MESS" : 10,
|
"vent" : 5, "germ" : 6, "flor" : 7, "prai" : 8, "mess" : 9,
|
||||||
"THER" :11, "FRUC" :12, "EXTR" : 13 }
|
"ther" :10, "fruc" :11, "extr" : 12,"nivô" : 3 }
|
||||||
|
|
||||||
_hmonth = [
|
_hmonth = [
|
||||||
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI",
|
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI",
|
||||||
@ -58,12 +58,30 @@ _hmonth = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
_hmonth2num = {
|
_hmonth2num = {
|
||||||
"Tishri" : 1, "Heshvan" : 2, "Kislev" : 3, "Tevet" : 4,
|
"Tishri" : 0, "Heshvan" : 1, "Kislev" : 2, "Tevet" : 3,
|
||||||
"Shevat" : 5, "AdarI" : 6, "AdarII" : 7, "Nisan" : 8,
|
"Shevat" : 4, "AdarI" : 5, "AdarII" : 6, "Nisan" : 7,
|
||||||
"Iyyar" : 9, "Sivan" :10, "Tammuz" :11, "Av" : 12,
|
"Iyyar" : 8, "Sivan" : 9, "Tammuz" :10, "Av" : 11,
|
||||||
"Elul" : 13
|
"Elul" : 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
|
_UNDEF = -999999
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -203,24 +221,15 @@ class Date:
|
|||||||
def getDate(self):
|
def getDate(self):
|
||||||
return self.get_fmt(SingleDate.getDate)
|
return self.get_fmt(SingleDate.getDate)
|
||||||
|
|
||||||
def getFrench(self):
|
|
||||||
return self.get_fmt(SingleDate.displayFrench)
|
|
||||||
|
|
||||||
def getHebrew(self):
|
|
||||||
return self.get_fmt(SingleDate.displayHebrew)
|
|
||||||
|
|
||||||
def getJulian(self):
|
|
||||||
return self.get_fmt(SingleDate.displayJulian)
|
|
||||||
|
|
||||||
def getQuoteDate(self):
|
def getQuoteDate(self):
|
||||||
if self.calendar == GREGORIAN:
|
if self.calendar == GREGORIAN:
|
||||||
return self.getGregorianQuoteDate()
|
return self.getGregorianQuoteDate()
|
||||||
elif self.calendar == JULIAN:
|
elif self.calendar == JULIAN:
|
||||||
return self.getJulianQuoteDate()
|
return self.get_quote_date(_mname,_("Julian"))
|
||||||
elif self.calendar == HEBREW:
|
elif self.calendar == HEBREW:
|
||||||
return self.getHebrewQuoteDate()
|
return self.get_quote_date(_hmonth,_("French"))
|
||||||
else:
|
else:
|
||||||
return self.getFrenchQuoteDate()
|
return self.get_quote_date(_fmonth,_("French"))
|
||||||
|
|
||||||
def getGregorianQuoteDate(self):
|
def getGregorianQuoteDate(self):
|
||||||
if self.range == 0:
|
if self.range == 0:
|
||||||
@ -235,28 +244,19 @@ class Date:
|
|||||||
d2 = _func(self.stop)
|
d2 = _func(self.stop)
|
||||||
return "%s %s %s %s" % ( _("from"),d1,_("to"), d2)
|
return "%s %s %s %s" % ( _("from"),d1,_("to"), d2)
|
||||||
|
|
||||||
def get_quote_date(self,func,cal_str):
|
def get_quote_date(self,month_map,cal_str):
|
||||||
if self.range == 0:
|
if self.range == 0:
|
||||||
return "%s (%s)" % (func(self.start),cal_str)
|
return "%s (%s)" % (self.start.display_calendar(month_map),cal_str)
|
||||||
elif self.range == -1:
|
elif self.range == -1:
|
||||||
if self.text:
|
if self.text:
|
||||||
return '"%s (%s)"' % (self.text,cal_str)
|
return '"%s (%s)"' % (self.text,cal_str)
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
d1 = func(self.start)
|
d1 = self.start.display_calendar(month_map)
|
||||||
d2 = func(self.stop)
|
d2 = self.stop.display_calenar(month_map)
|
||||||
return "%s %s %s %s (%s)" % ( _("from"),d1,_("to"), d2,cal_str)
|
return "%s %s %s %s (%s)" % ( _("from"),d1,_("to"), d2,cal_str)
|
||||||
|
|
||||||
def getFrenchQuoteDate(self):
|
|
||||||
return self.get_quote_date(SingleDate.displayFrench,_("French"))
|
|
||||||
|
|
||||||
def getJulianQuoteDate(self):
|
|
||||||
return self.get_quote_date(SingleDate.displayJulian,_("Julian"))
|
|
||||||
|
|
||||||
def getHebrewQuoteDate(self):
|
|
||||||
return self.get_quote_date(SingleDate.displayHebrew,_("Hebrew"))
|
|
||||||
|
|
||||||
def getSaveDate(self):
|
def getSaveDate(self):
|
||||||
if self.range == 1:
|
if self.range == 1:
|
||||||
d1 = self.start.getSaveDate()
|
d1 = self.start.getSaveDate()
|
||||||
@ -308,26 +308,9 @@ class SingleDate:
|
|||||||
before = 2
|
before = 2
|
||||||
after = 3
|
after = 3
|
||||||
|
|
||||||
mname = [ _("January"), _("February"), _("March"), _("April"),
|
|
||||||
_("May"), _("June"), _("July"), _("August"),
|
|
||||||
_("September"), _("October"), _("November"), _("December") ]
|
|
||||||
|
|
||||||
emname =[ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
|
emname =[ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN',
|
||||||
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ]
|
'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ]
|
||||||
|
|
||||||
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 }
|
|
||||||
|
|
||||||
em2num ={ "jan" : 0, "feb" : 1, "mar" : 2, "apr" : 3,
|
em2num ={ "jan" : 0, "feb" : 1, "mar" : 2, "apr" : 3,
|
||||||
"may" : 4, "jun" : 5, "jul" : 6, "aug" : 7,
|
"may" : 4, "jun" : 5, "jul" : 6, "aug" : 7,
|
||||||
"sep" : 8, "oct" : 9, "nov" : 10,"dec" : 11 }
|
"sep" : 8, "oct" : 9, "nov" : 10,"dec" : 11 }
|
||||||
@ -398,11 +381,32 @@ class SingleDate:
|
|||||||
self.mode = SingleDate.m2v[val]
|
self.mode = SingleDate.m2v[val]
|
||||||
|
|
||||||
def setMonth(self,val):
|
def setMonth(self,val):
|
||||||
if val > 12:
|
if val > 12 or val < 0:
|
||||||
self.month = _UNDEF
|
self.month = _UNDEF
|
||||||
else:
|
else:
|
||||||
self.month = val - 1
|
self.month = val - 1
|
||||||
|
|
||||||
|
def setMonthVal(self,s):
|
||||||
|
try:
|
||||||
|
val = int(s)
|
||||||
|
self.month = val - 1
|
||||||
|
except ValueError:
|
||||||
|
self.month = _UNDEF
|
||||||
|
|
||||||
|
def setDayVal(self,s):
|
||||||
|
try:
|
||||||
|
val = int(s)
|
||||||
|
self.day = val
|
||||||
|
except ValueError:
|
||||||
|
self.day = _UNDEF
|
||||||
|
|
||||||
|
def setYearVal(self,s):
|
||||||
|
try:
|
||||||
|
val = int(s)
|
||||||
|
self.year = val
|
||||||
|
except ValueError:
|
||||||
|
self.year = _UNDEF
|
||||||
|
|
||||||
def getMonth(self):
|
def getMonth(self):
|
||||||
return self.month + 1
|
return self.month + 1
|
||||||
|
|
||||||
@ -431,18 +435,18 @@ class SingleDate:
|
|||||||
self.month = _UNDEF
|
self.month = _UNDEF
|
||||||
|
|
||||||
def getMonthStr(self):
|
def getMonthStr(self):
|
||||||
return SingleDate.mname[self.month]
|
return _mname[self.month]
|
||||||
|
|
||||||
def getIsoDate(self):
|
def getIsoDate(self):
|
||||||
if self.year == _UNDEF:
|
if self.year == _UNDEF:
|
||||||
y = "?"
|
y = "????"
|
||||||
else:
|
else:
|
||||||
y = "%04d" % self.year
|
y = "%04d" % self.year
|
||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
if self.day == _UNDEF:
|
if self.day == _UNDEF:
|
||||||
m = ""
|
m = ""
|
||||||
else:
|
else:
|
||||||
m = "-?"
|
m = "-??"
|
||||||
else:
|
else:
|
||||||
m = "-%02d" % (self.month+1)
|
m = "-%02d" % (self.month+1)
|
||||||
if self.day == _UNDEF:
|
if self.day == _UNDEF:
|
||||||
@ -474,8 +478,7 @@ class SingleDate:
|
|||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = "ABT %s" % retval
|
retval = "ABT %s" % retval
|
||||||
|
elif self.mode == SingleDate.before:
|
||||||
if self.mode == SingleDate.before:
|
|
||||||
retval = "BEFORE" + " " + retval
|
retval = "BEFORE" + " " + retval
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = "AFTER" + " " + retval
|
retval = "AFTER" + " " + retval
|
||||||
@ -490,13 +493,13 @@ class SingleDate:
|
|||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
elif self.year == _UNDEF:
|
elif self.year == _UNDEF:
|
||||||
retval = SingleDate.mname[self.month]
|
retval = _mname[self.month]
|
||||||
else:
|
else:
|
||||||
retval = "%s %d" % (SingleDate.mname[self.month],self.year)
|
retval = "%s %d" % (_mname[self.month],self.year)
|
||||||
elif self.month == _UNDEF:
|
elif self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
if self.year == _UNDEF:
|
if self.year == _UNDEF:
|
||||||
retval = "%s %d, ????" % (month,self.day)
|
retval = "%s %d, ????" % (month,self.day)
|
||||||
else:
|
else:
|
||||||
@ -504,8 +507,7 @@ class SingleDate:
|
|||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = _("about") + ' ' + retval
|
retval = _("about") + ' ' + retval
|
||||||
|
elif self.mode == SingleDate.before:
|
||||||
if self.mode == SingleDate.before:
|
|
||||||
retval = _("before") + ' ' + retval
|
retval = _("before") + ' ' + retval
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = _("after") + ' ' + retval
|
retval = _("after") + ' ' + retval
|
||||||
@ -516,7 +518,7 @@ class SingleDate:
|
|||||||
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
||||||
return ""
|
return ""
|
||||||
elif self.month != _UNDEF and self.month != _UNDEF:
|
elif self.month != _UNDEF and self.month != _UNDEF:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
if self.year == _UNDEF:
|
if self.year == _UNDEF:
|
||||||
retval = "%s %d, ????" % (string.upper(month[0:3]),self.day)
|
retval = "%s %d, ????" % (string.upper(month[0:3]),self.day)
|
||||||
else:
|
else:
|
||||||
@ -525,17 +527,17 @@ class SingleDate:
|
|||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
elif self.year == _UNDEF:
|
elif self.year == _UNDEF:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
retval = string.upper(month[0:3])
|
retval = string.upper(month[0:3])
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
retval = "%s %d" % (string.upper(month[0:3]),self.year)
|
retval = "%s %d" % (string.upper(month[0:3]),self.year)
|
||||||
else:
|
else:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = "%s %s" % (_("abt"),retval)
|
retval = "%s %s" % (_("abt"),retval)
|
||||||
if self.mode == SingleDate.before:
|
elif self.mode == SingleDate.before:
|
||||||
retval = "%s %s" % (_("before"),retval)
|
retval = "%s %s" % (_("before"),retval)
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = "%s %s" % (_("after"),retval)
|
retval = "%s %s" % (_("after"),retval)
|
||||||
@ -543,23 +545,21 @@ class SingleDate:
|
|||||||
return retval
|
return retval
|
||||||
|
|
||||||
def getFmt3(self):
|
def getFmt3(self):
|
||||||
retval = ""
|
|
||||||
|
|
||||||
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
||||||
pass
|
return ""
|
||||||
elif self.day == _UNDEF:
|
elif self.day == _UNDEF:
|
||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
elif self.year == _UNDEF:
|
elif self.year == _UNDEF:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
retval = string.upper(month[0:3])
|
retval = string.upper(month[0:3])
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
retval = "%s %d" % (string.upper(month[0:3]),self.year)
|
retval = "%s %d" % (string.upper(month[0:3]),self.year)
|
||||||
elif self.month == _UNDEF:
|
elif self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
if self.year == _UNDEF:
|
if self.year == _UNDEF:
|
||||||
retval = "%d %s ????" % (self.day,string.upper(month[0:3]))
|
retval = "%d %s ????" % (self.day,string.upper(month[0:3]))
|
||||||
else:
|
else:
|
||||||
@ -567,7 +567,7 @@ class SingleDate:
|
|||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = "%s %s" % (_("ABT"),retval)
|
retval = "%s %s" % (_("ABT"),retval)
|
||||||
if self.mode == SingleDate.before:
|
elif self.mode == SingleDate.before:
|
||||||
retval = "%s %s" % (_("BEFORE"),retval)
|
retval = "%s %s" % (_("BEFORE"),retval)
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = "%s %s" % (_("AFTER"),retval)
|
retval = "%s %s" % (_("AFTER"),retval)
|
||||||
@ -575,22 +575,20 @@ class SingleDate:
|
|||||||
return retval
|
return retval
|
||||||
|
|
||||||
def getFmt10(self):
|
def getFmt10(self):
|
||||||
retval = ""
|
|
||||||
|
|
||||||
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
||||||
pass
|
return ""
|
||||||
elif self.day == _UNDEF:
|
elif self.day == _UNDEF:
|
||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
elif self.year == _UNDEF:
|
elif self.year == _UNDEF:
|
||||||
retval = SingleDate.mname[self.month]
|
retval = _mname[self.month]
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
retval = "%s %d" % (month,self.year)
|
retval = "%s %d" % (month,self.year)
|
||||||
elif self.month == _UNDEF:
|
elif self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
else:
|
else:
|
||||||
month = SingleDate.mname[self.month]
|
month = _mname[self.month]
|
||||||
if self.year == _UNDEF:
|
if self.year == _UNDEF:
|
||||||
retval = "%d. %s ????" % (self.day,month)
|
retval = "%d. %s ????" % (self.day,month)
|
||||||
else:
|
else:
|
||||||
@ -598,7 +596,7 @@ class SingleDate:
|
|||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = "%s %s" % (_("ABT"),retval)
|
retval = "%s %s" % (_("ABT"),retval)
|
||||||
if self.mode == SingleDate.before:
|
elif self.mode == SingleDate.before:
|
||||||
retval = "%s %s" % (_("BEFORE"),retval)
|
retval = "%s %s" % (_("BEFORE"),retval)
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = "%s %s" % (_("AFTER"),retval)
|
retval = "%s %s" % (_("AFTER"),retval)
|
||||||
@ -606,10 +604,8 @@ class SingleDate:
|
|||||||
return retval
|
return retval
|
||||||
|
|
||||||
def get_mmddyyyy(self,sep):
|
def get_mmddyyyy(self,sep):
|
||||||
retval = ""
|
|
||||||
|
|
||||||
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
if self.month == _UNDEF and self.day == _UNDEF and self.year == _UNDEF :
|
||||||
pass
|
return ""
|
||||||
elif self.day == _UNDEF:
|
elif self.day == _UNDEF:
|
||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
retval = str(self.year)
|
retval = str(self.year)
|
||||||
@ -627,8 +623,7 @@ class SingleDate:
|
|||||||
|
|
||||||
if self.mode == SingleDate.about:
|
if self.mode == SingleDate.about:
|
||||||
retval = "%s %s" % (_("ABT"),retval)
|
retval = "%s %s" % (_("ABT"),retval)
|
||||||
|
elif self.mode == SingleDate.before:
|
||||||
if self.mode == SingleDate.before:
|
|
||||||
retval = "%s %s" % (_("BEFORE"),retval)
|
retval = "%s %s" % (_("BEFORE"),retval)
|
||||||
elif self.mode == SingleDate.after:
|
elif self.mode == SingleDate.after:
|
||||||
retval = "%s %s" % (_("AFTER"),retval)
|
retval = "%s %s" % (_("AFTER"),retval)
|
||||||
@ -730,61 +725,31 @@ class SingleDate:
|
|||||||
getFmt7, getFmt8, getFmt9, getFmt10, getFmt11, getFmt12,
|
getFmt7, getFmt8, getFmt9, getFmt10, getFmt11, getFmt12,
|
||||||
getFmt13]
|
getFmt13]
|
||||||
|
|
||||||
def displayFrench(self):
|
def display_calendar(self,month_map):
|
||||||
if self.year==_UNDEF:
|
if self.year==_UNDEF:
|
||||||
if self.month == _UNDEF:
|
if self.month == _UNDEF:
|
||||||
return ""
|
return ""
|
||||||
elif self.day == _UNDEF:
|
elif self.day == _UNDEF:
|
||||||
return _fmonth[self.month]
|
return month_map[self.month]
|
||||||
else:
|
else:
|
||||||
return "%02 %s" % (self.day,_fmonth[self.month])
|
return "%02 %s" % (self.day,month_map[self.month])
|
||||||
elif self.month == _UNDEF:
|
elif self.month == _UNDEF:
|
||||||
return "%d" % self.year
|
return str(self.year)
|
||||||
elif self.day == _UNDEF:
|
elif self.day == _UNDEF:
|
||||||
return "%s %d" % (_fmonth[self.month],self.year)
|
return "%s %d" % (month_map[self.month],self.year)
|
||||||
else:
|
else:
|
||||||
return "%02d %s %d" % (self.day,_fmonth[self.month],self.year)
|
return "%02d %s %d" % (self.day,month_map[self.month],self.year)
|
||||||
|
|
||||||
def displayHebrew(self):
|
|
||||||
if self.year==_UNDEF:
|
|
||||||
if self.month == _UNDEF:
|
|
||||||
return ""
|
|
||||||
elif self.day == _UNDEF:
|
|
||||||
return _hmonth[self.month]
|
|
||||||
else:
|
|
||||||
return "%02 %s" % (self.day,_hmonth[self.month])
|
|
||||||
elif self.month == _UNDEF:
|
|
||||||
return "%d" % self.year
|
|
||||||
elif self.day == _UNDEF:
|
|
||||||
return "%s %d" % (_hmonth[self.month],self.year)
|
|
||||||
else:
|
|
||||||
return "%02d %s %d" % (self.day,_hmonth[self.month],self.year)
|
|
||||||
|
|
||||||
def displayJulian(self):
|
|
||||||
if self.year==_UNDEF:
|
|
||||||
if self.month == _UNDEF:
|
|
||||||
return ""
|
|
||||||
elif self.day == _UNDEF:
|
|
||||||
return self.mname[self.month]
|
|
||||||
else:
|
|
||||||
return "%02 %s" % (self.day,self.mname[self.month])
|
|
||||||
elif self.month == _UNDEF:
|
|
||||||
return "%d" % self.year
|
|
||||||
elif self.day == _UNDEF:
|
|
||||||
return "%s %d" % (self.mname[self.month],self.year)
|
|
||||||
else:
|
|
||||||
return "%02d %s %d" % (self.day,self.mname[self.month],self.year)
|
|
||||||
|
|
||||||
def getDate(self):
|
def getDate(self):
|
||||||
if self.calendar == GREGORIAN:
|
if self.calendar == GREGORIAN:
|
||||||
return _func(self)
|
return _func(self)
|
||||||
elif self.calendar == JULIAN:
|
elif self.calendar == JULIAN:
|
||||||
return self.displayJulian()
|
return self.display_calendar(_mname)
|
||||||
elif self.calendar == HEBREW:
|
elif self.calendar == HEBREW:
|
||||||
return self.displayHebrew()
|
return self.display_calendar(_hmonth)
|
||||||
else:
|
else:
|
||||||
return self.displayFrench()
|
return self.display_calendar(_fmonth)
|
||||||
|
|
||||||
def setIsoDate(self,v):
|
def setIsoDate(self,v):
|
||||||
data = string.split(v)
|
data = string.split(v)
|
||||||
if len(data) > 1:
|
if len(data) > 1:
|
||||||
@ -792,18 +757,11 @@ class SingleDate:
|
|||||||
v = data[1]
|
v = data[1]
|
||||||
|
|
||||||
vals = string.split(v,'-')
|
vals = string.split(v,'-')
|
||||||
if vals[0] == '?':
|
self.setYearVal(vals[0])
|
||||||
self.year = _UNDEF
|
if len(vals) > 1:
|
||||||
else:
|
self.setMonthVal(vals[1])
|
||||||
self.year = int(vals[0])
|
|
||||||
if len(vals) > 1 and vals[1] != '?':
|
|
||||||
self.month = int(vals[1])-1
|
|
||||||
else:
|
|
||||||
self.month = _UNDEF
|
|
||||||
if len(vals) > 2:
|
if len(vals) > 2:
|
||||||
self.day = int(vals[2])
|
self.setDayVal(vals[2])
|
||||||
else:
|
|
||||||
self.day = _UNDEF
|
|
||||||
|
|
||||||
def getModeVal(self):
|
def getModeVal(self):
|
||||||
return self.mode
|
return self.mode
|
||||||
@ -827,20 +785,23 @@ class SingleDate:
|
|||||||
if self.calendar == GREGORIAN:
|
if self.calendar == GREGORIAN:
|
||||||
self.set_gregorian(text)
|
self.set_gregorian(text)
|
||||||
elif self.calendar == JULIAN:
|
elif self.calendar == JULIAN:
|
||||||
self.set_julian(text)
|
self.set_calendar(text,_m2num,3)
|
||||||
elif self.calendar == HEBREW:
|
elif self.calendar == HEBREW:
|
||||||
self.set_hebrew(text)
|
self.set_calendar(text,_hmonth2num,0)
|
||||||
else:
|
else:
|
||||||
self.set_french(text)
|
self.set_calendar(text,_fmonth2num,4)
|
||||||
|
|
||||||
def set_french(self,text):
|
def set_calendar(self,text,month_map,l):
|
||||||
match = SingleDate.fmt2.match(text)
|
match = SingleDate.fmt2.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
mon = string.upper(matches[2])[0:4]
|
if l == 0:
|
||||||
if _fmonth2num.has_key(mon):
|
mon = string.lower(matches[2])
|
||||||
|
else:
|
||||||
|
mon = string.lower(matches[2])[0:l]
|
||||||
|
if month_map.has_key(mon):
|
||||||
self.setYear(int(matches[3]))
|
self.setYear(int(matches[3]))
|
||||||
self.setMonth(_fmonth2num[mon])
|
self.setMonth(month_map[mon]+1)
|
||||||
self.setDay(int(matches[1]))
|
self.setDay(int(matches[1]))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -851,42 +812,13 @@ class SingleDate:
|
|||||||
match = SingleDate.fmt3.match(text)
|
match = SingleDate.fmt3.match(text)
|
||||||
if match:
|
if match:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.setYear(int(matches[3]))
|
self.setYearVal(matches[3])
|
||||||
self.setMonth(int(matches[2]))
|
self.setMonthVal(matches[2])
|
||||||
self.setDay(int(matches[1]))
|
self.setDayVal(matches[1])
|
||||||
else:
|
else:
|
||||||
self.setYear(_UNDEF)
|
self.year = _UNDEF
|
||||||
self.setMonth(_UNDEF)
|
self.month = _UNDEF
|
||||||
self.setDay(_UNDEF)
|
self.day = _UNDEF
|
||||||
|
|
||||||
def set_hebrew(self,text):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def set_julian(self,text):
|
|
||||||
match = SingleDate.fmt2.match(text)
|
|
||||||
if match:
|
|
||||||
matches = match.groups()
|
|
||||||
mon = string.lower(matches[2])[0:3]
|
|
||||||
if SingleDate.m2num.has_key(mon):
|
|
||||||
self.setYear(int(matches[3]))
|
|
||||||
self.setMonth(SingleDate.m2num[mon]+1)
|
|
||||||
self.setDay(int(matches[1]))
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.setYear(int(matches[3]))
|
|
||||||
self.setMonth(_UNDEF)
|
|
||||||
self.setDay(_UNDEF)
|
|
||||||
return
|
|
||||||
match = SingleDate.fmt3.match(text)
|
|
||||||
if match:
|
|
||||||
matches = match.groups()
|
|
||||||
self.setYear(int(matches[3]))
|
|
||||||
self.setMonth(int(matches[2]))
|
|
||||||
self.setDay(int(matches[1]))
|
|
||||||
else:
|
|
||||||
self.setYear(_UNDEF)
|
|
||||||
self.setMonth(_UNDEF)
|
|
||||||
self.setDay(_UNDEF)
|
|
||||||
|
|
||||||
def set_gregorian(self,text):
|
def set_gregorian(self,text):
|
||||||
match = SingleDate.fmt2.match(text)
|
match = SingleDate.fmt2.match(text)
|
||||||
@ -898,11 +830,7 @@ class SingleDate:
|
|||||||
raise Date.Error,text
|
raise Date.Error,text
|
||||||
self.day = int(matches[1])
|
self.day = int(matches[1])
|
||||||
if len(matches) == 4:
|
if len(matches) == 4:
|
||||||
val = matches[3]
|
self.setYearVal(matches[3])
|
||||||
if val == None or val[0] == '?':
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
else:
|
else:
|
||||||
self.year = _UNDEF
|
self.year = _UNDEF
|
||||||
return 1
|
return 1
|
||||||
@ -921,82 +849,29 @@ class SingleDate:
|
|||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.getMode(matches[0])
|
||||||
if Date.entryCode == 2:
|
if Date.entryCode == 2:
|
||||||
try:
|
self.setMonthVal(matches[2])
|
||||||
self.month = int(matches[2])-1
|
self.setYearVal(matches[1])
|
||||||
if self.month > 11:
|
|
||||||
raise Date.Error,text
|
|
||||||
except ValueError:
|
|
||||||
self.month = _UNDEF
|
|
||||||
try:
|
|
||||||
self.year = int(matches[1])
|
|
||||||
except ValueError:
|
|
||||||
self.year = _UNDEF
|
|
||||||
return 1
|
|
||||||
else:
|
else:
|
||||||
try:
|
self.setMonthVal(matches[1])
|
||||||
self.month = int(matches[1])-1
|
self.setYearVal(matches[2])
|
||||||
if self.month > 11:
|
return 1
|
||||||
raise Date.Error,text
|
|
||||||
except ValueError:
|
|
||||||
self.month = _UNDEF
|
|
||||||
try:
|
|
||||||
self.year = int(matches[2])
|
|
||||||
except ValueError:
|
|
||||||
self.year = _UNDEF
|
|
||||||
return 1
|
|
||||||
|
|
||||||
match = SingleDate.fmt3.match(text)
|
match = SingleDate.fmt3.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.getMode(matches[0])
|
||||||
if Date.entryCode == 0:
|
if Date.entryCode == 0:
|
||||||
try:
|
self.setMonthVal(matches[1])
|
||||||
self.month = int(matches[1])-1
|
self.setDayVal(matches[2])
|
||||||
if self.month > 11:
|
self.setYearVal(matches[3])
|
||||||
raise Date.Error,text
|
|
||||||
except ValueError:
|
|
||||||
self.month = _UNDEF
|
|
||||||
try:
|
|
||||||
self.day = int(matches[2])
|
|
||||||
except ValueError:
|
|
||||||
self.day = _UNDEF
|
|
||||||
val = matches[3]
|
|
||||||
if val == None or val[0] == '?':
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
elif Date.entryCode == 1:
|
elif Date.entryCode == 1:
|
||||||
try:
|
self.setMonthVal(matches[2])
|
||||||
self.month = int(matches[2])-1
|
self.setDayVal(matches[1])
|
||||||
if self.month > 11:
|
self.setYearVal(matches[3])
|
||||||
raise Date.Error,text
|
|
||||||
except ValueError:
|
|
||||||
self.month = _UNDEF
|
|
||||||
try:
|
|
||||||
self.day = int(matches[1])
|
|
||||||
except ValueError:
|
|
||||||
self.day = _UNDEF
|
|
||||||
val = matches[3]
|
|
||||||
if val == None or val[0] == '?':
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
else:
|
else:
|
||||||
try:
|
self.setMonthVal(matches[2])
|
||||||
self.month = int(matches[2])-1
|
self.setDayVal(matches[3])
|
||||||
if self.month > 11:
|
self.setYearVal(matches[1])
|
||||||
raise Date.Error,text
|
|
||||||
except ValueError:
|
|
||||||
self.month = _UNDEF
|
|
||||||
try:
|
|
||||||
self.day = int(matches[3])
|
|
||||||
except ValueError:
|
|
||||||
self.day = _UNDEF
|
|
||||||
val = matches[1]
|
|
||||||
if val == None or val[0] == '?':
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
match = SingleDate.fmt1.match(text)
|
match = SingleDate.fmt1.match(text)
|
||||||
@ -1011,11 +886,7 @@ class SingleDate:
|
|||||||
self.day = int(string.replace(val,',',''))
|
self.day = int(string.replace(val,',',''))
|
||||||
else:
|
else:
|
||||||
self.day = _UNDEF
|
self.day = _UNDEF
|
||||||
val = matches[3]
|
self.setYearVal(matches[3])
|
||||||
if val == None or val[0] == '?':
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
match = SingleDate.fmt4.match(text)
|
match = SingleDate.fmt4.match(text)
|
||||||
@ -1027,20 +898,14 @@ class SingleDate:
|
|||||||
raise Date.Error,text
|
raise Date.Error,text
|
||||||
self.day = _UNDEF
|
self.day = _UNDEF
|
||||||
if len(matches) == 4:
|
if len(matches) == 4:
|
||||||
val = matches[3]
|
self.setYearVal(matches[3])
|
||||||
if val == None or val[0] == '?' :
|
|
||||||
self.year = _UNDEF
|
|
||||||
else:
|
|
||||||
self.year = int(val)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
match = SingleDate.fmt6.match(text)
|
match = SingleDate.fmt6.match(text)
|
||||||
if match != None:
|
if match != None:
|
||||||
matches = match.groups()
|
matches = match.groups()
|
||||||
self.getMode(matches[0])
|
self.getMode(matches[0])
|
||||||
self.month = int(matches[1])-1
|
self.setMonthVal(matches[1])
|
||||||
if self.month > 11:
|
|
||||||
raise Date.Error,text
|
|
||||||
self.day = _UNDEF
|
self.day = _UNDEF
|
||||||
self.year = _UNDEF
|
self.year = _UNDEF
|
||||||
return 1
|
return 1
|
||||||
@ -1071,57 +936,18 @@ class SingleDate:
|
|||||||
|
|
||||||
def convert_to(self,val):
|
def convert_to(self,val):
|
||||||
if val == GREGORIAN:
|
if val == GREGORIAN:
|
||||||
self.convertGregorian()
|
self.convert_calendar(sdn_to_gregorian,val)
|
||||||
elif val == JULIAN:
|
elif val == JULIAN:
|
||||||
self.convertJulian()
|
self.convert_calendar(sdn_to_julian,val)
|
||||||
elif val == HEBREW:
|
elif val == HEBREW:
|
||||||
self.convertHebrew()
|
self.convert_calendar(sdn_to_hebrew,val)
|
||||||
else:
|
else:
|
||||||
self.convertFrench()
|
self.convert_calendar(sdn_to_french,val)
|
||||||
|
|
||||||
def convertFrench(self):
|
def convert_calendar(self,func,mode):
|
||||||
sdn = self.get_sdn()
|
sdn = self.get_sdn()
|
||||||
(y,m,d) = sdn_to_french(sdn)
|
(y,m,d) = func(sdn)
|
||||||
self.calendar = FRENCH
|
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 convertHebrew(self):
|
|
||||||
sdn = self.get_sdn()
|
|
||||||
(y,m,d) = sdn_to_jewish(sdn)
|
|
||||||
self.calendar = HEBREW
|
|
||||||
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 convertJulian(self):
|
|
||||||
sdn = self.get_sdn()
|
|
||||||
self.calendar = JULIAN
|
|
||||||
(y,m,d) = sdn_to_julian(sdn)
|
|
||||||
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 convertGregorian(self):
|
|
||||||
sdn = self.get_sdn()
|
|
||||||
self.calendar = GREGORIAN
|
|
||||||
(y,m,d) = sdn_to_gregorian(sdn)
|
|
||||||
if y == 0 and m == 0 and d == 0:
|
if y == 0 and m == 0 and d == 0:
|
||||||
self.year = _UNDEF
|
self.year = _UNDEF
|
||||||
self.month = _UNDEF
|
self.month = _UNDEF
|
||||||
@ -1196,11 +1022,3 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
print "----------"
|
print "----------"
|
||||||
checkit("BET. 1994 - 1999")
|
checkit("BET. 1994 - 1999")
|
||||||
sdn = french_to_sdn(1,1,1)
|
|
||||||
print sdn_to_gregorian(sdn)
|
|
||||||
|
|
||||||
d = Date()
|
|
||||||
d.get_start_date().setMonth(9)
|
|
||||||
d.get_start_date().setYear(1792)
|
|
||||||
d.get_start_date().setDay(22)
|
|
||||||
print d.get_start_date().getFrench()
|
|
||||||
|
@ -98,7 +98,7 @@ class EventEditor:
|
|||||||
self.place_field.set_text(event.getPlaceName())
|
self.place_field.set_text(event.getPlaceName())
|
||||||
if (def_placename):
|
if (def_placename):
|
||||||
self.place_field.set_text(def_placename)
|
self.place_field.set_text(def_placename)
|
||||||
self.date_field.set_text(event.getPrefDate())
|
self.date_field.set_text(self.date.getDate())
|
||||||
self.cause_field.set_text(event.getCause())
|
self.cause_field.set_text(event.getCause())
|
||||||
self.descr_field.set_text(event.getDescription())
|
self.descr_field.set_text(event.getDescription())
|
||||||
self.priv.set_active(event.getPrivacy())
|
self.priv.set_active(event.getPrivacy())
|
||||||
|
@ -454,16 +454,12 @@ class StyleSheetList:
|
|||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
try:
|
try:
|
||||||
f = open(self.file,"r")
|
parser = make_parser()
|
||||||
|
parser.setContentHandler(SheetParser(self))
|
||||||
|
parser.parse(self.file)
|
||||||
except:
|
except:
|
||||||
return
|
print "could not parse file"
|
||||||
|
|
||||||
parser = make_parser()
|
|
||||||
parser.setContentHandler(SheetParser(self))
|
|
||||||
parser.parse(f)
|
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -60,10 +60,14 @@ def report(database,person):
|
|||||||
females = 0
|
females = 0
|
||||||
bytes = 0
|
bytes = 0
|
||||||
namelist = []
|
namelist = []
|
||||||
|
notfound = []
|
||||||
|
|
||||||
pobjects = len(database.getObjectMap().values())
|
pobjects = len(database.getObjectMap().values())
|
||||||
for photo in database.getObjectMap().values():
|
for photo in database.getObjectMap().values():
|
||||||
bytes = bytes + posixpath.getsize(photo.getPath())
|
try:
|
||||||
|
bytes = bytes + posixpath.getsize(photo.getPath())
|
||||||
|
except:
|
||||||
|
notfound.append(photo.getPath())
|
||||||
|
|
||||||
for person in personList:
|
for person in personList:
|
||||||
length = len(person.getPhotoList())
|
length = len(person.getPhotoList())
|
||||||
@ -104,7 +108,12 @@ def report(database,person):
|
|||||||
text = text + "%s : %d\n" % (_("Number of unique media objects"),pobjects)
|
text = text + "%s : %d\n" % (_("Number of unique media objects"),pobjects)
|
||||||
text = text + "%s : %d %s\n" % (_("Total size of images"),bytes,\
|
text = text + "%s : %d %s\n" % (_("Total size of images"),bytes,\
|
||||||
_("bytes"))
|
_("bytes"))
|
||||||
|
|
||||||
|
if len(notfound) > 0:
|
||||||
|
text = text + "\n%s\n" % _("Missing Media Objects")
|
||||||
|
text = text + "----------------------------\n"
|
||||||
|
for p in notfound:
|
||||||
|
text = text + "%s\n" % p
|
||||||
|
|
||||||
top = topDialog.get_widget("summary")
|
top = topDialog.get_widget("summary")
|
||||||
textwindow = topDialog.get_widget("textwindow")
|
textwindow = topDialog.get_widget("textwindow")
|
||||||
|
Loading…
Reference in New Issue
Block a user