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