From 2f7f7ac5f8783590f68fa753d74df7ac38fe97e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Fri, 8 Jan 2010 16:10:54 +0000 Subject: [PATCH] pylint svn: r13998 --- src/plugins/rel/rel_fi.py | 47 ++--- src/plugins/rel/rel_hu.py | 105 +++++------ src/plugins/rel/rel_it.py | 51 +++--- src/plugins/rel/rel_nl.py | 21 ++- src/plugins/rel/rel_no.py | 65 +++---- src/plugins/rel/rel_pl.py | 66 +++---- src/plugins/rel/rel_pt.py | 147 +++++++-------- src/plugins/rel/rel_ru.py | 365 ++++++++++++++++++++++++++++---------- src/plugins/rel/rel_sk.py | 21 ++- src/plugins/rel/rel_sv.py | 20 ++- 10 files changed, 548 insertions(+), 360 deletions(-) diff --git a/src/plugins/rel/rel_fi.py b/src/plugins/rel/rel_fi.py index 786261163..5fc9d464e 100644 --- a/src/plugins/rel/rel_fi.py +++ b/src/plugins/rel/rel_fi.py @@ -25,7 +25,9 @@ # Written by Alex Roitman, largely based on Relationship.py by Don Allingham # and on valuable input from Eero Tamminen - +""" +Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -50,11 +52,14 @@ _parents_level = [ "", "vanhemmat", "isovanhemmat", "isoisovanhemmat", # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ def __init__(self): Relationship.RelationshipCalculator.__init__(self) - def get_cousin(self,level): + def get_cousin(self, level): if level == 0: return "" elif level == 1: @@ -64,7 +69,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level > 2: return "%d. serkku" % level - def get_cousin_genitive(self,level): + def get_cousin_genitive(self, level): if level == 0: return "" elif level == 1: @@ -74,13 +79,13 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level > 2: return "%d. serkun" % level - def get_parents(self,level): - if level>len(_parents_level)-1: + def get_parents(self, level): + if level > len(_parents_level)-1: return "kaukaiset esivanhemmat" else: return _parents_level[level] - def get_direct_ancestor(self,person,rel_string): + def get_direct_ancestor(self, person, rel_string): result = [] for ix in range(len(rel_string)-1): if rel_string[ix] == 'f': @@ -93,9 +98,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('äiti') return ' '.join(result) - def get_direct_descendant(self,person,rel_string): + def get_direct_descendant(self, person, rel_string): result = [] - for ix in range(len(rel_string)-2,-1,-1): + for ix in range(len(rel_string)-2, -1, -1): if rel_string[ix] == 'f': result.append('pojan') elif rel_string[ix] == 'm': @@ -110,7 +115,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('lapsi') return ' '.join(result) - def get_ancestors_cousin(self,rel_string_long,rel_string_short): + def get_ancestors_cousin(self, rel_string_long, rel_string_short): result = [] removed = len(rel_string_long)-len(rel_string_short) level = len(rel_string_short)-1 @@ -122,7 +127,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append(self.get_cousin(level)) return ' '.join(result) - def get_cousins_descendant(self,person,rel_string_long,rel_string_short): + def get_cousins_descendant(self, person, rel_string_long, rel_string_short): result = [] removed = len(rel_string_long)-len(rel_string_short)-1 level = len(rel_string_short)-1 @@ -132,7 +137,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('veljen') else: result.append('sisaren') - for ix in range(removed-1,-1,-1): + for ix in range(removed-1, -1, -1): if rel_string_long[ix] == 'f': result.append('pojan') elif rel_string_long[ix] == 'm': @@ -147,7 +152,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('lapsi') return ' '.join(result) - def get_ancestors_brother(self,rel_string): + def get_ancestors_brother(self, rel_string): result = [] for ix in range(len(rel_string)-1): if rel_string[ix] == 'f': @@ -157,7 +162,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('veli') return ' '.join(result) - def get_ancestors_sister(self,rel_string): + def get_ancestors_sister(self, rel_string): result = [] for ix in range(len(rel_string)-1): if rel_string[ix] == 'f': @@ -174,26 +179,26 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): common = "" if not firstRel: if not secondRel: - return ('',common) + return ('', common) else: - return (self.get_direct_ancestor(other_person,secondRel),common) + return (self.get_direct_ancestor(other_person, secondRel), common) elif not secondRel: - return (self.get_direct_descendant(other_person,firstRel),common) + return (self.get_direct_descendant(other_person, firstRel), common) elif len(firstRel) == 1: if other_person == gen.lib.Person.MALE: - return (self.get_ancestors_brother(secondRel),common) + return (self.get_ancestors_brother(secondRel), common) else: - return (self.get_ancestors_sister(secondRel),common) + return (self.get_ancestors_sister(secondRel), common) elif len(secondRel) >= len(firstRel): - return (self.get_ancestors_cousin(secondRel,firstRel),common) + return (self.get_ancestors_cousin(secondRel, firstRel), common) else: - return (self.get_cousins_descendant(other_person,firstRel,secondRel),common) + return (self.get_cousins_descendant(other_person, firstRel, secondRel), common) def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b, reltocommon_a, reltocommon_b, only_birth=True, in_law_a=False, in_law_b=False): - return self.get_relationship(reltocommon_a, reltocommon_b, gender_a, gender_b)[0]; + return self.get_relationship(reltocommon_a, reltocommon_b, gender_a, gender_b)[0] def get_sibling_relationship_string(self, sib_type, gender_a, gender_b, in_law_a=False, in_law_b=False): diff --git a/src/plugins/rel/rel_hu.py b/src/plugins/rel/rel_hu.py index f4526b611..47f8b96a5 100644 --- a/src/plugins/rel/rel_hu.py +++ b/src/plugins/rel/rel_hu.py @@ -24,7 +24,9 @@ # # Written by Egyeki Gergely , 2004 -# +""" +Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -40,7 +42,7 @@ import Relationship # #------------------------------------------------------------------------- -_level =\ +_level = \ ["", "", "másod", "harmad", "negyed", "ötöd", "hatod", "heted", "nyolcad", "kilenced", "tized", "tizenegyed", "tizenketted", "tizenharmad", "tizennegyed", "tizenötöd", "tizenhatod", @@ -53,12 +55,15 @@ _level =\ # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ def __init__(self): Relationship.RelationshipCalculator.__init__(self) - def get_parents (self,level): + def get_parents (self, level): if level == 0: return "" elif level == 1: return "szülei" elif level == 2: return "nagyszülei" @@ -66,9 +71,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level == 4: return "ükszülei" else : return "%s szülei" % _level[level] - - - def get_father (self,level): + def get_father (self, level): if level == 0: return "" elif level == 1: return "apja" elif level == 2: return "nagyapja" @@ -76,7 +79,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level == 4: return "ükapja" else : return "%s ükapja" % (_level[level]) - def get_mother (self,level): + def get_mother (self, level): if level == 0: return "" elif level == 1: return "anyja" elif level == 2: return "nagyanyja" @@ -84,9 +87,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level == 4: return "ükanyja" else : return "%s ükanyja" % (_level[level]) - - - def get_son (self,level): + def get_son (self, level): if level == 0: return "" elif level == 1: return "fia" elif level == 2: return "unokája" @@ -94,49 +95,37 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif level == 4: return "ükunokája" else : return "%s unokája" % (_level[level]) - - def get_daughter (self,level): + def get_daughter (self, level): if level == 0: return "" elif level == 1: return "lánya" else : return self.get_son(level) - - - - - def get_uncle (self,level): + def get_uncle (self, level): if level == 0: return "" elif level == 1: return "testvére" elif level == 2: return "nagybátyja" else : return "%s nagybátyja" % (_level[level]) - - def get_aunt (self,level): + def get_aunt (self, level): if level == 0: return "" elif level == 1: return "testvére" elif level == 2: return "nagynénje" else : return "%s nagynénje" % (_level[level]) - - - - def get_nephew (self,level): + def get_nephew (self, level): if level == 0: return "" elif level == 1: return "unokája" else : return "%s unokája" % (_level[level]) - def get_niece(self,level): + def get_niece(self, level): return self.get_nephew(level) - - - - def get_male_cousin (self,level): + def get_male_cousin (self, level): if level == 0: return "" elif level == 1: return "unokatestvére" else : return "%s unokatestvére" % (_level[level]) - def get_female_cousin (self,level): + def get_female_cousin (self, level): return self.get_male_cousin(level) #---------------------------------------------- @@ -152,15 +141,15 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): other_birth_event = other_person.get_birth() other_birth_date = other_birth_event.get_date_object() if (orig_birth_date == "")or(other_birth_date == "") :return 0 - else :return orig_birth_date>other_birth_date + else :return orig_birth_date > other_birth_date - def get_age_brother (self,level): + def get_age_brother (self, level): if level == 0 : return "testvére" elif level == 1 : return "öccse" else : return "bátyja" - def get_age_sister (self,level): + def get_age_sister (self, level): if level == 0 : return "testvére" elif level == 1 : return "húga" else : return "nővére" @@ -253,91 +242,91 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # #------------------------------------------------------------------------- - def get_relationship(self,db, orig_person, other_person): + def get_relationship(self, db, orig_person, other_person): """ returns a string representing the relationshp between the two people, along with a list of common ancestors (typically father,mother) """ if orig_person is None: - return ("undefined",[]) + return ("undefined", []) if orig_person.get_handle() == other_person.get_handle(): return ('', []) is_spouse = self.is_spouse(db, orig_person, other_person) if is_spouse: - return (is_spouse,[]) + return (is_spouse, []) if self.is_fathermother_in_law(other_person, orig_person): if other_person.getGender() == gen.lib.Person.MALE: - return ("apósa",self.get_fathermother_in_law_common(other_person, orig_person)) + return ("apósa", self.get_fathermother_in_law_common(other_person, orig_person)) elif other_person.getGender() == gen.lib.Person.FEMALE: - return ("anyósa",self.get_fathermother_in_law_common(other_person, orig_person)) + return ("anyósa", self.get_fathermother_in_law_common(other_person, orig_person)) elif other_person.getGender() == 2 : - return ("apósa vagy anyósa",self.get_fathermother_in_law_common(other_person, orig_person)) + return ("apósa vagy anyósa", self.get_fathermother_in_law_common(other_person, orig_person)) if self.is_fathermother_in_law(orig_person, other_person): if orig_person.getGender() == gen.lib.Person.MALE: - return ("veje",self.get_fathermother_in_law_common(orig_person, other_person)) + return ("veje", self.get_fathermother_in_law_common(orig_person, other_person)) elif orig_person.getGender() == gen.lib.Person.FEMALE: - return ("menye",self.get_fathermother_in_law_common(orig_person, other_person)) + return ("menye", self.get_fathermother_in_law_common(orig_person, other_person)) elif orig_person.getGender() == 2 : - return ("veje vagy menye",self.get_fathermother_in_law_common(orig_person, other_person)) + return ("veje vagy menye", self.get_fathermother_in_law_common(orig_person, other_person)) if self.is_brothersister_in_law(orig_person, other_person): if other_person.getGender() == gen.lib.Person.MALE: - return ("sógora",self.get_brothersister_in_law_common(orig_person, other_person)) + return ("sógora", self.get_brothersister_in_law_common(orig_person, other_person)) elif other_person.getGender() == gen.lib.Person.FEMALE: - return ("sógornője",self.get_brothersister_in_law_common(orig_person, other_person)) + return ("sógornője", self.get_brothersister_in_law_common(orig_person, other_person)) elif other_person.getGender() == 2 : - return ("sógora vagy sógornője",self.get_brothersister_in_law_common(orig_person, other_person)) + return ("sógora vagy sógornője", self.get_brothersister_in_law_common(orig_person, other_person)) #get_relationship_distance changed, first data is relation to #orig person, apperently secondRel in this function - (secondRel,firstRel,common) = \ + (secondRel, firstRel, common) = \ self.get_relationship_distance(db, orig_person, other_person) if isinstance(common, basestring): - return (common,[]) + return (common, []) elif common: person_handle = common[0] else: - return ("",[]) + return ("", []) firstRel = len(firstRel) secondRel = len(secondRel) if firstRel == 0: if secondRel == 0: - return ('',common) + return ('', common) elif other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_father(secondRel),common) + return (self.get_father(secondRel), common) else: - return (self.get_mother(secondRel),common) + return (self.get_mother(secondRel), common) elif secondRel == 0: if other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_son(firstRel),common) + return (self.get_son(firstRel), common) else: - return (self.get_daughter(firstRel),common) + return (self.get_daughter(firstRel), common) elif firstRel == 1: if other_person.get_gender() == gen.lib.Person.MALE: if secondRel == 1: - return (self.get_age_brother(self.get_age_comp(orig_person, other_person)),common) - else :return (self.get_uncle(secondRel),common) + return (self.get_age_brother(self.get_age_comp(orig_person, other_person)), common) + else :return (self.get_uncle(secondRel), common) else: if secondRel == 1: - return (self.get_age_sister(self.get_age_comp(orig_person, other_person)),common) - else :return (self.get_aunt(secondRel),common) + return (self.get_age_sister(self.get_age_comp(orig_person, other_person)), common) + else :return (self.get_aunt(secondRel), common) elif secondRel == 1: if other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_nephew(firstRel-1),common) + return (self.get_nephew(firstRel-1), common) else: - return (self.get_niece(firstRel-1),common) + return (self.get_niece(firstRel-1), common) else: if other_person.get_gender() == gen.lib.Person.MALE: diff --git a/src/plugins/rel/rel_it.py b/src/plugins/rel/rel_it.py index 2899412fb..6fa447190 100644 --- a/src/plugins/rel/rel_it.py +++ b/src/plugins/rel/rel_it.py @@ -28,7 +28,9 @@ # Benny Malengier , 2007 # - +""" +Italian-Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -122,6 +124,9 @@ _niece_level = [ "", "la nipote%(step)s%(inlaw)s", # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ INLAW = ' acquisit%(gen)s' @@ -145,8 +150,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return 'o' return 'a' - def get_parents (self,level): - if level>len(_level)-1: + def get_parents (self, level): + if level > len(_level)-1: return "remote ancestors" else: return "%si genitori" % _level[level] @@ -311,59 +316,59 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # #------------------------------------------------------------------------- - def get_relationship(self,db, orig_person, other_person): + def get_relationship(self, db, orig_person, other_person): """ returns a string representing the relationshp between the two people, - along with a list of common ancestors (typically father,mother) + along with a list of common ancestors (typically father, mother) """ if orig_person is None: - return ("non definito",[]) + return ("non definito", []) if orig_person.get_handle() == other_person.get_handle(): return ('', []) is_spouse = self.is_spouse(db, orig_person, other_person) if is_spouse: - return (is_spouse,[]) + return (is_spouse, []) #get_relationship_distance changed, first data is relation to #orig person, apperently secondRel in this function - (secondRel,firstRel,common) = \ + (secondRel, firstRel, common) = \ self.get_relationship_distance(db, orig_person, other_person) if isinstance(common, basestring): - return (common,[]) + return (common, []) elif common: person_handle = common[0] else: - return ("",[]) + return ("", []) firstRel = len(firstRel) secondRel = len(secondRel) if firstRel == 0: if secondRel == 0: - return ('',common) + return ('', common) elif other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_father(secondRel),common) + return (self.get_father(secondRel), common) else: - return (self.get_mother(secondRel),common) + return (self.get_mother(secondRel), common) elif secondRel == 0: if other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_son(firstRel),common) + return (self.get_son(firstRel), common) else: - return (self.get_daughter(firstRel),common) + return (self.get_daughter(firstRel), common) elif firstRel == 1: if other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_uncle(secondRel),common) + return (self.get_uncle(secondRel), common) else: - return (self.get_aunt(secondRel),common) + return (self.get_aunt(secondRel), common) elif secondRel == 1: if other_person.get_gender() == gen.lib.Person.MALE: - return (self.get_nephew(firstRel-1),common) + return (self.get_nephew(firstRel-1), common) else: - return (self.get_niece(firstRel-1),common) + return (self.get_niece(firstRel-1), common) else: if other_person.get_gender() == gen.lib.Person.MALE: return (self.get_male_cousin(firstRel-1, secondRel-1), common) @@ -507,12 +512,12 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_it.py + # python src/plugins/rel/rel_it.py """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test - rc = RelationshipCalculator() - test(rc, True) + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_nl.py b/src/plugins/rel/rel_nl.py index ef8c397e5..d691d6dde 100644 --- a/src/plugins/rel/rel_nl.py +++ b/src/plugins/rel/rel_nl.py @@ -21,7 +21,9 @@ # # $Id$ - +""" +Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -242,12 +244,15 @@ _uncle_level = [ "", # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ #sibling strings - STEP= 'stief' + STEP = 'stief' HALF = 'half' - INLAW='aangetrouwde ' + INLAW = 'aangetrouwde ' def __init__(self): Relationship.RelationshipCalculator.__init__(self) @@ -275,7 +280,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return "verre %s%sachterkleinzoon (%d generaties)" % (inlaw, step, level) - def _get_mother(self,level, step='', inlaw=''): + def _get_mother(self, level, step='', inlaw=''): """Internal Dutch method to create relation string """ if level > len(_mother_level)-1: @@ -542,12 +547,12 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_nl.py + # python src/plugins/rel/rel_nl.py """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test - rc = RelationshipCalculator() - test(rc, True) + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_no.py b/src/plugins/rel/rel_no.py index 50e83d34f..90972a901 100644 --- a/src/plugins/rel/rel_no.py +++ b/src/plugins/rel/rel_no.py @@ -25,7 +25,9 @@ # Written by Alex Roitman, largely based on Relationship.py by Don Allingham # and on valuable input from Frode Jemtland - +""" +Norwegian-Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -35,10 +37,6 @@ import gen.lib import Relationship -#------------------------------------------------------------------------- -# -# Norwegian-specific definitions of relationships -# #------------------------------------------------------------------------- _cousin_level = [ "", "", #brother/sister, fetter/kusine -- these are taken care of separately @@ -49,25 +47,28 @@ _cousin_level = [ "", "", #brother/sister, fetter/kusine -- these are taken care "femtenmenning", "sekstenmenning", "syttenmenning", "attenmenning", "nittenmenning", "tyvemenning" ] -_cousin_terms = _cousin_level + ["fetter","kusine"] +_cousin_terms = _cousin_level + ["fetter", "kusine"] #------------------------------------------------------------------------- # # # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ def __init__(self): Relationship.RelationshipCalculator.__init__(self) - def get_parents(self,level): + def get_parents(self, level): if level == 0: return "forelder" else: return "ane i %d-te generationen" % (level+1) - def get_cousin(self,level): - if level>len(_cousin_level)-1: + def get_cousin(self, level): + if level > len(_cousin_level)-1: # FIXME: use Norwegian term term here, # UPDATED by Frode: unsure about the expretion "en fjern slektning", should it be just "fjern slektning". # Need to see it used in the program to get the understanding. @@ -75,7 +76,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): else: return _cousin_level[level] - def pair_up(self,rel_list): + def pair_up(self, rel_list): result = [] item = "" for word in rel_list[:]: @@ -99,7 +100,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): gen_result = [ item + 's' for item in result[0:-1] ] return ' '.join(gen_result+result[-1:]) - def get_direct_ancestor(self,person,rel_string): + def get_direct_ancestor(self, person, rel_string): result = [] for ix in range(len(rel_string)): if rel_string[ix] == 'f': @@ -108,9 +109,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('mor') return self.pair_up(result) - def get_direct_descendant(self,person,rel_string): + def get_direct_descendant(self, person, rel_string): result = [] - for ix in range(len(rel_string)-2,-1,-1): + for ix in range(len(rel_string)-2, -1, -1): if rel_string[ix] == 'f': result.append('sønne') else: @@ -121,7 +122,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('datter') return self.pair_up(result) - def get_ancestors_cousin(self,person,rel_string_long,rel_string_short): + def get_ancestors_cousin(self, person, rel_string_long, rel_string_short): result = [] removed = len(rel_string_long)-len(rel_string_short) level = len(rel_string_short)-1 @@ -136,11 +137,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('fetter') else: result.append('kusine') - main_string = self.get_two_way_rel(person,rel_string_short,rel_string_long) + main_string = self.get_two_way_rel(person, rel_string_short, rel_string_long) aux_string = self.pair_up(result) - return "%s (%s)" % (main_string,aux_string) + return "%s (%s)" % (main_string, aux_string) - def get_cousins_descendant(self,person,rel_string_long,rel_string_short): + def get_cousins_descendant(self, person, rel_string_long, rel_string_short): result = [] aux_string = "" removed = len(rel_string_long)-len(rel_string_short)-1 @@ -156,7 +157,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('bror') else: result.append('søster') - for ix in range(removed-1,-1,-1): + for ix in range(removed-1, -1, -1): if rel_string_long[ix] == 'f': result.append('sønn') else: @@ -165,12 +166,12 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('sønn') else: result.append('datter') - main_string = self.get_two_way_rel(person,rel_string_long,rel_string_short) + main_string = self.get_two_way_rel(person, rel_string_long, rel_string_short) if level: aux_string = " (%s)" % self.pair_up(result) - return "%s%s" % (main_string,aux_string) + return "%s%s" % (main_string, aux_string) - def get_ancestors_brother(self,rel_string): + def get_ancestors_brother(self, rel_string): result = [] for ix in range(len(rel_string)-1): if rel_string[ix] == 'f': @@ -180,7 +181,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('bror') return self.pair_up(result) - def get_ancestors_sister(self,rel_string): + def get_ancestors_sister(self, rel_string): result = [] for ix in range(len(rel_string)-1): if rel_string[ix] == 'f': @@ -190,7 +191,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('søster') return self.pair_up(result) - def get_two_way_rel(self,person,first_rel_string,second_rel_string): + def get_two_way_rel(self, person, first_rel_string, second_rel_string): result = [] for ix in range(len(second_rel_string)-1): if second_rel_string[ix] == 'f': @@ -202,7 +203,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): result.append('bror') else: result.append('søster') - for ix in range(len(first_rel_string)-3,-1,-1): + for ix in range(len(first_rel_string)-3, -1, -1): if first_rel_string[ix] == 'f': result.append('sønne') else: @@ -224,20 +225,20 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): common = "" if not firstRel: if not secondRel: - return ('',common) + return ('', common) else: - return (self.get_direct_ancestor(other_person,secondRel),common) + return (self.get_direct_ancestor(other_person, secondRel), common) elif not secondRel: - return (self.get_direct_descendant(other_person,firstRel),common) + return (self.get_direct_descendant(other_person, firstRel), common) elif len(firstRel) == 1: if other_person == gen.lib.Person.MALE: - return (self.get_ancestors_brother(secondRel),common) + return (self.get_ancestors_brother(secondRel), common) else: - return (self.get_ancestors_sister(secondRel),common) + return (self.get_ancestors_sister(secondRel), common) elif len(secondRel) >= len(firstRel): - return (self.get_ancestors_cousin(other_person,secondRel,firstRel),common) + return (self.get_ancestors_cousin(other_person, secondRel, firstRel), common) else: - return (self.get_cousins_descendant(other_person,firstRel,secondRel),common) + return (self.get_cousins_descendant(other_person, firstRel, secondRel), common) def get_single_relationship_string(self, Ga, Gb, gender_a, gender_b, reltocommon_a, reltocommon_b, @@ -247,7 +248,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): def get_sibling_relationship_string(self, sib_type, gender_a, gender_b, in_law_a=False, in_law_b=False): - return self.get_two_way_rel(gender_b,"","") + return self.get_two_way_rel(gender_b, "", "") if __name__ == "__main__": diff --git a/src/plugins/rel/rel_pl.py b/src/plugins/rel/rel_pl.py index 99fd45187..9c37eb962 100644 --- a/src/plugins/rel/rel_pl.py +++ b/src/plugins/rel/rel_pl.py @@ -26,9 +26,9 @@ # PL: Po objaśnienia oznaczania relacji zobacz Relationship.py # EN: For more information see Relationship.py # - - - +""" +Polish-specific definitions of relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -39,10 +39,6 @@ import gen.lib import Relationship #------------------------------------------------------------------------- -# -# Polish-specific definitions of relationships -# -#------------------------------------------------------------------------- # określa liczebnik porządkowy @@ -254,17 +250,13 @@ _niece_level_of_sisters_daughter = [ "", "siostrzenica", #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ - def __init__(self): Relationship.RelationshipCalculator.__init__(self) - - #-------------------------------------------------- - # - # - # - #-------------------------------------------------- def get_son(self, level, inlaw=''): """ Podaje tekst zawierający informację, jak bardzo potomek męski @@ -273,9 +265,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Określ, czy osoba jest przybraną, czy rodzoną if inlaw == '': - t_inlaw ="" + t_inlaw = "" else: - t_inlaw ="przybrany " + t_inlaw = "przybrany " # TODO: dodać rozpoznawanie pasierb/pasierbica if level >= 0 and level < len(_son_level): @@ -301,11 +293,11 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Określ, czy osoba jest przybraną, czy rodzoną # + stwórz obie formy (męską i żeńską) if inlaw == '': - t_inlaw ="" - t_inlawM ="" + t_inlaw = "" + t_inlawM = "" else: - t_inlaw ="przybrana " - t_inlawM ="przybrany " + t_inlaw = "przybrana " + t_inlawM = "przybrany " # TODO: dodać rozpoznawanie pasierb/pasierbica if level >= 0 and level < len(_daughter_level): @@ -328,9 +320,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Określ, czy osoba jest przybraną, czy rodzoną if inlaw == '': - t_inlaw ="" + t_inlaw = "" else: - t_inlaw ="przybrany " + t_inlaw = "przybrany " if level == 1: if inlaw == '' : @@ -350,7 +342,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): PL: Generuje relację po mieczu/po kądzieli EN: Generate relation 'by sword' or 'by distaff', polish specific """ - if level <=1: + if level <= 1: return "" elif level == 2: @@ -422,9 +414,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): (np. ojciec) jest spokrewniony do danej osoby """ if inlaw == '': - t_inlaw ="" + t_inlaw = "" else: - t_inlaw ="przybrany " + t_inlaw = "przybrany " if level >= 0 and level < len(_father_level): # Jeśli znasz bezpośrednią nazwę relacji, to ją zastosuj @@ -460,9 +452,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): """ if inlaw == '': - t_inlaw ="" + t_inlaw = "" else: - t_inlaw ="przybrana " + t_inlaw = "przybrana " if level >= 0 and level < len(_mother_level): # Jeśli znasz bezpośrednią nazwę relacji, to ją zastosuj @@ -498,9 +490,9 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): """ if inlaw == '': - t_inlaw ="" + t_inlaw = "" else: - t_inlaw ="przybrany " + t_inlaw = "przybrany " if level == 1: return t_inlaw + "rodzic" @@ -785,26 +777,26 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): elif Ga > 1 and Gb > 1: if (gender_b == gen.lib.Person.MALE): - if Ga==2 and Gb==2: + if Ga == 2 and Gb == 2: rel_str = "kuzyn" else: rel_str = "daleki kuzyn (%d. stopień pokrewieństwa)" % (Ga+Gb) elif (gender_b == gen.lib.Person.FEMALE): - if Ga==2 and Gb==2: + if Ga == 2 and Gb == 2: rel_str = "kuzynka" else: rel_str = "daleka kuzynka (%d. stopień pokrewieństwa)" % (Ga+Gb) else: - if Ga==2 and Gb==2: + if Ga == 2 and Gb == 2: rel_str = "kuzyn(ka)" else: rel_str = "daleki członek rodziny (%d. stopień pokrewieństwa)" % (Ga+Gb) else: # A program should never goes there, but... - rel_str ="nieokreślony stopień pokrewieństwa" + rel_str = "nieokreślony stopień pokrewieństwa" return rel_str @@ -883,12 +875,12 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_pl.py + # python src/plugins/rel/rel_pl.py """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test - rc = RelationshipCalculator() - test(rc, True) + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_pt.py b/src/plugins/rel/rel_pt.py index 7645fae71..a8eb6bb7a 100644 --- a/src/plugins/rel/rel_pt.py +++ b/src/plugins/rel/rel_pt.py @@ -24,7 +24,9 @@ # Based on the Spanish version by Julio Sanchez # $Id:rel_pt.py 9912 2008-01-22 09:17:46Z acraphae $ - +""" +Specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -110,133 +112,136 @@ _niece_level = [ "", "sobrinha", "sobrinha neta", "sobrinha bisneta", ] # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ def __init__(self): Relationship.RelationshipCalculator.__init__(self) - def get_male_cousin(self,level): - if levellen(_parents_level)-1: + def get_parents(self, level): + if level > len(_parents_level)-1: return u"дальние родственники" else: return _parents_level[level] - def get_junior_male_cousin(self,level,removed): - if removed > len(_junior_male_removed_level)-1 or level>len(_male_cousin_level)-1: + def get_junior_male_cousin(self, level, removed): + if removed > len(_junior_male_removed_level)-1 or \ + level > len(_male_cousin_level)-1: return u"дальний родственник" else: - return u"%s %s" % (_male_cousin_level[level],_junior_male_removed_level[removed]) + return u"%s %s" % (_male_cousin_level[level], _junior_male_removed_level[removed]) - def get_senior_male_cousin(self,level,removed): - if removed > len(_senior_male_removed_level)-1 or level>len(_male_cousin_level)-1: + def get_senior_male_cousin(self, level, removed): + if removed > len(_senior_male_removed_level)-1 or \ + level > len(_male_cousin_level)-1: return u"дальний родственник" else: - return u"%s %s" % (_male_cousin_level[level],_senior_male_removed_level[removed]) + return u"%s %s" % (_male_cousin_level[level], _senior_male_removed_level[removed]) - def get_junior_female_cousin(self,level,removed): - if removed > len(_junior_female_removed_level)-1 or level>len(_male_cousin_level)-1: + def get_junior_female_cousin(self, level, removed): + if removed > len(_junior_female_removed_level)-1 or \ + level > len(_male_cousin_level)-1: return u"дальняя родственница" else: - return u"%s %s" % (_female_cousin_level[level],_junior_female_removed_level[removed]) + return u"%s %s" % (_female_cousin_level[level], _junior_female_removed_level[removed]) - def get_senior_female_cousin(self,level,removed): - if removed > len(_senior_female_removed_level)-1 or level>len(_male_cousin_level)-1: + def get_senior_female_cousin(self, level, removed): + if removed > len(_senior_female_removed_level)-1 or \ + level > len(_male_cousin_level)-1: return u"дальняя родственница" else: - return u"%s %s" % (_female_cousin_level[level],_senior_female_removed_level[removed]) + return u"%s %s" % (_female_cousin_level[level], _senior_female_removed_level[removed]) - def get_father(self,level): - if level>len(_father_level)-1: + def get_father(self, level): + if level > len(_father_level)-1: return u"дальний предок" else: return _father_level[level] - def get_son(self,level): - if level>len(_son_level)-1: + def get_son(self, level): + if level > len(_son_level)-1: return u"дальний потомок" else: return _son_level[level] - def get_mother(self,level): - if level>len(_mother_level)-1: + def get_mother(self, level): + if level > len(_mother_level)-1: return u"дальний предок" else: return _mother_level[level] - def get_daughter(self,level): - if level>len(_daughter_level)-1: + def get_daughter(self, level): + if level > len(_daughter_level)-1: return u"дальний потомок" else: return _daughter_level[level] def _get_aunt(self, level, step='', inlaw=''): - if level>len(_sister_level)-1: + if level > len(_sister_level)-1: return u"дальний предок" else: return _sister_level[level] def _get_uncle(self, level, step='', inlaw=''): - if level>len(_brother_level)-1: + if level > len(_brother_level)-1: return u"дальний предок" else: return _brother_level[level] def _get_sibling(self, level, step='', inlaw=''): - """Sibling of unknown gender + """ + Sibling of unknown gender """ return self._get_uncle(level, step, inlaw) + u" или u" + self._get_aunt(level, step, inlaw) - def get_nephew(self,level): - if level>len(_nephew_level)-1: + def get_nephew(self, level): + if level > len(_nephew_level)-1: return u"дальний потомок" else: return _nephew_level[level] - def get_niece(self,level): - if level>len(_niece_level)-1: + def get_niece(self, level): + if level > len(_niece_level)-1: return u"дальний потомок" else: return _niece_level[level] @@ -258,14 +424,14 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_niece(Gb-1)) elif Ga > Gb: if gender_b == gen.lib.Person.MALE: - return (self.get_senior_male_cousin(Gb-1,Ga-Gb)) + return (self.get_senior_male_cousin(Gb-1, Ga-Gb)) else: - return (self.get_senior_female_cousin(Gb-1,Ga-Gb)) + return (self.get_senior_female_cousin(Gb-1, Ga-Gb)) else: if gender_b == gen.lib.Person.MALE: - return (self.get_junior_male_cousin(Ga-1,Gb-Ga)) + return (self.get_junior_male_cousin(Ga-1, Gb-Ga)) else: - return (self.get_junior_female_cousin(Ga-1,Gb-Ga)) + return (self.get_junior_female_cousin(Ga-1, Gb-Ga)) def get_plural_relationship_string(self, Ga, Gb): @@ -316,3 +482,18 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # TODO: def get_sibling_relationship_string for Russian step and inlaw relations +if __name__ == "__main__": + + # Test function. Call it as follows from the command line (so as to find + # imported modules): + # export PYTHONPATH=/path/to/gramps/src + # python src/plugins/rel/rel_ru.py + # (Above not needed here) + + """TRANSLATORS, copy this if statement at the bottom of your + rel_xx.py module, and test your work with: + python src/plugins/rel/rel_xx.py + """ + from Relationship import test + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_sk.py b/src/plugins/rel/rel_sk.py index 1dcd7d0b5..f32a92149 100644 --- a/src/plugins/rel/rel_sk.py +++ b/src/plugins/rel/rel_sk.py @@ -19,9 +19,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - - - +""" +Slovak-specific classes for relationships. +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -75,9 +75,9 @@ _sister_level = [ "", "sestra%s", "teta%s", "prateta%s", "praprateta%s", ] _brother_level = [ "", "brat%s", "strýko%s", "prastrýko%s", "praprastrýko%s", ] -_nephew_level =[ "", "synovec%s", "prasynovec%s", "praprasynovec%s", ] +_nephew_level = [ "", "synovec%s", "prasynovec%s", "praprasynovec%s", ] -_niece_level =[ "", "neter%s", "praneter%s", "prapraneter%s", ] +_niece_level = [ "", "neter%s", "praneter%s", "prapraneter%s", ] # kinship report @@ -106,6 +106,9 @@ _nephews_nieces_level = [ "", "synovci a netere", #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ INLAW = ' (m. zväzok)' @@ -576,13 +579,13 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_sk.py + # python src/plugins/rel/rel_sk.py # (Above not needed here) """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test - rc = RelationshipCalculator() - test(rc, True) + RC = RelationshipCalculator() + test(RC, True) diff --git a/src/plugins/rel/rel_sv.py b/src/plugins/rel/rel_sv.py index 9bef72c96..b3be0a0b9 100644 --- a/src/plugins/rel/rel_sv.py +++ b/src/plugins/rel/rel_sv.py @@ -26,7 +26,10 @@ # Written by Alex Roitman, largely based on Relationship.py by Don Allingham # and on valuable input from Jens Arvidsson # Updated to 3.0 by Peter Landgren 2007-12-30. - +# +""" +Swedish-specific definitions of relationships +""" #------------------------------------------------------------------------- # # GRAMPS modules @@ -36,10 +39,6 @@ import gen.lib import Relationship -#------------------------------------------------------------------------- -# -# Swedish-specific definitions of relationships -# #------------------------------------------------------------------------- _cousin_level = [ "", "kusin", @@ -69,6 +68,9 @@ u"artonde", u"nittonde", u"tjugonde" ] # #------------------------------------------------------------------------- class RelationshipCalculator(Relationship.RelationshipCalculator): + """ + RelationshipCalculator Class + """ #sibling strings STEP = 'styv' @@ -524,13 +526,13 @@ if __name__ == "__main__": # Test function. Call it as follows from the command line (so as to find # imported modules): # export PYTHONPATH=/path/to/gramps/src - # python src/plugins/rel_fr.py + # python src/plugins/rel/rel_sv.py # (Above not needed here) """TRANSLATORS, copy this if statement at the bottom of your rel_xx.py module, and test your work with: - python src/plugins/rel_xx.py + python src/plugins/rel/rel_xx.py """ from Relationship import test - rc = RelationshipCalculator() - test(rc, True) + RC = RelationshipCalculator() + test(RC, True)