2007-04-04 Don Allingham <don@gramps-project.org>
* src/DateHandler/_DateParser.py: fix text string that contians a valid modifier. * src/Editors/_EditPerson.py: disable OK button on save to prevent double clicks * src/Editors/_EditPrimary.py: disable OK button on save to prevent double clicks * src/docgen/ODFDoc.py: XML escape strings svn: r8351
This commit is contained in:
parent
6948cf26e2
commit
2fb4abbb1f
@ -1,3 +1,12 @@
|
|||||||
|
2007-04-04 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/DateHandler/_DateParser.py: fix text string that contians a valid
|
||||||
|
modifier.
|
||||||
|
* src/Editors/_EditPerson.py: disable OK button on save to prevent
|
||||||
|
double clicks
|
||||||
|
* src/Editors/_EditPrimary.py: disable OK button on save to prevent
|
||||||
|
double clicks
|
||||||
|
* src/docgen/ODFDoc.py: XML escape strings
|
||||||
|
|
||||||
2007-04-01 Benny Malengier <bm@cage.ugent.be>
|
2007-04-01 Benny Malengier <bm@cage.ugent.be>
|
||||||
* help/nl/nl.po: correct keyword error
|
* help/nl/nl.po: correct keyword error
|
||||||
NarrativeWeb
|
NarrativeWeb
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#
|
s#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||||
|
@ -296,27 +296,27 @@ class DateParser:
|
|||||||
else:
|
else:
|
||||||
return int(val)
|
return int(val)
|
||||||
|
|
||||||
def _parse_hebrew(self,text):
|
def _parse_hebrew(self, text):
|
||||||
return self._parse_calendar(text,self._jtext,self._jtext2,
|
return self._parse_calendar(text, self._jtext, self._jtext2,
|
||||||
self.hebrew_to_int)
|
self.hebrew_to_int)
|
||||||
|
|
||||||
def _parse_islamic(self,text):
|
def _parse_islamic(self, text):
|
||||||
return self._parse_calendar(text,self._itext,self._itext2,
|
return self._parse_calendar(text, self._itext, self._itext2,
|
||||||
self.islamic_to_int)
|
self.islamic_to_int)
|
||||||
|
|
||||||
def _parse_persian(self,text):
|
def _parse_persian(self, text):
|
||||||
return self._parse_calendar(text,self._ptext,self._ptext2,
|
return self._parse_calendar(text, self._ptext, self._ptext2,
|
||||||
self.persian_to_int)
|
self.persian_to_int)
|
||||||
|
|
||||||
def _parse_french(self,text):
|
def _parse_french(self, text):
|
||||||
return self._parse_calendar(text,self._ftext,self._ftext2,
|
return self._parse_calendar(text, self._ftext, self._ftext2,
|
||||||
self.french_to_int)
|
self.french_to_int)
|
||||||
|
|
||||||
def _parse_greg_julian(self,text):
|
def _parse_greg_julian(self, text):
|
||||||
return self._parse_calendar(text,self._text,self._text2,
|
return self._parse_calendar(text, self._text,s elf._text2,
|
||||||
self.month_to_int,gregorian_valid)
|
self.month_to_int, gregorian_valid)
|
||||||
|
|
||||||
def _parse_calendar(self,text,regex1,regex2,mmap,check=None):
|
def _parse_calendar(self, text, regex1, regex2, mmap, check=None):
|
||||||
match = regex1.match(text.lower())
|
match = regex1.match(text.lower())
|
||||||
if match:
|
if match:
|
||||||
groups = match.groups()
|
groups = match.groups()
|
||||||
@ -333,8 +333,8 @@ class DateParser:
|
|||||||
d = self._get_int(groups[1])
|
d = self._get_int(groups[1])
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
s = groups[4] != None
|
s = groups[4] != None
|
||||||
value = (d,m,y,s)
|
value = (d, m, y, s)
|
||||||
if check and not check((d,m,y)):
|
if check and not check((d, m, y)):
|
||||||
value = Date.EMPTY
|
value = Date.EMPTY
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@ -354,14 +354,14 @@ class DateParser:
|
|||||||
else:
|
else:
|
||||||
y = int(groups[3])
|
y = int(groups[3])
|
||||||
s = groups[4] != None
|
s = groups[4] != None
|
||||||
value = (d,m,y,s)
|
value = (d, m, y, s)
|
||||||
if check and not check((d,m,y)):
|
if check and not check((d, m, y)):
|
||||||
value = Date.EMPTY
|
value = Date.EMPTY
|
||||||
return value
|
return value
|
||||||
|
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
|
|
||||||
def _parse_subdate(self,text,subparser=None):
|
def _parse_subdate(self, text, subparser=None):
|
||||||
"""
|
"""
|
||||||
Converts only the date portion of a date.
|
Converts only the date portion of a date.
|
||||||
"""
|
"""
|
||||||
@ -383,12 +383,12 @@ class DateParser:
|
|||||||
y = self._get_int(groups[0])
|
y = self._get_int(groups[0])
|
||||||
m = self._get_int(groups[3])
|
m = self._get_int(groups[3])
|
||||||
d = self._get_int(groups[4])
|
d = self._get_int(groups[4])
|
||||||
if check and not check((d,m,y)):
|
if check and not check((d, m, y)):
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
if groups[2]:
|
if groups[2]:
|
||||||
return (d,m,y,True)
|
return (d, m, y,True)
|
||||||
else:
|
else:
|
||||||
return (d,m,y,False)
|
return (d, m, y,False)
|
||||||
|
|
||||||
match = self._rfc.match(text)
|
match = self._rfc.match(text)
|
||||||
if match:
|
if match:
|
||||||
@ -396,8 +396,8 @@ class DateParser:
|
|||||||
d = self._get_int(groups[2])
|
d = self._get_int(groups[2])
|
||||||
m = self._rfc_mons_to_int[groups[3]]
|
m = self._rfc_mons_to_int[groups[3]]
|
||||||
y = self._get_int(groups[4])
|
y = self._get_int(groups[4])
|
||||||
value = (d,m,y,False)
|
value = (d, m, y, False)
|
||||||
if check and not check((d,m,y)):
|
if check and not check((d, m, y)):
|
||||||
value = Date.EMPTY
|
value = Date.EMPTY
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ class DateParser:
|
|||||||
|
|
||||||
return Date.EMPTY
|
return Date.EMPTY
|
||||||
|
|
||||||
def match_calendar(self,text,cal):
|
def match_calendar(self, text, cal):
|
||||||
"""
|
"""
|
||||||
Try parsing calendar.
|
Try parsing calendar.
|
||||||
|
|
||||||
@ -441,7 +441,7 @@ class DateParser:
|
|||||||
text = match.group(1) + match.group(3)
|
text = match.group(1) + match.group(3)
|
||||||
return (text,cal)
|
return (text,cal)
|
||||||
|
|
||||||
def match_quality(self,text,qual):
|
def match_quality(self, text, qual):
|
||||||
"""
|
"""
|
||||||
Try matching quality.
|
Try matching quality.
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ class DateParser:
|
|||||||
text = match.group(1) + match.group(3)
|
text = match.group(1) + match.group(3)
|
||||||
return (text,qual)
|
return (text,qual)
|
||||||
|
|
||||||
def match_span(self,text,cal,qual,date):
|
def match_span(self, text, cal, qual, date):
|
||||||
"""
|
"""
|
||||||
Try matching span date.
|
Try matching span date.
|
||||||
|
|
||||||
@ -468,15 +468,15 @@ class DateParser:
|
|||||||
start = self.invert_year(start)
|
start = self.invert_year(start)
|
||||||
|
|
||||||
(text2,bc2) = self.match_bce(match.group('stop'))
|
(text2,bc2) = self.match_bce(match.group('stop'))
|
||||||
stop = self._parse_subdate(text2,text_parser)
|
stop = self._parse_subdate(text2, text_parser)
|
||||||
if bc2:
|
if bc2:
|
||||||
stop = self.invert_year(stop)
|
stop = self.invert_year(stop)
|
||||||
|
|
||||||
date.set(qual,Date.MOD_SPAN,cal,start + stop)
|
date.set(qual, Date.MOD_SPAN, cal, start + stop)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def match_range(self,text,cal,qual,date):
|
def match_range(self, text, cal, qual, date):
|
||||||
"""
|
"""
|
||||||
Try matching range date.
|
Try matching range date.
|
||||||
|
|
||||||
@ -486,20 +486,20 @@ class DateParser:
|
|||||||
if match:
|
if match:
|
||||||
text_parser = self.parser[cal]
|
text_parser = self.parser[cal]
|
||||||
(text1,bc1) = self.match_bce(match.group('start'))
|
(text1,bc1) = self.match_bce(match.group('start'))
|
||||||
start = self._parse_subdate(text1,text_parser)
|
start = self._parse_subdate(text1, text_parser)
|
||||||
if bc1:
|
if bc1:
|
||||||
start = self.invert_year(start)
|
start = self.invert_year(start)
|
||||||
|
|
||||||
(text2,bc2) = self.match_bce(match.group('stop'))
|
(text2,bc2) = self.match_bce(match.group('stop'))
|
||||||
stop = self._parse_subdate(text2,text_parser)
|
stop = self._parse_subdate(text2, text_parser)
|
||||||
if bc2:
|
if bc2:
|
||||||
stop = self.invert_year(stop)
|
stop = self.invert_year(stop)
|
||||||
|
|
||||||
date.set(qual,Date.MOD_RANGE,cal,start + stop)
|
date.set(qual, Date.MOD_RANGE, cal, start + stop)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def match_bce(self,text):
|
def match_bce(self, text):
|
||||||
"""
|
"""
|
||||||
Try matching BCE qualifier.
|
Try matching BCE qualifier.
|
||||||
|
|
||||||
@ -514,9 +514,9 @@ class DateParser:
|
|||||||
except:
|
except:
|
||||||
print "MATCH:", match.groups()
|
print "MATCH:", match.groups()
|
||||||
bc = True
|
bc = True
|
||||||
return (text,bc)
|
return (text, bc)
|
||||||
|
|
||||||
def match_modifier(self,text,cal,qual,bc,date):
|
def match_modifier(self, text, cal, qual, bc, date):
|
||||||
"""
|
"""
|
||||||
Try matching date with modifier.
|
Try matching date with modifier.
|
||||||
|
|
||||||
@ -528,10 +528,13 @@ class DateParser:
|
|||||||
grps = match.groups()
|
grps = match.groups()
|
||||||
start = self._parse_subdate(grps[1], self.parser[cal])
|
start = self._parse_subdate(grps[1], self.parser[cal])
|
||||||
mod = self.modifier_to_int.get(grps[0].lower(), Date.MOD_NONE)
|
mod = self.modifier_to_int.get(grps[0].lower(), Date.MOD_NONE)
|
||||||
if bc:
|
if start == Date.EMPTY:
|
||||||
date.set(qual,mod,cal,self.invert_year(start))
|
date.set_modifier(Date.MOD_TEXTONLY)
|
||||||
|
date.set_text_value(text)
|
||||||
|
elif bc:
|
||||||
|
date.set(qual, mod, cal, self.invert_year(start))
|
||||||
else:
|
else:
|
||||||
date.set(qual,mod,cal,start)
|
date.set(qual, mod, cal, start)
|
||||||
return True
|
return True
|
||||||
# modifiers after the date
|
# modifiers after the date
|
||||||
if self.modifier_after_to_int:
|
if self.modifier_after_to_int:
|
||||||
@ -542,9 +545,9 @@ class DateParser:
|
|||||||
mod = self.modifier_after_to_int.get(grps[1].lower(),
|
mod = self.modifier_after_to_int.get(grps[1].lower(),
|
||||||
Date.MOD_NONE)
|
Date.MOD_NONE)
|
||||||
if bc:
|
if bc:
|
||||||
date.set(qual,mod,cal,self.invert_year(start))
|
date.set(qual, mod, cal, self.invert_year(start))
|
||||||
else:
|
else:
|
||||||
date.set(qual,mod,cal,start)
|
date.set(qual, mod, cal, start)
|
||||||
return True
|
return True
|
||||||
match = self._abt2.match(text)
|
match = self._abt2.match(text)
|
||||||
if match:
|
if match:
|
||||||
@ -552,13 +555,13 @@ class DateParser:
|
|||||||
start = self._parse_subdate(grps[0])
|
start = self._parse_subdate(grps[0])
|
||||||
mod = Date.MOD_ABOUT
|
mod = Date.MOD_ABOUT
|
||||||
if bc:
|
if bc:
|
||||||
date.set(qual,mod,cal,self.invert_year(start))
|
date.set(qual, mod, cal, self.invert_year(start))
|
||||||
else:
|
else:
|
||||||
date.set(qual,mod,cal,start)
|
date.set(qual, mod, cal, start)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def set_date(self,date,text):
|
def set_date(self, date, text):
|
||||||
"""
|
"""
|
||||||
Parses the text and sets the date according to the parsing.
|
Parses the text and sets the date according to the parsing.
|
||||||
"""
|
"""
|
||||||
@ -567,20 +570,20 @@ class DateParser:
|
|||||||
qual = Date.QUAL_NONE
|
qual = Date.QUAL_NONE
|
||||||
cal = Date.CAL_GREGORIAN
|
cal = Date.CAL_GREGORIAN
|
||||||
|
|
||||||
(text,cal) = self.match_calendar(text,cal)
|
(text, cal) = self.match_calendar(text, cal)
|
||||||
(text,qual) = self.match_quality(text,qual)
|
(text, qual) = self.match_quality(text, qual)
|
||||||
|
|
||||||
if self.match_span(text,cal,qual,date):
|
if self.match_span(text, cal, qual, date):
|
||||||
return
|
return
|
||||||
if self.match_range(text,cal,qual,date):
|
if self.match_range(text, cal, qual, date):
|
||||||
return
|
return
|
||||||
|
|
||||||
(text,bc) = self.match_bce(text)
|
(text,bc) = self.match_bce(text)
|
||||||
if self.match_modifier(text,cal,qual,bc,date):
|
if self.match_modifier(text, cal, qual, bc, date):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subdate = self._parse_subdate(text,self.parser[cal])
|
subdate = self._parse_subdate(text, self.parser[cal])
|
||||||
if subdate == Date.EMPTY and text != "":
|
if subdate == Date.EMPTY and text != "":
|
||||||
date.set_as_text(text)
|
date.set_as_text(text)
|
||||||
return
|
return
|
||||||
@ -589,20 +592,20 @@ class DateParser:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if bc:
|
if bc:
|
||||||
date.set(qual,Date.MOD_NONE,cal,self.invert_year(subdate))
|
date.set(qual, Date.MOD_NONE, cal, self.invert_year(subdate))
|
||||||
else:
|
else:
|
||||||
date.set(qual,Date.MOD_NONE,cal,subdate)
|
date.set(qual, Date.MOD_NONE, cal, subdate)
|
||||||
|
|
||||||
def invert_year(self,subdate):
|
def invert_year(self, subdate):
|
||||||
return (subdate[0],subdate[1],-subdate[2],subdate[3])
|
return (subdate[0] ,subdate[1], -subdate[2], subdate[3])
|
||||||
|
|
||||||
def parse(self,text):
|
def parse(self, text):
|
||||||
"""
|
"""
|
||||||
Parses the text, returning a Date object.
|
Parses the text, returning a Date object.
|
||||||
"""
|
"""
|
||||||
new_date = Date()
|
new_date = Date()
|
||||||
try:
|
try:
|
||||||
self.set_date(new_date,text)
|
self.set_date(new_date, text)
|
||||||
except DateError:
|
except DateError:
|
||||||
new_date.set_as_text(text)
|
new_date.set_as_text(text)
|
||||||
return new_date
|
return new_date
|
||||||
|
@ -152,7 +152,6 @@ class EditEventRef(EditReference):
|
|||||||
self.track,
|
self.track,
|
||||||
self.db.readonly)
|
self.db.readonly)
|
||||||
|
|
||||||
|
|
||||||
def _create_tabbed_pages(self):
|
def _create_tabbed_pages(self):
|
||||||
"""
|
"""
|
||||||
Creates the notebook tabs and inserts them into the main
|
Creates the notebook tabs and inserts them into the main
|
||||||
|
@ -582,10 +582,12 @@ class EditPerson(EditPrimary):
|
|||||||
Save the data.
|
Save the data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
self.ok_button.set_sensitive(False)
|
||||||
if self.object_is_empty():
|
if self.object_is_empty():
|
||||||
ErrorDialog(_("Cannot save person"),
|
ErrorDialog(_("Cannot save person"),
|
||||||
_("No data exists for this person. Please "
|
_("No data exists for this person. Please "
|
||||||
"enter data or cancel the edit."))
|
"enter data or cancel the edit."))
|
||||||
|
self.ok_button.set_sensitive(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
self._check_for_unknown_gender()
|
self._check_for_unknown_gender()
|
||||||
|
@ -44,6 +44,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.signal_keys = []
|
self.signal_keys = []
|
||||||
self.get_from_handle = get_from_handle
|
self.get_from_handle = get_from_handle
|
||||||
|
self.ok_button = None
|
||||||
|
|
||||||
ManagedWindow.ManagedWindow.__init__(self, uistate, track, obj)
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, obj)
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
|||||||
self.empty_object().serialize()[1:]) == 0
|
self.empty_object().serialize()[1:]) == 0
|
||||||
|
|
||||||
def define_ok_button(self,button,function):
|
def define_ok_button(self,button,function):
|
||||||
|
self.ok_button = button
|
||||||
button.connect('clicked',function)
|
button.connect('clicked',function)
|
||||||
button.set_sensitive(not self.db.readonly)
|
button.set_sensitive(not self.db.readonly)
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# This is the src/data level Makefile for gramps
|
# This is the src/data level Makefile for gramps
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
SUBDIRS = templates
|
|
||||||
pkgdatadir = $(datadir)/@PACKAGE@/data
|
pkgdatadir = $(datadir)/@PACKAGE@/data
|
||||||
|
|
||||||
dist_pkgdata_DATA = \
|
dist_pkgdata_DATA = \
|
||||||
|
@ -1113,7 +1113,7 @@ class ODFDoc(BaseDoc.BaseDoc):
|
|||||||
self.cntnt.write('<text:span text:style-name="F%s">' % para_name)
|
self.cntnt.write('<text:span text:style-name="F%s">' % para_name)
|
||||||
text = text.replace('\t','<text:tab-stop/>')
|
text = text.replace('\t','<text:tab-stop/>')
|
||||||
text = text.replace('\n','<text:line-break/>')
|
text = text.replace('\n','<text:line-break/>')
|
||||||
self.cntnt.write(text)
|
self.cntnt.write(escape(text))
|
||||||
self.cntnt.write('</text:span>')
|
self.cntnt.write('</text:span>')
|
||||||
self.cntnt.write('</text:p>\n')
|
self.cntnt.write('</text:p>\n')
|
||||||
self.cntnt.write('</draw:rect>\n')
|
self.cntnt.write('</draw:rect>\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user