From 66523b5c7c19373bdfefc3e7c0efa16ff943590c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 2 Aug 2005 21:53:27 +0000 Subject: [PATCH] date fixes svn: r5004 --- gramps2/ChangeLog | 3 ++- gramps2/src/DateParser.py | 20 ++++++++++++++++---- gramps2/src/plugins/NavWebPage.py | 26 ++++++++++++++++---------- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index cf008d24c..0352642da 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,6 @@ 2005-08-02 Don Allingham + * src/DateHandler.py: handle <> for about + * src/plugins/NavWebPage.py: cleanup * src/EditPerson.py: call new PersonEventEditor * src/Marriage.py: call new FamilyEventEditor * src/EditSource.py: call the correct EventEditor @@ -14,7 +16,6 @@ event types * src/ReadGedcom: use commit_event to handle personal vs. family event types - 2005-08-02 Martin Hawlisch * src/Bookmarks.py (edit): Dont crash if bookmark list contains diff --git a/gramps2/src/DateParser.py b/gramps2/src/DateParser.py index 134d150de..7ed9deaaa 100644 --- a/gramps2/src/DateParser.py +++ b/gramps2/src/DateParser.py @@ -137,9 +137,9 @@ class DateParser: } french_to_int = { - u'vend\xc3\xa9miaire' : 1, 'brumaire' : 2, + u'vend\xc3\xa9miaire' : 1, 'brumaire' : 2, 'frimaire' : 3, u'niv\xc3\xb4se ': 4, - u'pluvi\xc3\xb4se' : 5, u'vent\xc3\xb4se' : 6, + 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, @@ -239,6 +239,7 @@ class DateParser: self._mod_str = '(' + '|'.join( [ key.replace('.','\.') for key in self.modifier_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() @@ -263,6 +264,7 @@ class DateParser: re.IGNORECASE) self._modifier = re.compile('%s\s+(.*)' % self._mod_str, re.IGNORECASE) + self._abt2 = re.compile('<(.*)>',re.IGNORECASE) self._text = re.compile('%s\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?' % self._mon_str, re.IGNORECASE) self._text2 = re.compile('(\d+)?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str, @@ -527,8 +529,18 @@ class DateParser: date.set(qual,mod,cal,self.invert_year(start)) else: date.set(qual,mod,cal,start) - return 1 - return 0 + return True + match = self._abt2.match(text) + if match: + grps = match.groups() + start = self._parse_subdate(grps[0]) + mod = Date.MOD_ABOUT + if bc: + date.set(qual,mod,cal,self.invert_year(start)) + else: + date.set(qual,mod,cal,start) + return True + return False def set_date(self,date,text): """ diff --git a/gramps2/src/plugins/NavWebPage.py b/gramps2/src/plugins/NavWebPage.py index 48891370c..7d3abb68f 100644 --- a/gramps2/src/plugins/NavWebPage.py +++ b/gramps2/src/plugins/NavWebPage.py @@ -157,17 +157,17 @@ class BasePage: return (real_path,thumb_path) def create_file(self,name): + self.cur_name = self.build_name("",name) if self.archive: self.string_io = StringIO() of = codecs.EncodedFile(self.string_io,'utf-8',self.encoding) - self.cur_name = name + "." + self.ext else: - page_name = os.path.join(self.html_dir,name + "." + self.ext) + page_name = os.path.join(self.html_dir,self.cur_name) of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding) return of def link_path(self,name,path): - base = name + "." + self.ext + base = self.build_name("",name) if self.levels == 2: dirpath = os.path.join(path,name[0],name[1],base) else: @@ -186,7 +186,7 @@ class BasePage: dirname = os.path.join(self.html_dir,path,name[0],name[1]) if not os.path.isdir(dirname): os.makedirs(dirname) - page_name = os.path.join(dirname,name + "." + self.ext) + page_name = self.build_name(dirname,name) of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding) return of @@ -414,6 +414,12 @@ class BasePage: else: return "%s/%s" % (dirroot,handle[0]) + def build_name(self,path,base): + if path: + return path + "/" + base + "." + self.ext + else: + return base + "." + self.ext + def person_link(self,of,path,name,gid=""): if self.levels == 1: path = "../../" + path @@ -520,7 +526,7 @@ class IndividualListPage(BasePage): of.write(' ') of.write('') path = self.build_path(person.handle,"ppl",False) - self.person_link(of, path + "/" + person.handle + "." + self.ext, + self.person_link(of, self.build_name(path,person.handle), person.get_primary_name().get_first_name(), person.gramps_id) of.write('') @@ -566,7 +572,7 @@ class SurnamePage(BasePage): person = db.get_person_from_handle(person_handle) of.write('') path = self.build_path(person.handle,"ppl",False) - self.person_link(of, path + "/" + person.handle + "." + self.ext, + self.person_link(of, self.build_name(path,person.handle), person.get_primary_name().get_first_name(), person.gramps_id) of.write('') @@ -1392,7 +1398,7 @@ class IndividualPage(BasePage): if use_link: child_name = nameof(child, self.exclude_private) path = self.build_path(child_handle,"ppl",False) - self.person_link(of, path + "/" + child_handle + "." + self.ext, + self.person_link(of, self.build_name(path,child_handle), child_name, gid) else: of.write(nameof(child,self.exclude_private)) @@ -1406,7 +1412,7 @@ class IndividualPage(BasePage): val = person.gramps_id if use_link: path = self.build_path(handle,"ppl",False) - fname = path + "/" + handle + "." + self.ext + fname = self.build_name(path,handle) self.person_link(of, fname, nameof(person,self.exclude_private), val) else: @@ -1515,7 +1521,7 @@ class IndividualPage(BasePage): if use_link: spouse_name = nameof(spouse,self.exclude_private) path = self.build_path(spouse.handle,"ppl",False) - fname = path + "/" + spouse.handle + "." + self.ext + fname = self.build_name(path,spouse.handle) self.person_link(of, fname, spouse_name, gid) else: of.write(name) @@ -1555,7 +1561,7 @@ class IndividualPage(BasePage): if person_link: person_name = nameof(person,self.exclude_private) path = self.build_path(person.handle,"ppl",False) - fname = path + "/" + person.handle + "." + self.ext + fname = self.build_name(path,person.handle) self.person_link(of, fname, person_name) else: of.write(nameof(person,self.exclude_private))