From b68e2d727f4beebe873bb951bcc897aaa1103a12 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 5 Apr 2007 02:46:56 +0000 Subject: [PATCH] 2007-04-04 Don Allingham * 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 --- ChangeLog | 9 +++ src/DateEdit.py | 2 +- src/DateHandler/_DateParser.py | 111 +++++++++++++++++---------------- src/Editors/_EditEventRef.py | 1 - src/Editors/_EditPerson.py | 2 + src/Editors/_EditPrimary.py | 2 + src/data/Makefile.am | 1 - src/docgen/ODFDoc.py | 2 +- 8 files changed, 72 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e7fde36f..0ddd88188 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-04-04 Don Allingham + * 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 * help/nl/nl.po: correct keyword error NarrativeWeb diff --git a/src/DateEdit.py b/src/DateEdit.py index 8d515f97c..d0345350b 100644 --- a/src/DateEdit.py +++ b/src/DateEdit.py @@ -1,4 +1,4 @@ -# +s# # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2002-2006 Donald N. Allingham diff --git a/src/DateHandler/_DateParser.py b/src/DateHandler/_DateParser.py index 2d3c41bac..12e7b6a77 100644 --- a/src/DateHandler/_DateParser.py +++ b/src/DateHandler/_DateParser.py @@ -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 diff --git a/src/Editors/_EditEventRef.py b/src/Editors/_EditEventRef.py index 10399ee8b..740fdb80b 100644 --- a/src/Editors/_EditEventRef.py +++ b/src/Editors/_EditEventRef.py @@ -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 diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index d815fb5d3..0d662d50f 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -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() diff --git a/src/Editors/_EditPrimary.py b/src/Editors/_EditPrimary.py index 1aca82b82..464b724e9 100644 --- a/src/Editors/_EditPrimary.py +++ b/src/Editors/_EditPrimary.py @@ -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) diff --git a/src/data/Makefile.am b/src/data/Makefile.am index b1aa964cc..b7b1c48d1 100644 --- a/src/data/Makefile.am +++ b/src/data/Makefile.am @@ -1,7 +1,6 @@ # This is the src/data level Makefile for gramps # $Id$ # -SUBDIRS = templates pkgdatadir = $(datadir)/@PACKAGE@/data dist_pkgdata_DATA = \ diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index 565605ce7..048f7596b 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -1113,7 +1113,7 @@ class ODFDoc(BaseDoc.BaseDoc): self.cntnt.write('' % para_name) text = text.replace('\t','') text = text.replace('\n','') - self.cntnt.write(text) + self.cntnt.write(escape(text)) self.cntnt.write('') self.cntnt.write('\n') self.cntnt.write('\n')