def main(): logging.basicConfig(filename='GeniToools.log', level=logging.INFO) logging.info('Starting GeniTools\n' + "=" * 20 + "\n") #Firstly the Input File is Read data = reader_input.reader_input("INPUT") base_call = geni_calls(data.genikey) if (data.continue_execution and base_call.check_valid_genikey()): #We only continue if inputs are correct! test_profile = profile.profile(data.profile, data.genikey) if (data.climbancestors or data.climbcousins): climber = climb(test_profile) if (data.climbcousins): ancestors, matrix_count, included_profiles = climber.get_cousins( data.generations) print(matrix_count) if (data.climbancestors): ancestors, affected_profiles = climber.get_ancestors( data.generations) else: logging.error(ERROR_MISSING_DATA) logging.info('Finishing GeniTools' + "=" * 20 + "\n")
def create_profiles_in_Geni(self, geni_data): ''' This method will create the needed profiles directly in Geni ''' if not self.correct_execution: logging.error(NO_GENI_EXECUTION) return False else: connector = geni_calls() valid = connector.check_valid_genikey() if not valid: #Ok, it appears the call is not correct and we are getting an error message logging.error(NO_GENI_KEY) return False else: parent_data = profile.profile(geni_input=geni_data) other_parent = None #We only make it for a single partner if len(parent_data.partner) == 1: other_parent = profile.profile(geni_input=parent_data.partner[0]) #We need to understand if it is mother of father, and then the logic diverts if (parent_data.gen_data["gender"] == "M"): self.father_profile.merge_profile(parent_data, language = self.language, convention = self.naming_convention) if other_parent: self.mother_profile.merge_profile(other_parent, language = self.language, convention = self.naming_convention) else: self.mother_profile.merge_profile(parent_data, language = self.language, convention = self.naming_convention) if other_parent: self.father_profile.merge_profile(other_parent, language = self.language, convention = self.naming_convention) #Once parents have been read, we proceed to create the profiles. for profile_obtained in self.profiles: logging.info(profile_obtained.returnFullName()) profile.profile.create_as_a_child(profile_obtained, geni_input=geni_data ) self.geni_profiles.append(profile_obtained) logging.info(profile_obtained.geni_specific_data["url"]) if profile_obtained.gen_data.get("marriage_link", None) in self.related_profiles.keys(): id_of_marriage = profile_obtained.gen_data["marriage_link"] partner = self.related_profiles[id_of_marriage] profile.profile.create_as_a_partner(partner, geni_input=profile_obtained.geni_specific_data["id"], type_geni="" ) self.related_geni_profiles.append(partner) logging.info(partner.geni_specific_data["url"]) if id_of_marriage in self.parents_profiles.keys(): father = self.parents_profiles[id_of_marriage][0] mother = self.parents_profiles[id_of_marriage][1] profile.profile.create_as_a_parent(father, geni_input=partner.geni_specific_data["id"], type_geni="" ) profile.profile.create_as_a_parent(mother, geni_input=partner.geni_specific_data["id"], type_geni="" ) self.parents_geni_profiles.append(father) self.parents_geni_profiles.append(mother) logging.info(ENDED) return True
def test_valid_token(self): ''' Secure that we are using a valid token ''' base_geni = geniapi_common.geni_calls() assert(base_geni.check_valid_genikey())
def test_no_valid_token(self): ''' Secure no valid token is found ''' base_geni2 = geniapi_common.geni_calls() self.assertFalse(base_geni2.check_valid_genikey())
def __runvalidation(self): validator = geni_calls() self.valid_key = validator.check_valid_genikey()