pylint improvements
svn: r18846
This commit is contained in:
parent
da16f93a45
commit
3d071f8b33
@ -89,7 +89,7 @@ all lines until the next level 2 token is found (in this case, skipping the
|
|||||||
# standard python modules
|
# standard python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os, sys
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import codecs
|
import codecs
|
||||||
@ -335,7 +335,7 @@ TOKENS = {
|
|||||||
"TEXT" : TOKEN_TEXT, "TIME" : TOKEN_TIME,
|
"TEXT" : TOKEN_TEXT, "TIME" : TOKEN_TIME,
|
||||||
"TITL" : TOKEN_TITL, "TITLE" : TOKEN_TITL,
|
"TITL" : TOKEN_TITL, "TITLE" : TOKEN_TITL,
|
||||||
"_TODO" : TOKEN__TODO, "TRLR" : TOKEN_TRLR,
|
"_TODO" : TOKEN__TODO, "TRLR" : TOKEN_TRLR,
|
||||||
"TRAILER" : TOKEN_TRLR, "TYPE" : TOKEN_TYPE,
|
"TYPE" : TOKEN_TYPE,
|
||||||
"_UID" : TOKEN__UID, "VERS" : TOKEN_VERS,
|
"_UID" : TOKEN__UID, "VERS" : TOKEN_VERS,
|
||||||
"VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE,
|
"VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE,
|
||||||
"_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN,
|
"_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN,
|
||||||
@ -350,7 +350,7 @@ TOKENS = {
|
|||||||
"_LEVEL" : TOKEN_IGNORE,"_PUBLISHER" : TOKEN_IGNORE,
|
"_LEVEL" : TOKEN_IGNORE,"_PUBLISHER" : TOKEN_IGNORE,
|
||||||
"MAP" : TOKEN_MAP, "LATI" : TOKEN_LATI,
|
"MAP" : TOKEN_MAP, "LATI" : TOKEN_LATI,
|
||||||
"LONG" : TOKEN_LONG, "_ITALIC" : TOKEN_IGNORE,
|
"LONG" : TOKEN_LONG, "_ITALIC" : TOKEN_IGNORE,
|
||||||
"_PAREN" : TOKEN_IGNORE,"_PLACE" : TOKEN_IGNORE,
|
"_PLACE" : TOKEN_IGNORE,
|
||||||
"FACT" : TOKEN_FACT, "EMAIL" : TOKEN_EMAIL,
|
"FACT" : TOKEN_FACT, "EMAIL" : TOKEN_EMAIL,
|
||||||
"EMAI" : TOKEN_EMAIL, "WWW" : TOKEN_WWW,
|
"EMAI" : TOKEN_EMAIL, "WWW" : TOKEN_WWW,
|
||||||
"_URL" : TOKEN_URL, "URL" : TOKEN_URL,
|
"_URL" : TOKEN_URL, "URL" : TOKEN_URL,
|
||||||
@ -456,7 +456,7 @@ SEX_MAP = {
|
|||||||
'M' : gen.lib.Person.MALE,
|
'M' : gen.lib.Person.MALE,
|
||||||
}
|
}
|
||||||
|
|
||||||
familyConstantEvents = {
|
FAMILYCONSTANTEVENTS = {
|
||||||
gen.lib.EventType.ANNULMENT : "ANUL",
|
gen.lib.EventType.ANNULMENT : "ANUL",
|
||||||
gen.lib.EventType.DIV_FILING : "DIVF",
|
gen.lib.EventType.DIV_FILING : "DIVF",
|
||||||
gen.lib.EventType.DIVORCE : "DIV",
|
gen.lib.EventType.DIVORCE : "DIV",
|
||||||
@ -469,7 +469,7 @@ familyConstantEvents = {
|
|||||||
gen.lib.EventType.MARRIAGE : "MARR"
|
gen.lib.EventType.MARRIAGE : "MARR"
|
||||||
}
|
}
|
||||||
|
|
||||||
personalConstantEvents = {
|
PERSONALCONSTANTEVENTS = {
|
||||||
gen.lib.EventType.ADOPT : "ADOP",
|
gen.lib.EventType.ADOPT : "ADOP",
|
||||||
gen.lib.EventType.ADULT_CHRISTEN : "CHRA",
|
gen.lib.EventType.ADULT_CHRISTEN : "CHRA",
|
||||||
gen.lib.EventType.BIRTH : "BIRT",
|
gen.lib.EventType.BIRTH : "BIRT",
|
||||||
@ -507,11 +507,11 @@ personalConstantEvents = {
|
|||||||
gen.lib.EventType.WILL : "WILL",
|
gen.lib.EventType.WILL : "WILL",
|
||||||
}
|
}
|
||||||
|
|
||||||
familyConstantAttributes = {
|
FAMILYCONSTANTATTRIBUTES = {
|
||||||
gen.lib.AttributeType.NUM_CHILD : "NCHI",
|
gen.lib.AttributeType.NUM_CHILD : "NCHI",
|
||||||
}
|
}
|
||||||
|
|
||||||
personalConstantAttributes = {
|
PERSONALCONSTANTATTRIBUTES = {
|
||||||
gen.lib.AttributeType.CASTE : "CAST",
|
gen.lib.AttributeType.CASTE : "CAST",
|
||||||
gen.lib.AttributeType.DESCRIPTION : "DSCR",
|
gen.lib.AttributeType.DESCRIPTION : "DSCR",
|
||||||
gen.lib.AttributeType.ID : "IDNO",
|
gen.lib.AttributeType.ID : "IDNO",
|
||||||
@ -525,7 +525,7 @@ personalConstantAttributes = {
|
|||||||
# Gedcom to int constants
|
# Gedcom to int constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
lds_status = {
|
LDS_STATUS = {
|
||||||
"BIC" : gen.lib.LdsOrd.STATUS_BIC,
|
"BIC" : gen.lib.LdsOrd.STATUS_BIC,
|
||||||
"CANCELED" : gen.lib.LdsOrd.STATUS_CANCELED,
|
"CANCELED" : gen.lib.LdsOrd.STATUS_CANCELED,
|
||||||
"CHILD" : gen.lib.LdsOrd.STATUS_CHILD,
|
"CHILD" : gen.lib.LdsOrd.STATUS_CHILD,
|
||||||
@ -543,7 +543,7 @@ lds_status = {
|
|||||||
|
|
||||||
# table for skipping illegal control chars in GEDCOM import
|
# table for skipping illegal control chars in GEDCOM import
|
||||||
# Only 09, 0A, 0D are allowed.
|
# Only 09, 0A, 0D are allowed.
|
||||||
strip_dict = dict.fromkeys(range(9)+range(11,13)+range(14, 32))
|
STRIP_DICT = dict.fromkeys(range(9)+range(11, 13)+range(14, 32))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -551,16 +551,16 @@ strip_dict = dict.fromkeys(range(9)+range(11,13)+range(14, 32))
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
GED_TO_GRAMPS_EVENT = {}
|
GED_TO_GRAMPS_EVENT = {}
|
||||||
for __val, __key in personalConstantEvents.iteritems():
|
for __val, __key in PERSONALCONSTANTEVENTS.iteritems():
|
||||||
if __key != "":
|
if __key != "":
|
||||||
GED_TO_GRAMPS_EVENT[__key] = __val
|
GED_TO_GRAMPS_EVENT[__key] = __val
|
||||||
|
|
||||||
for __val, __key in familyConstantEvents.iteritems():
|
for __val, __key in FAMILYCONSTANTEVENTS.iteritems():
|
||||||
if __key != "":
|
if __key != "":
|
||||||
GED_TO_GRAMPS_EVENT[__key] = __val
|
GED_TO_GRAMPS_EVENT[__key] = __val
|
||||||
|
|
||||||
GED_TO_GRAMPS_ATTR = {}
|
GED_TO_GRAMPS_ATTR = {}
|
||||||
for __val, __key in personalConstantAttributes.iteritems():
|
for __val, __key in PERSONALCONSTANTATTRIBUTES.iteritems():
|
||||||
if __key != "":
|
if __key != "":
|
||||||
GED_TO_GRAMPS_ATTR[__key] = __val
|
GED_TO_GRAMPS_ATTR[__key] = __val
|
||||||
|
|
||||||
@ -894,7 +894,8 @@ class GedLine(object):
|
|||||||
Converts the data field to a gen.lib token indicating the gender
|
Converts the data field to a gen.lib token indicating the gender
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.data = SEX_MAP.get(self.data.strip()[0], gen.lib.Person.UNKNOWN)
|
self.data = SEX_MAP.get(self.data.strip()[0],
|
||||||
|
gen.lib.Person.UNKNOWN)
|
||||||
except:
|
except:
|
||||||
self.data = gen.lib.Person.UNKNOWN
|
self.data = gen.lib.Person.UNKNOWN
|
||||||
|
|
||||||
@ -1070,13 +1071,13 @@ class GedcomInfoDB(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
filepath = os.path.join(const.DATA_DIR,"gedcom.xml")
|
filepath = os.path.join(const.DATA_DIR,"gedcom.xml")
|
||||||
f = open(filepath.encode('iso8859-1'),"r")
|
ged_file = open(filepath.encode('iso8859-1'),"r")
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
parser = GedInfoParser(self)
|
parser = GedInfoParser(self)
|
||||||
parser.parse(f)
|
parser.parse(ged_file)
|
||||||
f.close()
|
ged_file.close()
|
||||||
|
|
||||||
def add_description(self, name, obj):
|
def add_description(self, name, obj):
|
||||||
self.map[name] = obj
|
self.map[name] = obj
|
||||||
@ -1105,10 +1106,10 @@ class GedInfoParser(object):
|
|||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.current = None
|
self.current = None
|
||||||
|
|
||||||
def parse(self,file):
|
def parse(self, ged_file):
|
||||||
p = ParserCreate()
|
p = ParserCreate()
|
||||||
p.StartElementHandler = self.startElement
|
p.StartElementHandler = self.startElement
|
||||||
p.ParseFile(file)
|
p.ParseFile(ged_file)
|
||||||
|
|
||||||
def startElement(self, tag, attrs):
|
def startElement(self, tag, attrs):
|
||||||
if tag == "target":
|
if tag == "target":
|
||||||
@ -1181,7 +1182,7 @@ class BaseReader(object):
|
|||||||
line = unicode(self.ifile.readline(),
|
line = unicode(self.ifile.readline(),
|
||||||
encoding=self.enc,
|
encoding=self.enc,
|
||||||
errors='replace')
|
errors='replace')
|
||||||
return line.translate(strip_dict)
|
return line.translate(STRIP_DICT)
|
||||||
|
|
||||||
class UTF8Reader(BaseReader):
|
class UTF8Reader(BaseReader):
|
||||||
|
|
||||||
@ -1199,7 +1200,7 @@ class UTF8Reader(BaseReader):
|
|||||||
line = unicode(self.ifile.readline(),
|
line = unicode(self.ifile.readline(),
|
||||||
encoding=self.enc,
|
encoding=self.enc,
|
||||||
errors='replace')
|
errors='replace')
|
||||||
return line.translate(strip_dict)
|
return line.translate(STRIP_DICT)
|
||||||
|
|
||||||
class UTF16Reader(BaseReader):
|
class UTF16Reader(BaseReader):
|
||||||
|
|
||||||
@ -1495,12 +1496,38 @@ class CurrentState(object):
|
|||||||
"""
|
"""
|
||||||
self.name_cnt = 0
|
self.name_cnt = 0
|
||||||
self.person = person
|
self.person = person
|
||||||
|
self.family = None
|
||||||
self.level = level
|
self.level = level
|
||||||
self.event = event
|
self.event = event
|
||||||
self.event_ref = event_ref
|
self.event_ref = event_ref
|
||||||
self.source_ref = None
|
self.source_ref = None
|
||||||
|
self.citation = None
|
||||||
self.note = None
|
self.note = None
|
||||||
|
self.lds_ord = None
|
||||||
self.msg = ""
|
self.msg = ""
|
||||||
|
self.primary = False # _PRIM tag on an INDI.FAMC tag
|
||||||
|
self.filename = ""
|
||||||
|
self.title = ""
|
||||||
|
self.addr = None
|
||||||
|
self.res = None
|
||||||
|
self.source = None
|
||||||
|
self.ftype = None
|
||||||
|
self.pf = None # method for parsing places
|
||||||
|
self.location = None
|
||||||
|
self.place_fields = None # method for parsing places
|
||||||
|
self.ref = None # PersonRef
|
||||||
|
self.handle = None #
|
||||||
|
self.form = "" # Multimedia format
|
||||||
|
self.frel = None # Child relation to father
|
||||||
|
self.mrel = None
|
||||||
|
self.repo = None
|
||||||
|
self.attr = None
|
||||||
|
self.obj = None
|
||||||
|
self.name = ""
|
||||||
|
self.ignore = False
|
||||||
|
self.repo_ref = None
|
||||||
|
self.place = None
|
||||||
|
self.media = None
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""
|
"""
|
||||||
@ -1721,7 +1748,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
name.set_first_name(text.strip())
|
name.set_first_name(text.strip())
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def __init__(self, dbase, ifile, filename, callback, stage_one, default_source):
|
def __init__(self, dbase, ifile, filename, callback, stage_one,
|
||||||
|
default_source):
|
||||||
UpdateCallback.__init__(self, callback)
|
UpdateCallback.__init__(self, callback)
|
||||||
|
|
||||||
self.set_total(stage_one.get_line_count())
|
self.set_total(stage_one.get_line_count())
|
||||||
@ -2465,7 +2493,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.geddir = os.path.dirname(fullpath)
|
self.geddir = os.path.dirname(fullpath)
|
||||||
|
|
||||||
self.error_count = 0
|
self.error_count = 0
|
||||||
amap = personalConstantAttributes
|
amap = PERSONALCONSTANTATTRIBUTES
|
||||||
|
|
||||||
self.attrs = amap.values()
|
self.attrs = amap.values()
|
||||||
self.gedattr = dict([key, val] for val, key in amap.iteritems())
|
self.gedattr = dict([key, val] for val, key in amap.iteritems())
|
||||||
@ -2777,7 +2805,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
state.msg += message
|
state.msg += message
|
||||||
self.errors.append(message)
|
self.errors.append(message)
|
||||||
|
|
||||||
def __check_msgs(self, record_name, state, object, trans):
|
def __check_msgs(self, record_name, state, obj):
|
||||||
if state.msg == "":
|
if state.msg == "":
|
||||||
return
|
return
|
||||||
message = "Records not inported into " + record_name + ":\n\n" + \
|
message = "Records not inported into " + record_name + ":\n\n" + \
|
||||||
@ -2789,8 +2817,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
new_note.set_type(note_type)
|
new_note.set_type(note_type)
|
||||||
self.dbase.add_note(new_note, self.trans)
|
self.dbase.add_note(new_note, self.trans)
|
||||||
# If possible, attach the note to the relevant object
|
# If possible, attach the note to the relevant object
|
||||||
if object:
|
if obj:
|
||||||
object.add_note(new_note.get_handle())
|
obj.add_note(new_note.get_handle())
|
||||||
|
|
||||||
def _backup(self):
|
def _backup(self):
|
||||||
"""
|
"""
|
||||||
@ -2808,7 +2836,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
if line and line.token != TOKEN_TRLR:
|
if line and line.token != TOKEN_TRLR:
|
||||||
state = CurrentState()
|
state = CurrentState()
|
||||||
self.__not_recognized(line, 0, state)
|
self.__not_recognized(line, 0, state)
|
||||||
self.__check_msgs("TRLR (trailer)", state, None, self.trans)
|
self.__check_msgs("TRLR (trailer)", state, None)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -2863,7 +2891,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
rtype = gen.lib.RepositoryType()
|
rtype = gen.lib.RepositoryType()
|
||||||
rtype.set((gen.lib.RepositoryType.CUSTOM, 'GEDCOM data'))
|
rtype.set((gen.lib.RepositoryType.CUSTOM, 'GEDCOM data'))
|
||||||
repo.set_type(rtype)
|
repo.set_type(rtype)
|
||||||
self.__check_msgs(submitter_name, state, repo, self.trans)
|
self.__check_msgs(submitter_name, state, repo)
|
||||||
self.dbase.commit_repository(repo, self.trans, state.repo.change)
|
self.dbase.commit_repository(repo, self.trans, state.repo.change)
|
||||||
repo_ref = gen.lib.RepoRef()
|
repo_ref = gen.lib.RepoRef()
|
||||||
repo_ref.set_reference_handle(repo.handle)
|
repo_ref.set_reference_handle(repo.handle)
|
||||||
@ -2873,7 +2901,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.def_src.add_repo_reference(repo_ref)
|
self.def_src.add_repo_reference(repo_ref)
|
||||||
self.dbase.commit_source(self.def_src, self.trans)
|
self.dbase.commit_source(self.def_src, self.trans)
|
||||||
else:
|
else:
|
||||||
self.__check_msgs(submitter_name, state, None, self.trans)
|
self.__check_msgs(submitter_name, state, None)
|
||||||
|
|
||||||
|
|
||||||
def __parse_record(self):
|
def __parse_record(self):
|
||||||
@ -2909,7 +2937,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
state = CurrentState()
|
state = CurrentState()
|
||||||
self.__add_msg(_("Unknown tag"), line, state)
|
self.__add_msg(_("Unknown tag"), line, state)
|
||||||
self.__skip_subordinate_levels(1, state)
|
self.__skip_subordinate_levels(1, state)
|
||||||
self.__check_msgs("Top Level", state, None, self.trans)
|
self.__check_msgs("Top Level", state, None)
|
||||||
elif key in ("FAM", "FAMILY"):
|
elif key in ("FAM", "FAMILY"):
|
||||||
self.__parse_fam(line)
|
self.__parse_fam(line)
|
||||||
elif key in ("INDI", "INDIVIDUAL"):
|
elif key in ("INDI", "INDIVIDUAL"):
|
||||||
@ -2923,11 +2951,11 @@ class GedcomParser(UpdateCallback):
|
|||||||
elif key in ("SUBN"):
|
elif key in ("SUBN"):
|
||||||
state = CurrentState()
|
state = CurrentState()
|
||||||
self.__parse_submission(line, state)
|
self.__parse_submission(line, state)
|
||||||
self.__check_msgs("Top Level", state, None, self.trans)
|
self.__check_msgs("Top Level", state, None)
|
||||||
elif line.token in (TOKEN_SUBM, TOKEN_SUBN, TOKEN_IGNORE):
|
elif line.token in (TOKEN_SUBM, TOKEN_SUBN, TOKEN_IGNORE):
|
||||||
state = CurrentState()
|
state = CurrentState()
|
||||||
self.__skip_subordinate_levels(1, state)
|
self.__skip_subordinate_levels(1, state)
|
||||||
self.__check_msgs("Top Level", state, None, self.trans)
|
self.__check_msgs("Top Level", state, None)
|
||||||
elif key in ("SOUR", "SOURCE"):
|
elif key in ("SOUR", "SOURCE"):
|
||||||
self.__parse_source(line.token_text, 1)
|
self.__parse_source(line.token_text, 1)
|
||||||
elif (line.data.startswith("SOUR ") or
|
elif (line.data.startswith("SOUR ") or
|
||||||
@ -2948,7 +2976,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
else:
|
else:
|
||||||
state = CurrentState()
|
state = CurrentState()
|
||||||
self.__not_recognized(line, 1, state)
|
self.__not_recognized(line, 1, state)
|
||||||
self.__check_msgs("Top Level", state, None, self.trans)
|
self.__check_msgs("Top Level", state, None)
|
||||||
|
|
||||||
def __parse_level(self, state, __map, default):
|
def __parse_level(self, state, __map, default):
|
||||||
"""
|
"""
|
||||||
@ -3027,7 +3055,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.__add_default_source(person)
|
self.__add_default_source(person)
|
||||||
|
|
||||||
self.__check_msgs("INDI (individual) Gramps ID %s" %
|
self.__check_msgs("INDI (individual) Gramps ID %s" %
|
||||||
person.get_gramps_id(), state, person, self.trans)
|
person.get_gramps_id(), state, person)
|
||||||
# commit the person to the database
|
# commit the person to the database
|
||||||
self.dbase.commit_person(person, self.trans, state.person.change)
|
self.dbase.commit_person(person, self.trans, state.person.change)
|
||||||
|
|
||||||
@ -3071,8 +3099,10 @@ class GedcomParser(UpdateCallback):
|
|||||||
@param state: The current state
|
@param state: The current state
|
||||||
@type state: CurrentState
|
@type state: CurrentState
|
||||||
"""
|
"""
|
||||||
event_ref = self.__build_family_event_pair(state, gen.lib.EventType.CUSTOM,
|
event_ref = self.__build_family_event_pair(state,
|
||||||
self.event_parse_tbl, line.data)
|
gen.lib.EventType.CUSTOM,
|
||||||
|
self.event_parse_tbl,
|
||||||
|
line.data)
|
||||||
state.family.add_event_ref(event_ref)
|
state.family.add_event_ref(event_ref)
|
||||||
|
|
||||||
def __skip_record(self, line, state):
|
def __skip_record(self, line, state):
|
||||||
@ -3601,7 +3631,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
@param state: The current state
|
@param state: The current state
|
||||||
@type state: CurrentState
|
@type state: CurrentState
|
||||||
"""
|
"""
|
||||||
if state.name.get_suffix() == "" or state.name.get_suffix() == line.data:
|
if state.name.get_suffix() == "" or \
|
||||||
|
state.name.get_suffix() == line.data:
|
||||||
#suffix might be set before when parsing name string
|
#suffix might be set before when parsing name string
|
||||||
state.name.set_suffix(line.data)
|
state.name.set_suffix(line.data)
|
||||||
else:
|
else:
|
||||||
@ -3870,7 +3901,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
@param state: The current state
|
@param state: The current state
|
||||||
@type state: CurrentState
|
@type state: CurrentState
|
||||||
"""
|
"""
|
||||||
status = lds_status.get(line.data, gen.lib.LdsOrd.STATUS_NONE)
|
status = LDS_STATUS.get(line.data, gen.lib.LdsOrd.STATUS_NONE)
|
||||||
state.lds_ord.set_status(status)
|
state.lds_ord.set_status(status)
|
||||||
|
|
||||||
def __person_famc(self, line, state):
|
def __person_famc(self, line, state):
|
||||||
@ -4138,7 +4169,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.__add_default_source(family)
|
self.__add_default_source(family)
|
||||||
|
|
||||||
self.__check_msgs("FAM (family) Gramps ID %s" % family.get_gramps_id(),
|
self.__check_msgs("FAM (family) Gramps ID %s" % family.get_gramps_id(),
|
||||||
state, family, self.trans)
|
state, family)
|
||||||
# commit family to database
|
# commit family to database
|
||||||
self.dbase.commit_family(family, self.trans, family.change)
|
self.dbase.commit_family(family, self.trans, family.change)
|
||||||
|
|
||||||
@ -5336,7 +5367,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.__parse_level(state, self.source_func, self.__undefined)
|
self.__parse_level(state, self.source_func, self.__undefined)
|
||||||
self.__check_msgs("SOUR (source) Gramps ID %s" %
|
self.__check_msgs("SOUR (source) Gramps ID %s" %
|
||||||
state.source.get_gramps_id(),
|
state.source.get_gramps_id(),
|
||||||
state, state.source, self.trans)
|
state, state.source)
|
||||||
self.dbase.commit_source(state.source, self.trans, state.source.change)
|
self.dbase.commit_source(state.source, self.trans, state.source.change)
|
||||||
|
|
||||||
def __source_attr(self, line, state):
|
def __source_attr(self, line, state):
|
||||||
@ -5542,7 +5573,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.__add_default_source(media)
|
self.__add_default_source(media)
|
||||||
|
|
||||||
self.__check_msgs("OBJE (multi-media object) Gramps ID %s" %
|
self.__check_msgs("OBJE (multi-media object) Gramps ID %s" %
|
||||||
media.get_gramps_id(), state, media, self.trans)
|
media.get_gramps_id(), state, media)
|
||||||
# commit the person to the database
|
# commit the person to the database
|
||||||
self.dbase.commit_media_object(media, self.trans, media.change)
|
self.dbase.commit_media_object(media, self.trans, media.change)
|
||||||
|
|
||||||
@ -5714,7 +5745,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.__parse_level(state, self.repo_parse_tbl, self.__ignore)
|
self.__parse_level(state, self.repo_parse_tbl, self.__ignore)
|
||||||
|
|
||||||
self.__check_msgs("REPO (repository) Gramps ID %s" %
|
self.__check_msgs("REPO (repository) Gramps ID %s" %
|
||||||
repo.get_gramps_id(), state, repo, self.trans)
|
repo.get_gramps_id(), state, repo)
|
||||||
self.dbase.commit_repository(repo, self.trans, repo.change)
|
self.dbase.commit_repository(repo, self.trans, repo.change)
|
||||||
|
|
||||||
def __repo_name(self, line, state):
|
def __repo_name(self, line, state):
|
||||||
@ -5989,7 +6020,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
state = CurrentState(level=1)
|
state = CurrentState(level=1)
|
||||||
self.__parse_level(state, self.head_parse_tbl, self.__undefined)
|
self.__parse_level(state, self.head_parse_tbl, self.__undefined)
|
||||||
self.__check_msgs(_("Head (header)"), state, None, self.trans)
|
self.__check_msgs(_("Head (header)"), state, None)
|
||||||
|
|
||||||
def __header_sour(self, line, state):
|
def __header_sour(self, line, state):
|
||||||
"""
|
"""
|
||||||
@ -6005,7 +6036,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
# software, in case we do not get the name in the proper place
|
# software, in case we do not get the name in the proper place
|
||||||
self.genby = line.data
|
self.genby = line.data
|
||||||
if self.use_def_src:
|
if self.use_def_src:
|
||||||
self.def_src.set_data_item(_("Approved system identification"), "%s" % self.genby)
|
self.def_src.set_data_item(_("Approved system identification"),
|
||||||
|
"%s" % self.genby)
|
||||||
sub_state = CurrentState(level=state.level+1)
|
sub_state = CurrentState(level=state.level+1)
|
||||||
self.__parse_level(sub_state, self.header_sour_parse_tbl,
|
self.__parse_level(sub_state, self.header_sour_parse_tbl,
|
||||||
self.__undefined)
|
self.__undefined)
|
||||||
@ -6056,7 +6088,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
state.msg += sub_state.msg
|
state.msg += sub_state.msg
|
||||||
|
|
||||||
if self.use_def_src:
|
if self.use_def_src:
|
||||||
repo.set_name(_("Business that produced the product: %s") % line.data)
|
repo.set_name(_("Business that produced the product: %s") %
|
||||||
|
line.data)
|
||||||
rtype = gen.lib.RepositoryType()
|
rtype = gen.lib.RepositoryType()
|
||||||
rtype.set((gen.lib.RepositoryType.CUSTOM, 'GEDCOM data'))
|
rtype.set((gen.lib.RepositoryType.CUSTOM, 'GEDCOM data'))
|
||||||
repo.set_type(rtype)
|
repo.set_type(rtype)
|
||||||
@ -6229,7 +6262,8 @@ class GedcomParser(UpdateCallback):
|
|||||||
break
|
break
|
||||||
elif line.token == TOKEN_VERS:
|
elif line.token == TOKEN_VERS:
|
||||||
if line.data[0] != "5":
|
if line.data[0] != "5":
|
||||||
self.__add_msg(_("GEDCOM version not supported"), line, state)
|
self.__add_msg(_("GEDCOM version not supported"),
|
||||||
|
line, state)
|
||||||
if self.use_def_src:
|
if self.use_def_src:
|
||||||
self.def_src.set_data_item(_('GEDCOM version'), line.data)
|
self.def_src.set_data_item(_('GEDCOM version'), line.data)
|
||||||
elif line.token == TOKEN_FORM:
|
elif line.token == TOKEN_FORM:
|
||||||
@ -6272,20 +6306,22 @@ class GedcomParser(UpdateCallback):
|
|||||||
# Because there is a DATE tag, line.data is automatically converted to a
|
# Because there is a DATE tag, line.data is automatically converted to a
|
||||||
# Date object before getting to this point, so it has to be converted
|
# Date object before getting to this point, so it has to be converted
|
||||||
# back to a string
|
# back to a string
|
||||||
date = str(line.data)
|
tx_date = str(line.data)
|
||||||
time = ""
|
tx_time = ""
|
||||||
line = self.__get_next_line()
|
line = self.__get_next_line()
|
||||||
if self.__level_is_finished(line, state.level):
|
if self.__level_is_finished(line, state.level):
|
||||||
pass
|
pass
|
||||||
elif line.token == TOKEN_TIME:
|
elif line.token == TOKEN_TIME:
|
||||||
time = str(line.data)
|
tx_time = str(line.data)
|
||||||
|
|
||||||
if self.use_def_src:
|
if self.use_def_src:
|
||||||
if time == "":
|
if tx_time == "":
|
||||||
self.def_src.set_data_item(_('Creation date of GEDCOM'), date)
|
self.def_src.set_data_item(_('Creation date of GEDCOM'),
|
||||||
|
tx_date)
|
||||||
else:
|
else:
|
||||||
self.def_src.set_data_item(_('Creation date and time of GEDCOM'),
|
self.def_src.set_data_item(
|
||||||
"%s %s" % (date, time))
|
_('Creation date and time of GEDCOM'),
|
||||||
|
"%s %s" % (tx_date, tx_time))
|
||||||
|
|
||||||
def __header_note(self, line, state):
|
def __header_note(self, line, state):
|
||||||
"""
|
"""
|
||||||
@ -6370,7 +6406,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
self.dbase.commit_note(new_note, self.trans, new_note.change)
|
self.dbase.commit_note(new_note, self.trans, new_note.change)
|
||||||
self.nid2id[new_note.gramps_id] = new_note.handle
|
self.nid2id[new_note.gramps_id] = new_note.handle
|
||||||
self.__check_msgs("NOTE Gramps ID %s" % new_note.get_gramps_id(),
|
self.__check_msgs("NOTE Gramps ID %s" % new_note.get_gramps_id(),
|
||||||
state, None, self.trans)
|
state, None)
|
||||||
|
|
||||||
def __note_chan(self, line, state):
|
def __note_chan(self, line, state):
|
||||||
if state.note:
|
if state.note:
|
||||||
@ -6441,7 +6477,7 @@ class GedcomParser(UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
Skip add lines of the specified level or lower.
|
Skip add lines of the specified level or lower.
|
||||||
"""
|
"""
|
||||||
skips = 0;
|
skips = 0
|
||||||
while True:
|
while True:
|
||||||
line = self.__get_next_line()
|
line = self.__get_next_line()
|
||||||
if self.__level_is_finished(line, level):
|
if self.__level_is_finished(line, level):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user