date fixes

svn: r5004
This commit is contained in:
Don Allingham
2005-08-02 21:53:27 +00:00
parent 32b884fc5d
commit 66523b5c7c
3 changed files with 34 additions and 15 deletions

View File

@@ -1,4 +1,6 @@
2005-08-02 Don Allingham <don@gramps-project.org> 2005-08-02 Don Allingham <don@gramps-project.org>
* src/DateHandler.py: handle <> for about
* src/plugins/NavWebPage.py: cleanup
* src/EditPerson.py: call new PersonEventEditor * src/EditPerson.py: call new PersonEventEditor
* src/Marriage.py: call new FamilyEventEditor * src/Marriage.py: call new FamilyEventEditor
* src/EditSource.py: call the correct EventEditor * src/EditSource.py: call the correct EventEditor
@@ -15,7 +17,6 @@
* src/ReadGedcom: use commit_event to handle personal vs. family * src/ReadGedcom: use commit_event to handle personal vs. family
event types event types
2005-08-02 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-08-02 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/Bookmarks.py (edit): Dont crash if bookmark list contains * src/Bookmarks.py (edit): Dont crash if bookmark list contains
nonexisting person. nonexisting person.

View File

@@ -239,6 +239,7 @@ class DateParser:
self._mod_str = '(' + '|'.join( self._mod_str = '(' + '|'.join(
[ key.replace('.','\.') for key in self.modifier_to_int.keys() ] [ key.replace('.','\.') for key in self.modifier_to_int.keys() ]
) + ')' ) + ')'
# Need to reverse-sort the keys, so that April matches before Apr does. # Need to reverse-sort the keys, so that April matches before Apr does.
# Otherwise, 'april 2000' would be matched as 'apr' + garbage ('il 2000') # Otherwise, 'april 2000' would be matched as 'apr' + garbage ('il 2000')
_month_keys = self.month_to_int.keys() _month_keys = self.month_to_int.keys()
@@ -263,6 +264,7 @@ class DateParser:
re.IGNORECASE) re.IGNORECASE)
self._modifier = re.compile('%s\s+(.*)' % self._mod_str, self._modifier = re.compile('%s\s+(.*)' % self._mod_str,
re.IGNORECASE) re.IGNORECASE)
self._abt2 = re.compile('<(.*)>',re.IGNORECASE)
self._text = re.compile('%s\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?' % self._mon_str, self._text = re.compile('%s\s+(\d+)?\s*,?\s*((\d+)(/\d+)?)?' % self._mon_str,
re.IGNORECASE) re.IGNORECASE)
self._text2 = re.compile('(\d+)?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str, 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)) date.set(qual,mod,cal,self.invert_year(start))
else: else:
date.set(qual,mod,cal,start) date.set(qual,mod,cal,start)
return 1 return True
return 0 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): def set_date(self,date,text):
""" """

View File

@@ -157,17 +157,17 @@ class BasePage:
return (real_path,thumb_path) return (real_path,thumb_path)
def create_file(self,name): def create_file(self,name):
self.cur_name = self.build_name("",name)
if self.archive: if self.archive:
self.string_io = StringIO() self.string_io = StringIO()
of = codecs.EncodedFile(self.string_io,'utf-8',self.encoding) of = codecs.EncodedFile(self.string_io,'utf-8',self.encoding)
self.cur_name = name + "." + self.ext
else: 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) of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding)
return of return of
def link_path(self,name,path): def link_path(self,name,path):
base = name + "." + self.ext base = self.build_name("",name)
if self.levels == 2: if self.levels == 2:
dirpath = os.path.join(path,name[0],name[1],base) dirpath = os.path.join(path,name[0],name[1],base)
else: else:
@@ -186,7 +186,7 @@ class BasePage:
dirname = os.path.join(self.html_dir,path,name[0],name[1]) dirname = os.path.join(self.html_dir,path,name[0],name[1])
if not os.path.isdir(dirname): if not os.path.isdir(dirname):
os.makedirs(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) of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding)
return of return of
@@ -414,6 +414,12 @@ class BasePage:
else: else:
return "%s/%s" % (dirroot,handle[0]) 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=""): def person_link(self,of,path,name,gid=""):
if self.levels == 1: if self.levels == 1:
path = "../../" + path path = "../../" + path
@@ -520,7 +526,7 @@ class IndividualListPage(BasePage):
of.write('&nbsp') of.write('&nbsp')
of.write('</td><td class="data">') of.write('</td><td class="data">')
path = self.build_path(person.handle,"ppl",False) 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.get_primary_name().get_first_name(),
person.gramps_id) person.gramps_id)
of.write('</td><td class="field">') of.write('</td><td class="field">')
@@ -566,7 +572,7 @@ class SurnamePage(BasePage):
person = db.get_person_from_handle(person_handle) person = db.get_person_from_handle(person_handle)
of.write('<tr><td class="category">') of.write('<tr><td class="category">')
path = self.build_path(person.handle,"ppl",False) 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.get_primary_name().get_first_name(),
person.gramps_id) person.gramps_id)
of.write('</td><td class="field">') of.write('</td><td class="field">')
@@ -1392,7 +1398,7 @@ class IndividualPage(BasePage):
if use_link: if use_link:
child_name = nameof(child, self.exclude_private) child_name = nameof(child, self.exclude_private)
path = self.build_path(child_handle,"ppl",False) 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) child_name, gid)
else: else:
of.write(nameof(child,self.exclude_private)) of.write(nameof(child,self.exclude_private))
@@ -1406,7 +1412,7 @@ class IndividualPage(BasePage):
val = person.gramps_id val = person.gramps_id
if use_link: if use_link:
path = self.build_path(handle,"ppl",False) 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), self.person_link(of, fname, nameof(person,self.exclude_private),
val) val)
else: else:
@@ -1515,7 +1521,7 @@ class IndividualPage(BasePage):
if use_link: if use_link:
spouse_name = nameof(spouse,self.exclude_private) spouse_name = nameof(spouse,self.exclude_private)
path = self.build_path(spouse.handle,"ppl",False) 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) self.person_link(of, fname, spouse_name, gid)
else: else:
of.write(name) of.write(name)
@@ -1555,7 +1561,7 @@ class IndividualPage(BasePage):
if person_link: if person_link:
person_name = nameof(person,self.exclude_private) person_name = nameof(person,self.exclude_private)
path = self.build_path(person.handle,"ppl",False) 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) self.person_link(of, fname, person_name)
else: else:
of.write(nameof(person,self.exclude_private)) of.write(nameof(person,self.exclude_private))