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>
* 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
@ -15,7 +17,6 @@
* src/ReadGedcom: use commit_event to handle personal vs. family
event types
2005-08-02 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/Bookmarks.py (edit): Dont crash if bookmark list contains
nonexisting person.

View File

@ -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):
"""

View File

@ -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('&nbsp')
of.write('</td><td class="data">')
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('</td><td class="field">')
@ -566,7 +572,7 @@ class SurnamePage(BasePage):
person = db.get_person_from_handle(person_handle)
of.write('<tr><td class="category">')
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('</td><td class="field">')
@ -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))