2006-05-01  Alex Roitman  <shura@gramps-project.org>
	* various: merge changes from gramps20.

In po:
2006-05-01  Alex Roitman  <shura@gramps-project.org>
	* POTFILES.in: Add new file.



svn: r6504
This commit is contained in:
Alex Roitman
2006-05-01 21:11:26 +00:00
parent bb9f7dc74d
commit 3fe3482efb
44 changed files with 2077 additions and 647 deletions

View File

@@ -14,6 +14,7 @@ pkgdata_PYTHON = \
_Date_fi.py\
_Date_sv.py\
_Date_nl.py\
_Date_sk.py\
_DateDisplay.py\
_DateParser.py\
_DateHandler.py\

View File

@@ -1,4 +1,4 @@
# -*- coding: iso-8859-1 -*-
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
@@ -70,20 +70,20 @@ class DateDisplay:
)
_french = (
'',
unicode("Vend<EFBFBD>miaire",'latin-1'),
'Brumaire',
'Frimaire',
unicode("Niv<EFBFBD>se",'latin-1'),
unicode("Pluvi<EFBFBD>se",'latin-1'),
unicode("Vent<EFBFBD>se",'latin-1'),
'Germinal',
unicode("Flor<EFBFBD>al",'latin-1'),
'Prairial',
'Messidor',
'Thermidor',
'Fructidor',
'Extra'
u'',
u"Vendémiaire",
u'Brumaire',
u'Frimaire',
u"Nivôse",
u"Pluviôse",
u"Ventôse",
u'Germinal',
u"Floréal",
u'Prairial',
u'Messidor',
u'Thermidor',
u'Fructidor',
u'Extra',
)
_persian = (
@@ -162,10 +162,6 @@ class DateDisplay:
d1 = self.display_iso(start)
d2 = self.display_iso(date.get_stop_date())
return "%s %s - %s%s" % (qual_str,d1,d2,self.calendar[cal])
elif mod == Date.MOD_RANGE:
d1 = self.display_iso(start)
d2 = self.display_iso(date.get_stop_date())
return "%s %s - %s%s" % (qual_str,d1,d2,self.calendar[cal])
else:
text = self.display_iso(start)
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
@@ -175,7 +171,12 @@ class DateDisplay:
val = - val
if slash:
year = "%d/%d" % (val,(val%10)+1)
if val % 100 == 99:
year = "%d/%d" % (val,(val%1000)+1)
elif val % 10 == 9:
year = "%d/%d" % (val,(val%100)+1)
else:
year = "%d/%d" % (val,(val%10)+1)
else:
year = "%d" % (val)
@@ -184,7 +185,8 @@ class DateDisplay:
def display_iso(self,date_val):
# YYYY-MM-DD (ISO)
year = self._slash_year(date_val[2],date_val[3])
if date_val[0] == 0:
# FIXME: This prodices 1789-11-00 and 1789-00-00 for incomplete dates.
if False:#date_val[0] == 0:
if date_val[1] == 0:
value = year
else:
@@ -209,13 +211,16 @@ class DateDisplay:
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
if date_val[3]:
return self.display_iso(date_val)
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(abs(date_val[2])))
value = value.replace('-','/')
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(abs(date_val[2])))
value = value.replace('-','/')
elif self.format == 2:
# Month Day, Year
if date_val[0] == 0:

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
@@ -122,13 +123,13 @@ class DateParser:
}
french_to_int = {
u'vend\xc3\xa9miaire' : 1, 'brumaire' : 2,
'frimaire' : 3, u'niv\xc3\xb4se ': 4,
u'pluvi\xc3\xb4se' : 5, u'vent\xc3\xb4se' : 6,
'germinal' : 7, u'flor\xc3\xa9al' : 8,
'prairial' : 9, 'messidor' : 10,
'thermidor' : 11, 'fructidor' : 12,
'extra' : 13
u'vendémiaire' : 1, u'brumaire' : 2,
u'frimaire' : 3, u'nivôse': 4,
u'pluviôse' : 5, u'ventôse' : 6,
u'germinal' : 7, u'floréal' : 8,
u'prairial' : 9, u'messidor' : 10,
u'thermidor' : 11, u'fructidor' : 12,
u'extra' : 13
}
islamic_to_int = {
@@ -150,15 +151,15 @@ class DateParser:
}
persian_to_int = {
"Farvardin" : 1, "Ordibehesht" : 2,
"Khordad" : 3, "Tir" : 4,
"Mordad" : 5, "Shahrivar" : 6,
"Mehr" : 7, "Aban" : 8,
"Azar" : 9, "Dey" : 10,
"Bahman" : 11, "Esfand" : 12,
"farvardin" : 1, "ordibehesht" : 2,
"khordad" : 3, "tir" : 4,
"mordad" : 5, "shahrivar" : 6,
"mehr" : 7, "aban" : 8,
"azar" : 9, "dey" : 10,
"bahman" : 11, "esfand" : 12,
}
bce = ["BC", "B\.C", "B\.C\.", "BCE", "B\.C\.E", "B\.C\.E"]
bce = ["B.C.E.", "B.C.E", "BCE", "B.C.", "B.C", "BC" ]
calendar_to_int = {
'gregorian' : Date.CAL_GREGORIAN,
@@ -200,9 +201,20 @@ class DateParser:
match = self._fmt_parse.match(fmt.lower())
if match:
self.dmy = (match.groups() == ('d','m','y'))
self.ymd = (match.groups() == ('y','m','d'))
else:
self.dmy = True
self.ymd = False
def re_longest_first(self, keys):
"""
returns a string for a RE group which contains the given keys
sorted so that longest keys match first. Any '.' characters
are quoted.
"""
keys.sort(lambda x, y: cmp(len(y), len(x)))
return '(' + '|'.join([key.replace('.','\.') for key in keys]) + ')'
def init_strings(self):
"""
This method compiles regular expression strings for matching dates.
@@ -217,38 +229,29 @@ class DateParser:
self._rfc_mon_str = '(' + '|'.join(self._rfc_mons_to_int.keys()) + ')'
self._rfc_day_str = '(' + '|'.join(self._rfc_days) + ')'
self._bce_str = '(' + '|'.join(self.bce) + ')'
self._qual_str = '(' + '|'.join(
[ key.replace('.','\.') for key in self.quality_to_int.keys() ]
) + ')'
keys = self.modifier_to_int.keys()
keys.sort(lambda x, y: cmp(len(y), len(x)))
self._mod_str = '(' + '|'.join(
[ key.replace('.','\.') for key in keys ]
) + ')'
self._mod_after_str = '(' + '|'.join(
[ key.replace('.','\.') for key in self.modifier_after_to_int.keys() ]
) + ')'
self._bce_str = self.re_longest_first(self.bce)
self._qual_str = self.re_longest_first(self.quality_to_int.keys())
self._mod_str = self.re_longest_first(self.modifier_to_int.keys())
self._mod_after_str = self.re_longest_first(
self.modifier_after_to_int.keys())
# Need to reverse-sort the keys, so that April matches before Apr does.
# Otherwise, 'april 2000' would be matched as 'apr' + garbage ('il 2000')
_month_keys = self.month_to_int.keys()
_month_keys.sort()
_month_keys.reverse()
self._mon_str = '(' + '|'.join(_month_keys) + ')'
self._jmon_str = '(' + '|'.join(self.hebrew_to_int.keys()) + ')'
self._fmon_str = '(' + '|'.join(self.french_to_int.keys()) + ')'
self._pmon_str = '(' + '|'.join(self.persian_to_int.keys()) + ')'
self._cal_str = '(' + '|'.join(self.calendar_to_int.keys()) + ')'
self._imon_str = '(' + '|'.join(self.islamic_to_int.keys()) + ')'
self._mon_str = self.re_longest_first(self.month_to_int.keys())
self._jmon_str = self.re_longest_first(self.hebrew_to_int.keys())
self._fmon_str = self.re_longest_first(self.french_to_int.keys())
self._pmon_str = self.re_longest_first(self.persian_to_int.keys())
self._imon_str = self.re_longest_first(self.islamic_to_int.keys())
self._cal_str = self.re_longest_first(self.calendar_to_int.keys())
self._bce_re = re.compile("(.+)\s+%s" % self._bce_str)
self._cal = re.compile("(.+)\s\(%s\)" % self._cal_str,
# bce, calendar type and quality may be either at the end or at
# the beginning of the given date string, therefore they will
# be parsed from the middle and will be in match.group(2).
self._bce_re = re.compile("(.*)\s+%s( ?.*)" % self._bce_str)
self._cal = re.compile("(.*)\s+\(%s\)( ?.*)" % self._cal_str,
re.IGNORECASE)
self._qual = re.compile("%s\s+(.+)" % self._qual_str,
self._qual = re.compile("(.* ?)%s\s+(.+)" % self._qual_str,
re.IGNORECASE)
self._span = re.compile("(from)\s+(?P<start>.+)\s+to\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile("(bet|bet.|between)\s+(?P<start>.+)\s+and\s+(?P<stop>.+)",
@@ -279,7 +282,7 @@ class DateParser:
self._itext2 = re.compile('(\d+)?\s+?%s\s*((\d+)(/\d+)?)?\s*$' % self._imon_str,
re.IGNORECASE)
self._numeric = re.compile("((\d+)[/\.])?((\d+)[/\.])?(\d+)\s*$")
self._iso = re.compile("(\d+)-(\d+)-(\d+)\s*$")
self._iso = re.compile("(\d+)(/(\d+))?-(\d+)-(\d+)\s*$")
self._rfc = re.compile("(%s,)?\s+(\d|\d\d)\s+%s\s+(\d+)\s+\d\d:\d\d(:\d\d)?\s+(\+|-)\d\d\d\d"
% (self._rfc_day_str,self._rfc_mon_str))
@@ -325,7 +328,7 @@ class DateParser:
if groups[2] == None:
y = self._get_int(groups[1])
d = 0
s = None
s = False
else:
d = self._get_int(groups[1])
y = int(groups[3])
@@ -346,8 +349,8 @@ class DateParser:
d = self._get_int(groups[0])
if groups[2] == None:
y = 0
s = None
y = None
s = False
else:
y = int(groups[3])
s = groups[4] != None
@@ -378,12 +381,14 @@ class DateParser:
if match:
groups = match.groups()
y = self._get_int(groups[0])
m = self._get_int(groups[1])
d = self._get_int(groups[2])
if gregorian_valid((d,m,y)):
return (d,m,y,False)
else:
m = self._get_int(groups[3])
d = self._get_int(groups[4])
if check and not check((d,m,y)):
return Date.EMPTY
if groups[2]:
return (d,m,y,True)
else:
return (d,m,y,False)
match = self._rfc.match(text)
if match:
@@ -391,21 +396,32 @@ class DateParser:
d = self._get_int(groups[2])
m = self._rfc_mons_to_int[groups[3]]
y = self._get_int(groups[4])
if gregorian_valid((d,m,y)):
return (d,m,y,False)
else:
return Date.EMPTY
value = (d,m,y,False)
if check and not check((d,m,y)):
value = Date.EMPTY
return value
match = self._numeric.match(text)
if match:
groups = match.groups()
if self.dmy:
m = self._get_int(groups[3])
d = self._get_int(groups[1])
if self.ymd:
# '1789' and ymd: incomplete date
if groups[1] == None:
y = self._get_int(groups[4])
m = 0
d = 0
else:
y = self._get_int(groups[1])
m = self._get_int(groups[3])
d = self._get_int(groups[4])
else:
m = self._get_int(groups[1])
d = self._get_int(groups[3])
y = self._get_int(groups[4])
y = self._get_int(groups[4])
if self.dmy:
m = self._get_int(groups[3])
d = self._get_int(groups[1])
else:
m = self._get_int(groups[1])
d = self._get_int(groups[3])
value = (d,m,y,False)
if check and not check((d,m,y)):
value = Date.EMPTY
@@ -417,26 +433,24 @@ class DateParser:
"""
Try parsing calendar.
Return calendar index and the remainder of text.
Return calendar index and the text with calendar removed.
"""
match = self._cal.match(text)
if match:
grps = match.groups()
cal = self.calendar_to_int[grps[1].lower()]
text = grps[0]
cal = self.calendar_to_int[match.group(2).lower()]
text = match.group(1) + match.group(3)
return (text,cal)
def match_quality(self,text,qual):
"""
Try matching quality.
Return quality index and the remainder of text.
Return quality index and the text with quality removed.
"""
match = self._qual.match(text)
if match:
grps = match.groups()
qual = self.quality_to_int[grps[0].lower()]
text = grps[1]
qual = self.quality_to_int[match.group(2).lower()]
text = match.group(1) + match.group(3)
return (text,qual)
def match_span(self,text,cal,qual,date):
@@ -448,8 +462,16 @@ class DateParser:
match = self._span.match(text)
if match:
text_parser = self.parser[cal]
start = self._parse_subdate(match.group('start'),text_parser)
stop = self._parse_subdate(match.group('stop'),text_parser)
(text1,bc1) = self.match_bce(match.group('start'))
start = self._parse_subdate(text1,text_parser)
if bc1:
start = self.invert_year(start)
(text2,bc2) = self.match_bce(match.group('stop'))
stop = self._parse_subdate(text2,text_parser)
if bc2:
stop = self.invert_year(stop)
date.set(qual,Date.MOD_SPAN,cal,start + stop)
return 1
return 0
@@ -463,8 +485,16 @@ class DateParser:
match = self._range.match(text)
if match:
text_parser = self.parser[cal]
start = self._parse_subdate(match.group('start'),text_parser)
stop = self._parse_subdate(match.group('stop'),text_parser)
(text1,bc1) = self.match_bce(match.group('start'))
start = self._parse_subdate(text1,text_parser)
if bc1:
start = self.invert_year(start)
(text2,bc2) = self.match_bce(match.group('stop'))
stop = self._parse_subdate(text2,text_parser)
if bc2:
stop = self.invert_year(stop)
date.set(qual,Date.MOD_RANGE,cal,start + stop)
return 1
return 0
@@ -473,12 +503,16 @@ class DateParser:
"""
Try matching BCE qualifier.
Return BCE (True/False) and the remainder of text.
Return BCE (True/False) and the text with matched part removed.
"""
match = self._bce_re.match(text)
bc = False
if match:
text = match.groups()[0]
# bce is in the match.group(2)
try:
text = match.group(1) + match.group(3)
except:
print "MATCH:", match.groups()
bc = True
return (text,bc)
@@ -492,8 +526,8 @@ class DateParser:
match = self._modifier.match(text)
if match:
grps = match.groups()
start = self._parse_subdate(grps[1])
mod = self.modifier_to_int.get(grps[0].lower(),Date.MOD_NONE)
start = self._parse_subdate(grps[1], self.parser[cal])
mod = self.modifier_to_int.get(grps[0].lower(), Date.MOD_NONE)
if bc:
date.set(qual,mod,cal,self.invert_year(start))
else:
@@ -504,7 +538,7 @@ class DateParser:
match = self._modifier_after.match(text)
if match:
grps = match.groups()
start = self._parse_subdate(grps[0])
start = self._parse_subdate(grps[0], self.parser[cal])
mod = self.modifier_after_to_int.get(grps[1].lower(),
Date.MOD_NONE)
if bc:
@@ -529,7 +563,6 @@ class DateParser:
Parses the text and sets the date according to the parsing.
"""
date.set_text_value(text)
qual = Date.QUAL_NONE
cal = Date.CAL_GREGORIAN

View File

@@ -88,17 +88,17 @@ class DateParserDE(DateParser):
}
calendar_to_int = {
u'Gregorianisch' : Date.CAL_GREGORIAN,
u'Greg.' : Date.CAL_GREGORIAN,
u'Julianisch' : Date.CAL_JULIAN,
u'Jul.' : Date.CAL_JULIAN,
u'Hebräisch' : Date.CAL_HEBREW,
u'Hebr.' : Date.CAL_HEBREW,
u'Islamisch' : Date.CAL_ISLAMIC,
u'Isl.' : Date.CAL_ISLAMIC,
u'Französisch Republikanisch': Date.CAL_FRENCH,
u'Franz.' : Date.CAL_FRENCH,
u'Persisch' : Date.CAL_PERSIAN,
u'gregorianisch' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'julianisch' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebräisch' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamisch' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'französisch republikanisch': Date.CAL_FRENCH,
u'franz.' : Date.CAL_FRENCH,
u'persisch' : Date.CAL_PERSIAN,
}
quality_to_int = {
@@ -109,7 +109,10 @@ class DateParserDE(DateParser):
u'ber.' : Date.QUAL_CALCULATED,
}
bce = DateParser.bce + ["vor (unserer|der) Zeit(rechnung)?", "v\. (u|d)\. Z\.", "vor Christus", "vor Christi Geburt", "v\. Chr\."]
bce = ["vor unserer Zeitrechnung", "vor unserer Zeit",
"vor der Zeitrechnung", "vor der Zeit",
"v. u. Z.", "v. d. Z.", "v.u.Z.", "v.d.Z.",
"vor Christi Geburt", "vor Christus", "v. Chr."] + DateParser.bce
def init_strings(self):
DateParser.init_strings(self)
@@ -128,8 +131,8 @@ class DateParserDE(DateParser):
class DateDisplayDE(DateDisplay):
calendar = (
"", u" (Julianisch)", u" (Hebräisch)",
u" (Französisch Republikanisch)", u" (Persisch)", u" (Islamisch)"
"", u" (julianisch)", u" (hebräisch)",
u" (französisch republikanisch)", u" (persisch)", u" (islamisch)"
)
_mod_str = ("",u"vor ",u"nach ",u"etwa ","","","")
@@ -146,14 +149,17 @@ class DateDisplayDE(DateDisplay):
def _display_gregorian(self,date_val):
year = self._slash_year(date_val[2],date_val[3])
if self.format == 0:
value = self.display_iso(date_val)
return self.display_iso(date_val)
elif self.format == 1:
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
if date_val[3]:
return self.display_iso(date_val)
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(date_val[2]))
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(date_val[2]))
elif self.format == 2:
# Month Day, Year
if date_val[0] == 0:
@@ -190,7 +196,10 @@ class DateDisplayDE(DateDisplay):
value = "%s %s" % (self._MONS[date_val[1]],year)
else:
value = "%d. %s %s" % (date_val[0],self._MONS[date_val[1]],year)
return value
if date_val[2] < 0:
return self._bce_str % value
else:
return value
def display(self,date):
"""

View File

@@ -97,7 +97,7 @@ class DateParserES(DateParser):
DateParser.init_strings(self)
_span_1 = [u'de']
_span_2 = [u'a']
_range_1 = [u'ent.',u'ent',u'entre']
_range_1 = [u'entre',u'ent\.',u'ent']
_range_2 = [u'y']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),

View File

@@ -72,7 +72,7 @@ class DateParserFI(DateParser):
u'j.' : Date.MOD_AFTER,
}
bce = ["ekr", "ekr\."]
bce = [u"ekr.", u"ekr"]
calendar_to_int = {
u'gregoriaaninen' : Date.CAL_GREGORIAN,
@@ -99,9 +99,9 @@ class DateParserFI(DateParser):
def init_strings(self):
DateParser.init_strings(self)
# date, whitespace
self._span = re.compile("(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
self._span = re.compile(u"(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
re.IGNORECASE)
self._range = re.compile("(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
self._range = re.compile(u"(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
re.IGNORECASE)
#-------------------------------------------------------------------------
@@ -112,15 +112,15 @@ class DateParserFI(DateParser):
class DateDisplayFI(DateDisplay):
calendar = ("",
u"(Juliaaninen)",
u"(Heprealainen)",
u"(Ranskan v.)",
u"(Persialainen)",
u"(Islamilainen)")
u"(juliaaninen)",
u"(heprealainen)",
u"(ranskan v.)",
u"(persialainen)",
u"(islamilainen)")
_qual_str = ("", "arviolta", "laskettuna")
_qual_str = (u"", u"arviolta", u"laskettuna")
_bce_str = "%s ekr."
_bce_str = u"%s ekr."
formats = (
"VVVV-KK-PP (ISO)",
@@ -139,7 +139,7 @@ class DateDisplayFI(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
if start == Date.EMPTY:
return ""
return u""
# select numerical date format
self.format = 1
@@ -147,32 +147,32 @@ class DateDisplayFI(DateDisplay):
if mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
text = "%s - %s" % (d1, d2)
text = u"%s - %s" % (d1, d2)
elif mod == Date.MOD_RANGE:
stop = date.get_stop_date()
if start[0] == 0 and start[1] == 0 and stop[0] == 0 and stop[1] == 0:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = "vuosien %s ja %s välillä" % (d1, d2)
text = u"vuosien %s ja %s välillä" % (d1, d2)
else:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](stop)
text = "%s ja %s välillä" % (d1, d2)
text = u"%s ja %s välillä" % (d1, d2)
else:
text = self.display_cal[date.get_calendar()](start)
if mod == Date.MOD_AFTER:
text = text + " jälkeen"
text = text + u" jälkeen"
elif mod == Date.MOD_ABOUT:
text = "noin " + text
text = u"noin " + text
elif mod == Date.MOD_BEFORE:
text = "ennen " + text
text = u"ennen " + text
if qual:
# prepend quality
text = "%s %s" % (self._qual_str[qual], text)
text = u"%s %s" % (self._qual_str[qual], text)
if cal:
# append calendar type
text = "%s %s" % (text, self.calendar[cal])
text = u"%s %s" % (text, self.calendar[cal])
return text

View File

@@ -90,7 +90,6 @@ class DateParserFR(DateParser):
modifier_to_int = {
u'avant' : Date.MOD_BEFORE,
u'av.' : Date.MOD_BEFORE,
u'av' : Date.MOD_BEFORE,
u'après' : Date.MOD_AFTER,
u'ap.' : Date.MOD_AFTER,
u'ap' : Date.MOD_AFTER,
@@ -134,8 +133,11 @@ class DateParserFR(DateParser):
def init_strings(self):
DateParser.init_strings(self)
self._span = re.compile("(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",re.IGNORECASE)
self._range = re.compile("(entre|ent|ent.)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",re.IGNORECASE)
# This self._numeric is different from the base
# by allowing space after the slash/dot
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
self._span = re.compile(u"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",re.IGNORECASE)
self._range = re.compile(u"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",re.IGNORECASE)
self._text2 =re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
re.IGNORECASE)
self._jtext2 =re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str,
@@ -155,24 +157,27 @@ class DateDisplayFR(DateDisplay):
_mod_str = ("",u"avant ",u"après ",u"vers ","","","")
_qual_str = ("","estimée ","calculée ","")
_qual_str = ("",u"estimée ",u"calculée ","")
formats = (
"AAAA-MM-DD (ISO)", "Numérique", "Mois Jour, Année",
"MOI Jour, Année", "Jour Mois, Année", "Jour MOIS Année"
"AAAA-MM-JJ (ISO)", "Numérique", "Mois Jour, Année",
"MOI Jour, Année", "Jour Mois, Année", "Jour MOI Année"
)
def _display_gregorian(self,date_val):
year = self._slash_year(date_val[2],date_val[3])
if self.format == 0:
value = self.display_iso(date_val)
return self.display_iso(date_val)
elif self.format == 1:
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
if date_val[3]:
return self.display_iso(date_val)
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(date_val[2]))
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(date_val[2]))
elif self.format == 2:
# Month Day, Year
if date_val[0] == 0:
@@ -209,7 +214,11 @@ class DateDisplayFR(DateDisplay):
value = "%s %s" % (self._MONS[date_val[1]],year)
else:
value = "%d. %s %s" % (date_val[0],self._MONS[date_val[1]],year)
return value
if date_val[2] < 0:
return self._bce_str % value
else:
return value
def display(self,date):
"""
@@ -243,5 +252,6 @@ class DateDisplayFR(DateDisplay):
# Register classes
#
#-------------------------------------------------------------------------
register_datehandler(('fr_FR','fr','french','fr_CA','fr_BE','fr_CH'),
DateParserFR,DateDisplayFR)
register_datehandler(
('fr_FR','fr','french','fr_CA','fr_BE','fr_CH','fr_LU'),
DateParserFR,DateDisplayFR)

