From 8a8807c67047bca34d2a95d54f8696f621606cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?syst=C3=A8me?= Date: Sun, 1 Jan 2017 16:57:01 +0100 Subject: [PATCH] PR#284 9824: try to fix some remaining errors and warnings raised by pylint --- gramps/cli/clidbman.py | 4 +++ gramps/gen/datehandler/_date_sr.py | 38 +-------------------------- gramps/gen/simple/_simpleaccess.py | 5 ++-- gramps/gen/utils/alive.py | 2 +- gramps/plugins/db/dbapi/settings.py | 1 + gramps/plugins/lib/libhtml.py | 5 ++-- gramps/plugins/lib/libsubstkeyword.py | 2 +- gramps/plugins/rel/rel_es.py | 12 ++++----- gramps/plugins/rel/rel_hu.py | 14 +++++----- gramps/plugins/rel/rel_it.py | 2 +- 10 files changed, 29 insertions(+), 56 deletions(-) diff --git a/gramps/cli/clidbman.py b/gramps/cli/clidbman.py index caa817b48..7f5cab052 100644 --- a/gramps/cli/clidbman.py +++ b/gramps/cli/clidbman.py @@ -358,7 +358,11 @@ class CLIDbManager: temp_fp.write(data) url_fp.close() 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) + # dbase not set + dbase = make_database("bsddb") _LOG.debug("Write bsddb version %s", str(dbase.version())) with open(versionpath, "w") as version_file: version_file.write(str(dbase.version())) diff --git a/gramps/gen/datehandler/_date_sr.py b/gramps/gen/datehandler/_date_sr.py index 11cf16096..c50d6bbdc 100644 --- a/gramps/gen/datehandler/_date_sr.py +++ b/gramps/gen/datehandler/_date_sr.py @@ -296,43 +296,7 @@ class DateDisplaySR_Base(DateDisplay): else: return value - def display(self, date): - """ - 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) + display = DateDisplay.display_formatted class DateDisplaySR_Latin(DateDisplaySR_Base): """ diff --git a/gramps/gen/simple/_simpleaccess.py b/gramps/gen/simple/_simpleaccess.py index e26cc0ba2..836a43809 100644 --- a/gramps/gen/simple/_simpleaccess.py +++ b/gramps/gen/simple/_simpleaccess.py @@ -382,10 +382,11 @@ class SimpleAccess: if family: reflist = family.get_event_ref_list() if reflist: + # 'evnt' should be renamed to 'event'? elist = [ self.dbase.get_event_from_handle(ref.ref) for ref in reflist ] events = [ evnt for evnt in elist - if event.type == EventType.MARRIAGE ] + if evnt.type == EventType.MARRIAGE ] if events: return place_displayer.display_event(self.dbase, events[0]) return '' @@ -416,7 +417,7 @@ class SimpleAccess: elist = [ self.dbase.get_event_from_handle(ref.ref) for ref in reflist ] events = [ evnt for evnt in elist - if event.type == EventType.MARRIAGE ] + if evnt.type == EventType.MARRIAGE ] if events: date_obj = events[0].get_date_object() if date_obj: diff --git a/gramps/gen/utils/alive.py b/gramps/gen/utils/alive.py index 65bf1f162..8fcd5d0f9 100644 --- a/gramps/gen/utils/alive.py +++ b/gramps/gen/utils/alive.py @@ -459,7 +459,7 @@ class ProbablyAlive: # then assume our person must be dead too. date1, date2, explain, other = ancestors_too_old (person, - self.AVG_GENERATION_GAP) except RuntimeError: - raise Errors.DatabaseError( + raise DatabaseError( _("Database error: loop in %s's ancestors") % name_displayer.display(person)) if date1 and date2: diff --git a/gramps/plugins/db/dbapi/settings.py b/gramps/plugins/db/dbapi/settings.py index ba252674f..a9b2c645d 100644 --- a/gramps/plugins/db/dbapi/settings.py +++ b/gramps/plugins/db/dbapi/settings.py @@ -28,6 +28,7 @@ import os # NOTE: config is predefined # NOTE: you can override this in settings.ini or here: +#from gramps.gen.config import config dbtype = config.get('database.dbtype') if dbtype == "sqlite": diff --git a/gramps/plugins/lib/libhtml.py b/gramps/plugins/lib/libhtml.py index d48a24261..34d90a986 100644 --- a/gramps/plugins/lib/libhtml.py +++ b/gramps/plugins/lib/libhtml.py @@ -584,5 +584,6 @@ def htmltest(): pass if __name__ == '__main__': - from libhtmltest import htmltest - htmltest() + #from libhtmltest import htmltest + #htmltest() + pass diff --git a/gramps/plugins/lib/libsubstkeyword.py b/gramps/plugins/lib/libsubstkeyword.py index befbe330a..157301a8e 100644 --- a/gramps/plugins/lib/libsubstkeyword.py +++ b/gramps/plugins/lib/libsubstkeyword.py @@ -1271,7 +1271,7 @@ if __name__ == '__main__': def main_level_test(_in, testing_class, testing_what): """This is a mini def __main_level(self): """ - main = LevelParse(_in) + main = _in sepa = SeparatorParse(_in) test = testing_class(_in) diff --git a/gramps/plugins/rel/rel_es.py b/gramps/plugins/rel/rel_es.py index 98b1321fb..27282b0d4 100644 --- a/gramps/plugins/rel/rel_es.py +++ b/gramps/plugins/rel/rel_es.py @@ -502,7 +502,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): self._get_father(removed,step,inlaw)) else: - return "%s %scousin%s (%d-%d)" % (_level_name[level], + return "%s %scousin%s (%d-%d)" % (_level_name_male[level], step, inlaw, removed, lower) @@ -543,7 +543,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): self._get_father(removed,step,inlaw)) else: - return "%s %sprima%s (%d-%d)" % (_level_name[level], + return "%s %sprima%s (%d-%d)" % (_level_name_female[level], step, inlaw, removed, lower) @@ -709,16 +709,16 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): elif gender_b == Person.FEMALE: rel_str = self._get_distant_aunt(Gb, step, inlaw) else: - rel_str = "%s o %s" % (self._get_distant_uncle(Gb, 0, step=step, inlaw=inlaw), - self._get_distant_aunt(Gb, 0, step=step, inlaw=inlaw)) + rel_str = "%s o %s" % (self._get_distant_uncle(Gb, step, inlaw), + self._get_distant_aunt(Gb, step, inlaw)) elif Ga+1 == Gb: if gender_b == Person.MALE: rel_str = self._get_distant_nephew(Gb-1, step, inlaw) elif gender_b == Person.FEMALE: rel_str = self._get_distant_niece(Gb-1, step, inlaw) else: - rel_str = "%s o %s" % (self._get_distant_nephew(Gb-1, 0, step=step, inlaw=inlaw), - self._get_distant_niece(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, step, inlaw)) elif Ga > Gb: # These are cousins in different generations with the second person # being in a higher generation from the common ancestor than the diff --git a/gramps/plugins/rel/rel_hu.py b/gramps/plugins/rel/rel_hu.py index 79e190489..6f1021f6d 100644 --- a/gramps/plugins/rel/rel_hu.py +++ b/gramps/plugins/rel/rel_hu.py @@ -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(): - family = self.db.get_family_from_handle(f) + family = db.get_family_from_handle(f) sp_id = None if family: if other == family.get_father_handle(): @@ -166,7 +167,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): elif other == family.get_mother_handle(): sp_id = family.get_father_handle() 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 sp_id in family.get_child_handle_list(): 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(): - family = self.db.get_family_from_handle(f) + family = db.get_family_from_handle(f) sp_id = None if family: if orig == family.get_father_handle(): @@ -190,7 +192,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): sp_id = family.get_father_handler() p = other.get_main_parents_family_handle() - family = self.db.get_family_from_handle(p) + family = db.get_family_from_handle(p) if family: c = family.get_child_handle_list() if (other.get_handle() in c) and (sp_id in c): diff --git a/gramps/plugins/rel/rel_it.py b/gramps/plugins/rel/rel_it.py index 31ef267f7..eeabd9175 100644 --- a/gramps/plugins/rel/rel_it.py +++ b/gramps/plugins/rel/rel_it.py @@ -334,7 +334,7 @@ class RelationshipCalculator(gramps.gen.relationship.RelationshipCalculator): #get_relationship_distance changed, first data is relation to #orig person, apperently secondRel in this function (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): return (common, [])