Update
svn: r4550
This commit is contained in:
parent
2a77676b36
commit
ed5c7adc82
@ -254,6 +254,7 @@ class GedcomParser:
|
||||
self.dp = GedcomDateParser()
|
||||
self.db = dbase
|
||||
self.person = None
|
||||
self.inline_srcs = {}
|
||||
self.media_map = {}
|
||||
self.fmap = {}
|
||||
self.smap = {}
|
||||
@ -262,7 +263,7 @@ class GedcomParser:
|
||||
self.refn = {}
|
||||
self.added = {}
|
||||
self.gedmap = GedcomInfoDB()
|
||||
self.gedsource = None
|
||||
self.gedsource = self.gedmap.get_from_source_tag('GEDCOM 5.5')
|
||||
self.def_src = RelLib.Source()
|
||||
fname = os.path.basename(filename).split('\\')[-1]
|
||||
self.def_src.set_title(_("Import from %s") % unicode(fname))
|
||||
@ -493,6 +494,16 @@ class GedcomParser:
|
||||
if self.window:
|
||||
self.update(self.families_obj,str(self.fam_count))
|
||||
self.update(self.people_obj,str(self.indi_count))
|
||||
|
||||
for value in self.inline_srcs.keys():
|
||||
title,note = value
|
||||
handle = self.inline_srcs[value]
|
||||
src = RelLib.Source()
|
||||
src.set_handle(handle)
|
||||
src.set_title(title)
|
||||
if note:
|
||||
src.set_note(note)
|
||||
self.db.add_source(src,self.trans)
|
||||
|
||||
self.break_note_links()
|
||||
t = time.time() - t
|
||||
@ -1944,16 +1955,15 @@ class GedcomParser:
|
||||
def handle_source(self,matches,level):
|
||||
source_ref = RelLib.SourceRef()
|
||||
if matches[2] and matches[2][0] != "@":
|
||||
self.localref = self.localref + 1
|
||||
ref = "gsr%d" % self.localref
|
||||
s = self.find_or_create_source(ref)
|
||||
source_ref.set_base_handle(s.get_handle())
|
||||
s.set_title('Imported Source #%d' % self.localref)
|
||||
s.set_note(matches[2] + self.parse_continue_data(level))
|
||||
title = matches[2]
|
||||
note = self.parse_continue_data(level)
|
||||
handle = self.inline_srcs.get((title,note),Utils.create_id())
|
||||
self.inline_srcs[(title,note)] = handle
|
||||
self.ignore_sub_junk(level+1)
|
||||
else:
|
||||
source_ref.set_base_handle(self.find_or_create_source(matches[2][1:-1]).get_handle())
|
||||
handle = self.find_or_create_source(matches[2][1:-1]).get_handle()
|
||||
self.parse_source_reference(source_ref,level)
|
||||
source_ref.set_base_handle(handle)
|
||||
return source_ref
|
||||
|
||||
def resolve_refns(self):
|
||||
|
@ -325,9 +325,8 @@ class GrampsParser:
|
||||
self.media_file_map = {}
|
||||
|
||||
self.callback = callback
|
||||
self.entries = 0
|
||||
self.count = 0
|
||||
self.increment = 100
|
||||
self.increment = 500
|
||||
self.event = None
|
||||
self.name = None
|
||||
self.tempDefault = None
|
||||
@ -362,7 +361,7 @@ class GrampsParser:
|
||||
"comment" : (None, self.stop_comment),
|
||||
"created" : (self.start_created, None),
|
||||
"ref" : (None, self.stop_ref),
|
||||
"database" : (None, None),
|
||||
"database" : (None, self.stop_database),
|
||||
"phone" : (None, self.stop_phone),
|
||||
"date" : (None, self.stop_date),
|
||||
"cause" : (None, self.stop_cause),
|
||||
@ -617,10 +616,9 @@ class GrampsParser:
|
||||
title = attrs['id']
|
||||
self.placeobj.set_title(title)
|
||||
self.locations = 0
|
||||
if self.num_places > 0:
|
||||
if self.callback != None and self.count % self.increment == 0:
|
||||
self.callback(float(self.count)/float(self.entries))
|
||||
self.count = self.count + 1
|
||||
if self.callback != None and self.count % self.increment == 0:
|
||||
self.callback(True)
|
||||
self.count += 1
|
||||
|
||||
def start_location(self,attrs):
|
||||
"""Bypass the function calls for this one, since it appears to
|
||||
@ -649,6 +647,7 @@ class GrampsParser:
|
||||
|
||||
def start_witness(self,attrs):
|
||||
self.in_witness = 1
|
||||
self.witness_comment = ""
|
||||
if attrs.has_key('hlink'):
|
||||
self.witness = RelLib.Witness(RelLib.Event.ID,attrs['hlink'])
|
||||
elif attrs.has_key('ref'):
|
||||
@ -716,6 +715,8 @@ class GrampsParser:
|
||||
self.db.bookmarks.append(person.get_handle())
|
||||
|
||||
def start_person(self,attrs):
|
||||
if self.callback != None and self.count % self.increment == 0:
|
||||
self.callback(True)
|
||||
new_id = self.map_gid(attrs['id'])
|
||||
try:
|
||||
self.person = self.db.find_person_from_handle(attrs['handle'],self.trans)
|
||||
@ -778,7 +779,7 @@ class GrampsParser:
|
||||
|
||||
def start_family(self,attrs):
|
||||
if self.callback != None and self.count % self.increment == 0:
|
||||
self.callback(float(self.count)/float(self.entries))
|
||||
self.callback(True)
|
||||
self.count = self.count + 1
|
||||
handle = self.map_fid(attrs["id"])
|
||||
try:
|
||||
@ -941,6 +942,10 @@ class GrampsParser:
|
||||
def stop_people(self,*tag):
|
||||
pass
|
||||
|
||||
def stop_database(self,*tag):
|
||||
if self.callback:
|
||||
self.callback(False)
|
||||
|
||||
def stop_object(self,*tag):
|
||||
self.db.commit_media_object(self.object,self.trans,self.change)
|
||||
self.object = None
|
||||
@ -1054,7 +1059,6 @@ class GrampsParser:
|
||||
bc = -1
|
||||
val = val[1:]
|
||||
start = val.split('-')
|
||||
|
||||
try:
|
||||
y = int(start[0])*bc
|
||||
except:
|
||||
@ -1071,7 +1075,7 @@ class GrampsParser:
|
||||
d = 0
|
||||
|
||||
if attrs.has_key("cformat"):
|
||||
cal = Date.Date.calendar_names.index(attrs['calendar'])
|
||||
cal = Date.Date.calendar_names.index(attrs['cformat'])
|
||||
else:
|
||||
cal = Date.CAL_GREGORIAN
|
||||
|
||||
@ -1113,8 +1117,6 @@ class GrampsParser:
|
||||
self.num_places = int(attrs['places'])
|
||||
else:
|
||||
self.num_places = 0
|
||||
self.entries = int(attrs["people"]) + int(attrs["families"]) + \
|
||||
self.num_places + self.num_srcs
|
||||
|
||||
def start_pos(self,attrs):
|
||||
self.person.position = (int(attrs["x"]), int(attrs["y"]))
|
||||
|
@ -34,6 +34,7 @@ from gettext import gettext as _
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import locale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -48,13 +49,20 @@ import DateHandler
|
||||
# Confidence levels
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
CONF_VERY_HIGH = 4
|
||||
CONF_HIGH = 3
|
||||
CONF_NORMAL = 2
|
||||
CONF_LOW = 1
|
||||
CONF_VERY_LOW = 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Localized constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_date_format = locale.nl_langinfo(locale.D_T_FMT)
|
||||
_codeset = locale.nl_langinfo(locale.CODESET)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Base classes
|
||||
@ -231,7 +239,9 @@ class PrimaryObject(BaseObject):
|
||||
|
||||
"""
|
||||
if self.change:
|
||||
return time.asctime(time.localtime(self.change))
|
||||
return unicode(time.strftime(_date_format,
|
||||
time.localtime(self.change)),
|
||||
_codeset)
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
@ -908,6 +908,11 @@ def married_str(database,person,spouse,event,endnotes=None,
|
||||
def married_rel_str(database,person,family,is_first=True):
|
||||
spouse_handle = find_spouse(person,family)
|
||||
spouse = database.get_person_from_handle(spouse_handle)
|
||||
|
||||
# not all families have a spouse.
|
||||
if not spouse_handle or not spouse:
|
||||
return u""
|
||||
|
||||
spouse_name = _nd.display(spouse)
|
||||
|
||||
if is_first:
|
||||
@ -1796,6 +1801,6 @@ def old_calc_age(database,person):
|
||||
age = age - 1
|
||||
units = 2 # month
|
||||
if age == 0:
|
||||
age = death.get-day() + 31 - birth.get_day() # calc age in days
|
||||
age = death.get_day() + 31 - birth.get_day() # calc age in days
|
||||
units = 3 # day
|
||||
return (age,units)
|
||||
|
Loading…
Reference in New Issue
Block a user