View File

@@ -56,17 +56,17 @@ class DateParserLT(DateParser):
}
calendar_to_int = {
u'Grigaliaus' : Date.CAL_GREGORIAN,
u'grigaliaus' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'Julijaus' : Date.CAL_JULIAN,
u'julijaus' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'Hebrajų' : Date.CAL_HEBREW,
u'hebrajų' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'Islamo' : Date.CAL_ISLAMIC,
u'islamo' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'Prancuzų Respublikos': Date.CAL_FRENCH,
u'prancuzų respublikos': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'Persų' : Date.CAL_PERSIAN,
u'persų' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
}
@@ -96,18 +96,20 @@ class DateParserLT(DateParser):
class DateDisplayLT(DateDisplay):
calendar = (
"", u" (Julijaus)",
u" (Hebrajų)",
u" (Prancuzų Respublikos)",
u" (Persų)",
u" (Islamo)"
u"", u" (julijaus)",
u" (hebrajų)",
u" (prancuzų respublikos)",
u" (persų)",
u" (islamo)"
)
_mod_str = ("",u"iki ",
_mod_str = (u"",
u"prieš ",
u"po ",
u"apie ","","","")
u"apie ",
u"",u"",u"")
_qual_str = ("","apytikriai ","apskaičiuota ")
_qual_str = (u"",u"apytikriai ",u"apskaičiuota ")
formats = (
"YYYY-MM-DD (ISO)", "Skaitmeninis", "Mėnuo Diena, Metai",
@@ -132,7 +134,7 @@ class DateDisplayLT(DateDisplay):
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
return "%sс %s %s %s%s" % (qual_str,d1,u'iki',d2,self.calendar[cal])
return "%s%s %s %s %s%s" % (qual_str,u'nuo',d1,u'iki',d2,self.calendar[cal])
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())

