def __init__(self, geni_input, type_geni="g"): # id int or string ''' The geni input provided can be: - The id of the profile - The id of the profile with g - Each address of the profile. ''' #Some checking parameters initiated self.properly_executed = False self.existing_in_geni = False self.geni_specific_data = {} #We initiate the base classes geni_calls.__init__(self) url = process_geni_input(geni_input, type_geni) + self.token_string() r = s.geni_request_get(url) data = r.json() #Now we can execute the constructor if (not "first_name" in data.keys()): data["first_name"] = NOT_KNOWN_VALUE if (not "last_name" in data.keys()): data["last_name"] = NOT_KNOWN_VALUE gen_profile.__init__(self, data["first_name"], data["last_name"], id_db=data.get("id", None)) if not "error" in data.keys(): self.existing_in_geni = True self.fulldata = data if "mugshot_urls" in data: data.pop("mugshot_urls") if "photo_urls" in data: data.pop("photo_urls") self.data = data self.get_geni_data(data) self.properly_executed = True
def create_as_a_child(cls, base_profile, union=None, profile=None, geni_input=None, type_geni="g"): ''' From a common profile from pyGenealogy library, a new profile will be created as a child of a given union of 2 profiles. ''' union_to_use = None if (union != None): union_to_use = union elif (profile != None): if (len(profile.marriage_union) == 1): union_to_use = profile.marriage_union[0].union_id elif (geni_input != None): tmp_prof = cls.create_internally(geni_input, type_geni) #TODO: add error checking if tmp_prof is not properly created. if (len(tmp_prof.marriage_union) == 1): union_to_use = tmp_prof.marriage_union[0].union_id else: #We have a problem, potentially a wrong profile logging.error(NO_VALID_UNION_PROFILE + str(len(tmp_prof.marriage_union))) if (union_to_use == None): return False #Calling essentially the constructors base_profile.__class__ = cls geni_calls.__init__(cls) #We create the url for creating the child add_child = s.GENI_API + union_to_use + s.GENI_ADD_CHILD + s.GENI_INITIATE_PARAMETER + "first_name=" add_child += base_profile.gen_data[ "name"] + s.GENI_ADD_PARAMETER + s.GENI_TOKEN + s.get_token() base_profile.creation_operations(add_child) return True
def __init__(self): ''' Simple constructor of the database ''' #We initiate the base classes geni_calls.__init__(self) gen_database.__init__(self) self.equivalence = {} self.inmediate = {}
def __init__(self, myid): ''' The constructor will also make the call to the web to get the right string ''' input_id = myid #This will allow to intoduce the complete direction of the profile if "https" in myid: input_id = "profile" + myid.split("profile")[1] #Initiating base class geni_calls.__init__(self) self.union_url = self.get_profile_url( input_id) + s.GENI_FAMILY + self.token_string() r = s.geni_request_get(self.union_url) self.data = r.json() #we initialize the lists self.error = False self.union_extracted = False self.parents = [] self.sibligns = [] self.partner = [] self.children = [] self.parent_union = [] self.marriage_union = [] self.marriage_events = [] if not ('error' in self.data): #In this case, we have extracted properly the union data self.union_extracted = True #the nodes include the data of the different affected profiles and unions for keydata in self.data["nodes"].keys(): #is easier to go to the usions, so we filter by unions. if "union" in keydata: #Good... let's obtain the data from the union tmp_union = geni_union(self.data["nodes"][keydata], keydata) #Now we need to filter the parents and children as we should not duplicate if tmp_union.is_profile_child(input_id): #We know is a child... so self.parents = self.parents + tmp_union.parents tmp_union.children.remove(input_id) self.sibligns = self.sibligns + tmp_union.children self.parent_union.append(tmp_union) else: #In this case we know is a marriage union tmp_union.parents.remove(input_id) self.partner = self.partner + tmp_union.parents self.children = self.children + tmp_union.children #We obtain the union from Geni in order to introduce the marriage marriage_union = union(tmp_union.union_id) self.marriage_union.append(tmp_union) if "marriage" in marriage_union.union_data.keys(): self.marriage_events.append( marriage_union.union_data.get( 'marriage', None)) else: self.error = True
def __init__(self, geni_input, type_geni="g", data_language="en", data_value=None): ''' The geni input provided can be: - The id of the profile - The id of the profile with g - Each address of the profile. - data_value: is the raw output from Geni API that can be used for direct data introductions ''' #Some checking parameters initiated self.properly_executed = False self.existing_in_geni = False self.merged_in_geni = False self.geni_specific_data = {} #We initiate the base classes geni_calls.__init__(self) #It is possible to introduce the direct raw data from geni to the profile if data_value: data = data_value else: url = process_geni_input(geni_input, type_geni) + self.token_string() r = s.geni_request_get(url) data = r.json() #In case the profile has been merged to other profile, as the information is available it will be modified. if (data.get("merged_into", None) and data.get("deleted", None)): self.merged_in_geni = True url = data.get("merged_into") + self.token_string() r = s.geni_request_get(url) data = r.json() #Now we can execute the constructor if ("first_name" not in data.keys()): data["first_name"] = NOT_KNOWN_VALUE if ("last_name" not in data.keys()): data["last_name"] = data.get("maiden_name", NOT_KNOWN_VALUE) gen_profile.__init__(self, data["first_name"], data["last_name"], id_db=data.get("id", None), data_language="en") #In some cases we do not have access to the profile and data is not accurate if data.get("name", None): if ("<private>" in data["name"]): self.set_accessible(False) if not "error" in data.keys(): self.existing_in_geni = True self.fulldata = data if "mugshot_urls" in data: data.pop("mugshot_urls") if "photo_urls" in data: data.pop("photo_urls") self.data = data self.get_geni_data(data) self.properly_executed = True
def __init__(self, union_id): ''' Constructor ''' #We initiate the base classes geni_calls.__init__(self) url = geni.GENI_API + union_id + geni.GENI_SINGLE_TOKEN + geni.get_token( ) r = geni.geni_request_get(url) data = r.json() self.union_data = {} for key_value in data.keys(): if key_value == "id": self.union_data["id"] = data[key_value] if key_value == "url": self.union_data["url"] = data[key_value] if key_value == "guid": self.union_data["guid"] = data[key_value] if key_value == "marriage_date": day = data["marriage_date"].get("day", 1) month = data["marriage_date"].get("month", 1) year = data["marriage_date"].get("year", 1) self.union_data["marriage_date"] = date(year, month, day) if key_value == "marriage_location": self.union_data["marriage_place"] = {} for location_key in data["marriage_location"].keys(): if location_key == "city": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "county": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "state": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "country": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "country_code": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "latitude": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "longitude": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if location_key == "formatted_location": self.union_data["marriage_place"][location_key] = data[ "marriage_location"][location_key] if key_value == "status": self.union_data["status"] = data[key_value] if key_value == "partners": self.union_data["partners"] = data[key_value] if key_value == "children": self.union_data["children"] = data[key_value]
def create_as_a_partner(cls, base_profile, profile = None, geni_input = None, type_geni="g"): ''' From a common profile we take another profile and we create at parnter. ''' partner_to_use = process_profile_input(profile, geni_input, type_geni) #Calling essentially the constructors data_input = create_input_file_2_geni(base_profile) base_profile.__class__ = cls geni_calls.__init__(cls) #We create the url for creating the child add_partner = partner_to_use + s.GENI_ADD_PARTNER + s.GENI_INITIATE_PARAMETER + "first_name=" add_partner += base_profile.gen_data["name"] + s.GENI_ADD_PARAMETER + s.GENI_TOKEN + s.get_token() base_profile.creation_operations(add_partner, data_input) base_profile.add_marriage_in_geni()
def create_as_a_parent(cls, base_profile, profile = None, geni_input = None, type_geni="g"): ''' From a common profile from pyGenealogy library, a new profile will be created as a parent of a given profile ''' child_to_use = process_profile_input(profile, geni_input, type_geni) #Calling essentially the constructors data_input = create_input_file_2_geni(base_profile) base_profile.__class__ = cls geni_calls.__init__(cls) #We create the url for creating the child add_parent = child_to_use + s.GENI_ADD_PARENT + s.GENI_INITIATE_PARAMETER + s.GENI_TOKEN + s.get_token() #We also add the needed data, that we take from the base profile directly base_profile.creation_operations(add_parent, data_input)
def create_as_a_child(cls, base_profile, union=None, profile=None, geni_input=None, type_geni="g", only_one_parent=False): ''' From a common profile from pyGenealogy library, a new profile will be created as a child of a given union of 2 profiles. union the union it will be added proile the geni profile geni_input the inptu fro geni if avaialbel only_one_parent is used when there is a sinlge parent ''' union_to_use = None if (union is not None): union_to_use = union elif (profile is not None): if (len(profile.marriage_union) == 1) and not only_one_parent: union_to_use = profile.marriage_union[0].union_id elif (geni_input is not None): tmp_prof = cls.create_internally(geni_input, type_geni) #TODO: add error checking if tmp_prof is not properly created. if (len(tmp_prof.marriage_union) == 1): union_to_use = tmp_prof.marriage_union[0].union_id else: #We have a problem, potentially a wrong profile logging.error(NO_VALID_UNION_PROFILE + str(len(tmp_prof.marriage_union))) #Calling essentially the constructors data_input = create_input_file_2_geni(base_profile) base_profile.__class__ = cls geni_calls.__init__(cls) #We create the url for creating the child if (union_to_use is None): add_child = s.GENI_API + profile.get_id() else: add_child = s.GENI_API + union_to_use add_child += s.GENI_ADD_CHILD + s.GENI_INITIATE_PARAMETER + "first_name=" + base_profile.gen_data[ "name"] + s.GENI_ADD_PARAMETER + s.GENI_TOKEN + s.get_token() base_profile.creation_operations(add_child, data_input) return True
def __init__(self, myid): ''' The constructor will also make the call to the web to get the right string ''' #Initiating base class geni_calls.__init__(self) self.union_url = self.get_profile_url( myid) + s.GENI_FAMILY + self.token_string() r = s.geni_request_get(self.union_url) self.data = r.json() #we initialize the lists self.union_extracted = False self.parents = [] self.sibligns = [] self.partner = [] self.children = [] self.parent_union = [] self.marriage_union = [] if not ('error' in self.data): #In this case, we have extracted properly the union data self.union_extracted = True #the nodes include the data of the different affected profiles and unions for keydata in self.data["nodes"].keys(): #is easier to go to the usions, so we filter by unions. if "union" in keydata: #Good... let's obtain the data from the union tmp_union = geni_union(self.data["nodes"][keydata], keydata) #Now we need to filter the parents and children as we should not duplicate if tmp_union.is_profile_child(myid): #We know is a child... so self.parents = self.parents + tmp_union.parents tmp_union.children.remove(myid) self.sibligns = self.sibligns + tmp_union.children self.parent_union.append(tmp_union) else: tmp_union.parents.remove(myid) self.partner = self.partner + tmp_union.parents self.children = self.children + tmp_union.children self.marriage_union.append(tmp_union)
def __init__(self, union_id): ''' Constructor it takes the union id from Geni ''' #We initiate the base classes geni_calls.__init__(self) family_profile.__init__(self) data = "" if (union_id in geni.GENI_CALLED_UNIONS): #In order to save calls we try to save the different calls data = geni.GENI_CALLED_UNIONS[union_id] else: url = geni.GENI_API + union_id + geni.GENI_SINGLE_TOKEN + geni.get_token( ) r = geni.geni_request_get(url) data = r.json() geni.GENI_CALLED_UNIONS[union_id] = data self.union_data = {} #Initiating values of the parametrs self.union_data["partners"] = [] for key_value in data.keys(): if key_value == "id": self.union_data["id"] = data[key_value] if key_value == "url": self.union_data["url"] = data[key_value] if key_value == "guid": self.union_data["guid"] = data[key_value] if key_value == "marriage_date": #We might have an existing marriage in the file self.union_data["marriage"] = self.get_date( "marriage", data["marriage_date"], previous_event=self.union_data.get("marriage", None)) if key_value == "marriage_location": place_data = {} for location_key in data["marriage_location"].keys(): if location_key == "city": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "county": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "state": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "country": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "country_code": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "latitude": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "longitude": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "formatted_location": place_data[location_key] = data["marriage_location"][ location_key] if not ("marriage" in self.union_data.keys()): self.union_data["marriage"] = event_profile("marriage") self.union_data["marriage"].setLocationAlreadyProcessed( place_data) if key_value == "status": self.union_data["status"] = data[key_value] if key_value == "partners": #The union stores the partner as a full address, but we are looking for the profile ID which is stored for partner in data[key_value]: self.union_data["partners"].append(partner.split("/")[-1]) self.setFather( geni.get_profile_id_from_address(data[key_value][0])) if len(data.get(key_value, None)) > 1: self.setMother( geni.get_profile_id_from_address(data[key_value][1])) if key_value == "children": self.union_data["children"] = data[key_value] children = [] for child in data[key_value]: children.append(geni.get_profile_id_from_address(child)) self.setChild(children)
def __init__(self, union_id): ''' Constructor it takes the union id from Geni ''' #We initiate the base classes geni_calls.__init__(self) data = "" if (union_id in geni.GENI_CALLED_UNIONS): #In order to save calls we try to save the different calls data = geni.GENI_CALLED_UNIONS[union_id] else: url = geni.GENI_API + union_id + geni.GENI_SINGLE_TOKEN + geni.get_token( ) r = geni.geni_request_get(url) data = r.json() geni.GENI_CALLED_UNIONS[union_id] = data self.union_data = {} for key_value in data.keys(): if key_value == "id": self.union_data["id"] = data[key_value] if key_value == "url": self.union_data["url"] = data[key_value] if key_value == "guid": self.union_data["guid"] = data[key_value] if key_value == "marriage_date": #We might have an existing marriage in the file self.union_data["marriage"] = self.get_date( "marriage", data["marriage_date"], previous_event=self.union_data.get("marriage", None)) if key_value == "marriage_location": place_data = {} for location_key in data["marriage_location"].keys(): if location_key == "city": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "county": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "state": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "country": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "country_code": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "latitude": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "longitude": place_data[location_key] = data["marriage_location"][ location_key] if location_key == "formatted_location": place_data[location_key] = data["marriage_location"][ location_key] if not ("marriage" in self.union_data.keys()): self.union_data["marriage"] = event_profile("marriage") self.union_data["marriage"].setLocationAlreadyProcessed( place_data) if key_value == "status": self.union_data["status"] = data[key_value] if key_value == "partners": self.union_data["partners"] = data[key_value] if key_value == "children": self.union_data["children"] = data[key_value]