PR#284 9824: try to fix some remaining errors and warnings raised by pylint
This commit is contained in:
parent
c4c1059c50
commit
8a8807c670
@ -358,7 +358,11 @@ class CLIDbManager:
|
|||||||
temp_fp.write(data)
|
temp_fp.write(data)
|
||||||
url_fp.close()
|
url_fp.close()
|
||||||
from gramps.gen.db.dbconst import BDBVERSFN
|
from gramps.gen.db.dbconst import BDBVERSFN
|
||||||
|
# name not set
|
||||||
|
(name, ext) = os.path.splitext(os.path.basename(filename))
|
||||||
versionpath = os.path.join(name, BDBVERSFN)
|
versionpath = os.path.join(name, BDBVERSFN)
|
||||||
|
# dbase not set
|
||||||
|
dbase = make_database("bsddb")
|
||||||
_LOG.debug("Write bsddb version %s", str(dbase.version()))
|
_LOG.debug("Write bsddb version %s", str(dbase.version()))
|
||||||
with open(versionpath, "w") as version_file:
|
with open(versionpath, "w") as version_file:
|
||||||
version_file.write(str(dbase.version()))
|
version_file.write(str(dbase.version()))
|
||||||
|
@ -296,43 +296,7 @@ class DateDisplaySR_Base(DateDisplay):
|
|||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def display(self, date):
|
display = DateDisplay.display_formatted
|
||||||
"""
|
|
||||||
Return a text string representing the date.
|
|
||||||
"""
|
|
||||||
mod = date.get_modifier()
|
|
||||||
cal = date.get_calendar()
|
|
||||||
qual = date.get_quality()
|
|
||||||
start = date.get_start_date()
|
|
||||||
newyear = date.get_new_year()
|
|
||||||
|
|
||||||
qual_str = self._qual_str[qual]
|
|
||||||
span1 = self._span1
|
|
||||||
span2 = self._span2
|
|
||||||
range1 = self._range1
|
|
||||||
range2 = self._range2
|
|
||||||
|
|
||||||
if mod == Date.MOD_TEXTONLY:
|
|
||||||
return date.get_text()
|
|
||||||
elif start == Date.EMPTY:
|
|
||||||
return ""
|
|
||||||
elif mod == Date.MOD_SPAN:
|
|
||||||
d_1 = self.display_cal[cal](start)
|
|
||||||
d_2 = self.display_cal[cal](date.get_stop_date())
|
|
||||||
scal = self.format_extras(cal, newyear)
|
|
||||||
return "%s%s %s %s %s%s" % (qual_str, span1, d_1, span2, d_2,
|
|
||||||
scal)
|
|
||||||
elif mod == Date.MOD_RANGE:
|
|
||||||
d_1 = self.display_cal[cal](start)
|
|
||||||
d_2 = self.display_cal[cal](date.get_stop_date())
|
|
||||||
scal = self.format_extras(cal, newyear)
|
|
||||||
return "%s%s %s %s %s%s" % (qual_str, range1, d_1, range2, d_2,
|
|
||||||
scal)
|
|
||||||
else:
|
|
||||||
text = self.display_cal[date.get_calendar()](start)
|
|
||||||
scal = self.format_extras(cal, newyear)
|
|
||||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
|
||||||
scal)
|
|
||||||
|
|
||||||
class DateDisplaySR_Latin(DateDisplaySR_Base):
|
class DateDisplaySR_Latin(DateDisplaySR_Base):
|
||||||
"""
|
"""
|
||||||
|
@ -382,10 +382,11 @@ class SimpleAccess:
|
|||||||
if family:
|
if family:
|
||||||
reflist = family.get_event_ref_list()
|
reflist = family.get_event_ref_list()
|
||||||
if reflist:
|
if reflist:
|
||||||
|
# 'evnt' should be renamed to 'event'?
|
||||||
elist = [ self.dbase.get_event_from_handle(ref.ref)
|
elist = [ self.dbase.get_event_from_handle(ref.ref)
|
||||||
for ref in reflist ]
|
for ref in reflist ]
|
||||||
events = [ evnt for evnt in elist
|
events = [ evnt for evnt in elist
|
||||||
if event.type == EventType.MARRIAGE ]
|
if evnt.type == EventType.MARRIAGE ]
|
||||||
if events:
|
if events:
|
||||||
return place_displayer.display_event(self.dbase, events[0])
|
return place_displayer.display_event(self.dbase, events[0])
|
||||||
return ''
|
return ''
|
||||||
@ -416,7 +417,7 @@ class SimpleAccess:
|
|||||||
elist = [ self.dbase.get_event_from_handle(ref.ref)
|
elist = [ self.dbase.get_event_from_handle(ref.ref)
|
||||||
for ref in reflist ]
|
for ref in reflist ]
|
||||||
events = [ evnt for evnt in elist
|
events = [ evnt for evnt in elist
|
||||||
if event.type == EventType.MARRIAGE ]
|
if evnt.type == EventType.MARRIAGE ]
|
||||||
if events:
|
if events:
|
||||||
date_obj = events[0].get_date_object()
|
date_obj = events[0].get_date_object()
|
||||||
if date_obj:
|
if date_obj:
|
||||||
|
@ -459,7 +459,7 @@ class ProbablyAlive:
|
|||||||
# then assume our person must be dead too.
|
# then assume our person must be dead too.
|
||||||
date1, date2, explain, other = ancestors_too_old (person, - self.AVG_GENERATION_GAP)
|
date1, date2, explain, other = ancestors_too_old (person, - self.AVG_GENERATION_GAP)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise Errors.DatabaseError(
|
raise DatabaseError(
|
||||||
_("Database error: loop in %s's ancestors") %
|
_("Database error: loop in %s's ancestors") %
|
||||||
name_displayer.display(person))
|
name_displayer.display(person))
|
||||||
if date1 and date2:
|
if date1 and date2:
|
||||||
|
@ -28,6 +28,7 @@ import os
|
|||||||
# NOTE: config is predefined
|
# NOTE: config is predefined
|
||||||
|
|
||||||
# NOTE: you can override this in settings.ini or here:
|
# NOTE: you can override this in settings.ini or here:
|
||||||
|
#from gramps.gen.config import config
|
||||||
dbtype = config.get('database.dbtype')
|
dbtype = config.get('database.dbtype')
|
||||||
|
|
||||||
if dbtype == "sqlite":
|
if dbtype == "sqlite":
|
||||||
|
@ -584,5 +584,6 @@ def htmltest():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from libhtmltest import htmltest
|
#from libhtmltest import htmltest
|
||||||
htmltest()
|
#htmltest()
|
||||||
|
pass
|
||||||
|
@ -1271,7 +1271,7 @@ if __name__ == '__main__':
|
|||||||
def main_level_test(_in, testing_class, testing_what):
|
def main_level_test(_in, testing_class, testing_what):
|
||||||
"""This is a mini def __main_level(self):
|
"""This is a mini def __main_level(self):
|
||||||
"""
|
"""
|
||||||
main = LevelParse(_in)
|
main = _in
|
||||||
sepa = SeparatorParse(_in)
|
sepa = SeparatorParse(_in)
|
||||||
test = testing_class(_in)
|
test = testing_class(_in)
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
self._get_father(removed,step,inlaw))
|
self._get_father(removed,step,inlaw))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "%s %scousin%s (%d-%d)" % (_level_name[level],
|
return "%s %scousin%s (%d-%d)" % (_level_name_male[level],
|
||||||
step, inlaw,
|
step, inlaw,
|
||||||
removed, lower)
|
removed, lower)
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
self._get_father(removed,step,inlaw))
|
self._get_father(removed,step,inlaw))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "%s %sprima%s (%d-%d)" % (_level_name[level],
|
return "%s %sprima%s (%d-%d)" % (_level_name_female[level],
|
||||||
step, inlaw,
|
step, inlaw,
|
||||||
removed, lower)
|
removed, lower)
|
||||||
|
|
||||||
@ -709,16 +709,16 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
elif gender_b == Person.FEMALE:
|
elif gender_b == Person.FEMALE:
|
||||||
rel_str = self._get_distant_aunt(Gb, step, inlaw)
|
rel_str = self._get_distant_aunt(Gb, step, inlaw)
|
||||||
else:
|
else:
|
||||||
rel_str = "%s o %s" % (self._get_distant_uncle(Gb, 0, step=step, inlaw=inlaw),
|
rel_str = "%s o %s" % (self._get_distant_uncle(Gb, step, inlaw),
|
||||||
self._get_distant_aunt(Gb, 0, step=step, inlaw=inlaw))
|
self._get_distant_aunt(Gb, step, inlaw))
|
||||||
elif Ga+1 == Gb:
|
elif Ga+1 == Gb:
|
||||||
if gender_b == Person.MALE:
|
if gender_b == Person.MALE:
|
||||||
rel_str = self._get_distant_nephew(Gb-1, step, inlaw)
|
rel_str = self._get_distant_nephew(Gb-1, step, inlaw)
|
||||||
elif gender_b == Person.FEMALE:
|
elif gender_b == Person.FEMALE:
|
||||||
rel_str = self._get_distant_niece(Gb-1, step, inlaw)
|
rel_str = self._get_distant_niece(Gb-1, step, inlaw)
|
||||||
else:
|
else:
|
||||||
rel_str = "%s o %s" % (self._get_distant_nephew(Gb-1, 0, step=step, inlaw=inlaw),
|
rel_str = "%s o %s" % (self._get_distant_nephew(Gb-1, step, inlaw),
|
||||||
self._get_distant_niece(Gb-1, 0, step=step, inlaw=inlaw))
|
self._get_distant_niece(Gb-1, step, inlaw))
|
||||||
elif Ga > Gb:
|
elif Ga > Gb:
|
||||||
# These are cousins in different generations with the second person
|
# These are cousins in different generations with the second person
|
||||||
# being in a higher generation from the common ancestor than the
|
# being in a higher generation from the common ancestor than the
|
||||||
|
@ -156,9 +156,10 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
#
|
#
|
||||||
#---------------------------------------------
|
#---------------------------------------------
|
||||||
|
|
||||||
def is_fathermother_in_law(self, orig, other):
|
# FIXME: is it still used?
|
||||||
|
def is_fathermother_in_law(self, db, orig, other):
|
||||||
for f in other.get_family_handle_list():
|
for f in other.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(f)
|
family = db.get_family_from_handle(f)
|
||||||
sp_id = None
|
sp_id = None
|
||||||
if family:
|
if family:
|
||||||
if other == family.get_father_handle():
|
if other == family.get_father_handle():
|
||||||
@ -166,7 +167,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
elif other == family.get_mother_handle():
|
elif other == family.get_mother_handle():
|
||||||
sp_id = family.get_father_handle()
|
sp_id = family.get_father_handle()
|
||||||
for g in orig.get_family_handle_list():
|
for g in orig.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(g)
|
family = db.get_family_from_handle(g)
|
||||||
if family:
|
if family:
|
||||||
if sp_id in family.get_child_handle_list():
|
if sp_id in family.get_child_handle_list():
|
||||||
return 1
|
return 1
|
||||||
@ -179,9 +180,10 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
def is_brothersister_in_law(self, orig, other):
|
# FIXME: is it still used?
|
||||||
|
def is_brothersister_in_law(self, db, orig, other):
|
||||||
for f in orig.get_family_handle_list():
|
for f in orig.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(f)
|
family = db.get_family_from_handle(f)
|
||||||
sp_id = None
|
sp_id = None
|
||||||
if family:
|
if family:
|
||||||
if orig == family.get_father_handle():
|
if orig == family.get_father_handle():
|
||||||
@ -190,7 +192,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
sp_id = family.get_father_handler()
|
sp_id = family.get_father_handler()
|
||||||
|
|
||||||
p = other.get_main_parents_family_handle()
|
p = other.get_main_parents_family_handle()
|
||||||
family = self.db.get_family_from_handle(p)
|
family = db.get_family_from_handle(p)
|
||||||
if family:
|
if family:
|
||||||
c = family.get_child_handle_list()
|
c = family.get_child_handle_list()
|
||||||
if (other.get_handle() in c) and (sp_id in c):
|
if (other.get_handle() in c) and (sp_id in c):
|
||||||
|
@ -334,7 +334,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator):
|
|||||||
#get_relationship_distance changed, first data is relation to
|
#get_relationship_distance changed, first data is relation to
|
||||||
#orig person, apperently secondRel in this function
|
#orig person, apperently secondRel in this function
|
||||||
(secondRel, firstRel, common) = \
|
(secondRel, firstRel, common) = \
|
||||||
self.get_relationship_distance(db, orig_person, other_person)
|
self.get_relationship_distance_new(db, orig_person, other_person)
|
||||||
|
|
||||||
if isinstance(common, str):
|
if isinstance(common, str):
|
||||||
return (common, [])
|
return (common, [])
|
||||||
|
Loading…
Reference in New Issue
Block a user