View File

@@ -92,17 +92,17 @@ class DateParserNL(DateParser):
}
calendar_to_int = {
u'Gregoriaans' : Date.CAL_GREGORIAN,
u'Greg.' : Date.CAL_GREGORIAN,
u'Juliaans' : Date.CAL_JULIAN,
u'Jul.' : Date.CAL_JULIAN,
u'Hebreeuws' : Date.CAL_HEBREW,
u'Hebr.' : Date.CAL_HEBREW,
u'Islamitisch' : Date.CAL_ISLAMIC,
u'Isl.' : Date.CAL_ISLAMIC,
u'Franse republiek': Date.CAL_FRENCH,
u'Fran.' : Date.CAL_FRENCH,
u'Persisch' : Date.CAL_PERSIAN,
u'gregoriaans' : Date.CAL_GREGORIAN,
u'greg.' : Date.CAL_GREGORIAN,
u'juliaans' : Date.CAL_JULIAN,
u'jul.' : Date.CAL_JULIAN,
u'hebreeuws' : Date.CAL_HEBREW,
u'hebr.' : Date.CAL_HEBREW,
u'islamitisch' : Date.CAL_ISLAMIC,
u'isl.' : Date.CAL_ISLAMIC,
u'franse republiek': Date.CAL_FRENCH,
u'fran.' : Date.CAL_FRENCH,
u'persisch' : Date.CAL_PERSIAN,
}
quality_to_int = {
@@ -112,9 +112,7 @@ class DateParserNL(DateParser):
u'ber.' : Date.QUAL_CALCULATED,
}
bce = DateParser.bce + ["voor onze tijdrekening",
"voor Christus",
"v\. Chr\."]
bce = ["voor onze tijdrekening","voor Christus","v. Chr."] + DateParser.bce
def init_strings(self):
DateParser.init_strings(self)
@@ -137,8 +135,8 @@ class DateParserNL(DateParser):
class DateDisplayNL(DateDisplay):
calendar = (
"", u" (Juliaans)", u" (Hebreeuws)",
u" (Franse Republiek)", u" (Persisch)", u" (Islamitisch)"
"", u" (juliaans)", u" (hebreeuws)",
u" (franse republiek)", u" (persisch)", u" (islamitisch)"
)
_mod_str = ("",u"voor ",u"na ",u"rond ","","","")
@@ -157,14 +155,17 @@ class DateDisplayNL(DateDisplay):
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# Numeric
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
if date_val[3]:
return self.display_iso(date_val)
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(abs(date_val[2])))
value = value.replace('-','/')
# Numeric
if date_val[0] == 0 and date_val[1] == 0:
value = str(date_val[2])
else:
value = self._tformat.replace('%m',str(date_val[1]))
value = value.replace('%d',str(date_val[0]))
value = value.replace('%Y',str(abs(date_val[2])))
value = value.replace('-','/')
elif self.format == 2:
# Month Day, Year
if date_val[0] == 0:

View File

@@ -50,7 +50,7 @@ from _DateHandler import register_datehandler
class DateParserRU(DateParser):
modifier_to_int = {
u'до' : Date.MOD_BEFORE,
u'перед' : Date.MOD_BEFORE,
u'по' : Date.MOD_BEFORE,
u'после' : Date.MOD_AFTER,
u'п.' : Date.MOD_AFTER,
@@ -97,11 +97,77 @@ class DateParserRU(DateParser):
u'выч' : Date.QUAL_CALCULATED,
}
hebrew_to_int = {
u"тишрей":1,
u"хешван":2,
u"кислев":3,
u"тевет":4,
u"шеват":5,
u"адар":6,
u"адар бет":7,
u"нисан":8,
u"ияр":9,
u"сиван":10,
u"таммуз":11,
u"ав":12,
u"элул":13,
}
islamic_to_int = {
u"мухаррам":1,
u"сафар":2,
u"раби-аль-авваль":3,
u"раби-ассани":4,
u"джумада-аль-уля":5,
u"джумада-аль-ахира":6,
u"раджаб":7,
u"шаабан":8,
u"рамадан":9,
u"шавваль":10,
u"зуль-каада":11,
u"зуль-хиджжа":12,
}
persian_to_int = {
u"фарвардин":1,
u"урдбихишт":2,
u"хурдад":3,
u"тир":4,
u"мурдад":5,
u"шахривар":6,
u"михр":7,
u"абан":8,
u"азар":9,
u"дай":10,
u"бахман":11,
u"исфаидармуз":12,
}
french_to_int = {
u"вандемьер":1,
u"брюмер":2,
u"фример":3,
u"нивоз":4,
u"плювиоз":5,
u"вантоз":6,
u"жерминаль":7,
u"флореаль":8,
u"прериаль":9,
u"мессидор":10,
u"термидор":11,
u"фрюктидор":12,
u"дополнит.":13,
}
bce = [
u'до нашей эры', u'до н. э.', u'до н.э.',
u'до н э', u'до нэ'] + DateParser.bce
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'с',u'от']
_span_2 = [u'по',u'до']
_range_1 = [u'между',u'меж',u'меж.']
_span_2 = [u'по']
_range_1 = [u'между',u'меж\.',u'меж']
_range_2 = [u'и']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),
@@ -118,24 +184,92 @@ class DateParserRU(DateParser):
class DateDisplayRU(DateDisplay):
calendar = (
"", u" (юлианский)",
u"",
u" (юлианский)",
u" (еврейский)",
u" (республиканский)",
u" (персидский)",
u" (исламский)"
)
_mod_str = ("",u"до ",
_mod_str = (
u"",
u"перед ",
u"после ",
u"около ","","","")
u"около ",
u"",u"",u"")
_qual_str = ("","оцен ","вычисл ")
_qual_str = (u"",u"оцен ",u"вычисл ")
_bce_str = u"%s до н.э."
formats = (
"ГГГГ-ММ-ДД (ISO)", "Численный", "Месяц День, Год",
"МЕС ДД, ГГГГГ", "День Месяц, Год", "ДД МЕС, ГГГГГ"
)
_hebrew = ( u"",
u"Тишрей",
u"Хешван",
u"Кислев",
u"Тевет",
u"Шеват",
u"Адар",
u"Адар бет",
u"Нисан",
u"Ияр",
u"Сиван",
u"Таммуз",
u"Ав",
u"Элул",
)
_islamic = ( u"",
u"Мухаррам",
u"Сафар",
u"Раби-аль-авваль",
u"Раби-ассани",
u"Джумада-аль-уля",
u"Джумада-аль-ахира",
u"Раджаб",
u"Шаабан",
u"Рамадан",
u"Шавваль",
u"Зуль-каада",
u"Зуль-хиджжа",
)
_persian = ( u"",
u"Фарвардин",
u"Урдбихишт",
u"Хурдад",
u"Тир",
u"Мурдад",
u"Шахривар",
u"Михр",
u"Абан",
u"Азар",
u"Дай",
u"Бахман",
u"Исфаидармуз",
)
_french = ( u"",
u"Вандемьер",
u"Брюмер",
u"Фример",
u"Нивоз",
u"Плювиоз",
u"Вантоз",
u"Жерминаль",
u"Флореаль",
u"Прериаль",
u"Мессидор",
u"Термидор",
u"Фрюктидор",
u"Дополнит."
)
def display(self,date):
"""
Returns a text string representing the date.

149
src/DateHandler/_Date_sk.py Normal file
View File

@@ -0,0 +1,149 @@
# -*- coding: utf-8 -*-
#
# Gramps - a GTK+/GNOME based genealogy program
#
# 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
# 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: Date_sk.py,v 1.1.2.4 2006/04/16 03:20:06 rshura Exp $
"""
Slovak-specific classes for parsing and displaying dates.
"""
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import re
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import Date
from DateParser import DateParser
from DateDisplay import DateDisplay
#-------------------------------------------------------------------------
#
# Slovak parser
#
#-------------------------------------------------------------------------
class DateParserSK(DateParser):
modifier_to_int = {
u'pred' : Date.MOD_BEFORE,
u'do' : Date.MOD_BEFORE,
u'po' : Date.MOD_AFTER,
u'asi' : Date.MOD_ABOUT,
u'okolo' : Date.MOD_ABOUT,
u'pribl.' : Date.MOD_ABOUT,
}
calendar_to_int = {
u'gregoriánsky' : Date.CAL_GREGORIAN,
u'g' : Date.CAL_GREGORIAN,
u'juliánský' : Date.CAL_JULIAN,
u'j' : Date.CAL_JULIAN,
u'hebrejský' : Date.CAL_HEBREW,
u'h' : Date.CAL_HEBREW,
u'islamský' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC,
u'republikánsky': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH,
u'perzský' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN,
}
quality_to_int = {
u'odhadovaný' : Date.QUAL_ESTIMATED,
u'odh.' : Date.QUAL_ESTIMATED,
u'vypočítaný' : Date.QUAL_CALCULATED,
u'vyp.' : Date.QUAL_CALCULATED,
}
def init_strings(self):
DateParser.init_strings(self)
_span_1 = [u'od']
_span_2 = [u'do']
_range_1 = [u'medzi']
_range_2 = [u'a']
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_span_1),'|'.join(_span_2)),
re.IGNORECASE)
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
('|'.join(_range_1),'|'.join(_range_2)),
re.IGNORECASE)
#-------------------------------------------------------------------------
#
# Slovak display
#
#-------------------------------------------------------------------------
class DateDisplaySK(DateDisplay):
calendar = (
"", u" (juliánský)", u" (hebrejský)",
u" (republikánsky)", u" (perzský)", u" (islamský)"
)
_mod_str = ("",u"pred ",u"po ",u"okolo ","","","")
_qual_str = ("","odh. ","vyp. ")
formats = (
"RRRR-MM-DD (ISO)", "numerický", "Mesiac Deň, Rok",
"MES Deň, Rok", "Deň, Mesiac, Rok", "Deň MES Rok"
)
def display(self,date):
"""
Returns a text string representing the date.
"""
mod = date.get_modifier()
cal = date.get_calendar()
qual = date.get_quality()
start = date.get_start_date()
qual_str = self._qual_str[qual]
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return ""
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
return "%s%s %s %s %s%s" % (qual_str,u'od',d1,u'do',d2,self.calendar[cal])
elif mod == Date.MOD_RANGE:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
return "%s%s %s %s %s%s" % (qual_str,u'medzi',d1,u'a',d2,self.calendar[cal])
else:
text = self.display_cal[date.get_calendar()](start)
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
#-------------------------------------------------------------------------
#
# Register classes
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('sk_SK','sk','SK'),DateParserSK, DateDisplaySK)

View File

@@ -145,7 +145,7 @@ class DateDisplaySv(DateDisplay):
if mod == Date.MOD_TEXTONLY:
return date.get_text()
elif start == Date.EMPTY:
return ""
return u""
elif mod == Date.MOD_SPAN:
d1 = self.display_cal[cal](start)
d2 = self.display_cal[cal](date.get_stop_date())
@@ -157,7 +157,7 @@ class DateDisplaySv(DateDisplay):
self.calendar[cal])
else:
text = self.display_cal[date.get_calendar()](start)
return "%s%s%s%s" % (qual_str,self._mod_str[mod],
return u"%s%s%s%s" % (qual_str,self._mod_str[mod],
text,self.calendar[cal])
#-------------------------------------------------------------------------