def get_gedcom(self, output):
     '''
     This will execute and create the gedcom to be used
     '''
     #We firstly create the gedcom wrapper file
     new_gedcom = gedcom_file()
     #We execute the reccurent function
     self.added_profiles = {}
     self.introduce_family(self.geni_profile, new_gedcom)
     #We save in the output specified
     new_gedcom.save(output)
     return new_gedcom
 def create_gedcom_file(self, output):
     '''
     This function will create the gedcom file that can be read by other genealogical tools
     '''
     if not self.correct_execution:
         logging.error(NO_GENI_EXECUTION)
         return False
     else:
         new_gedcom = gedcom_file()
         #We make father and mother a profile
         gedcom_profile.convert_gedcom(self.father_profile)
         gedcom_profile.convert_gedcom(self.mother_profile)
         #We add now the father and mother
         new_gedcom.add_element(self.father_profile.individual)
         new_gedcom.add_element(self.mother_profile.individual)
         #We prepara the children one
         children_ged = []
         for profile_obtained in self.profiles:
             #We convert the profile into the gedcom profile
             profile_temp = profile_obtained
             gedcom_profile.convert_gedcom(profile_temp)
             new_gedcom.add_element(profile_temp.individual)
             children_ged.append(profile_temp)
             if profile_obtained.gen_data.get("marriage_link", None) in self.related_profiles.keys():
                 id_of_marriage = profile_obtained.gen_data["marriage_link"]
                 #We capture the partner
                 partner = self.related_profiles[id_of_marriage]
                 gedcom_profile.convert_gedcom(partner)
                 #We add the partner
                 new_gedcom.add_element(partner.individual)
                 #We need to create a family here of both partners
                 if profile_obtained.gen_data["gender"] == "M":
                     new_gedcom.create_family(profile_temp, partner, [])
                 else:
                     new_gedcom.create_family(partner, profile_temp, [])
                 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]
                     #We now convert the profiles into the profile
                     gedcom_profile.convert_gedcom(father)
                     gedcom_profile.convert_gedcom(mother)
                     #We add them to the file
                     new_gedcom.add_element(father.individual)
                     new_gedcom.add_element(mother.individual)
                     #And the family!!!
                     new_gedcom.create_family(father, mother, [partner])
         #We create here the family
         new_gedcom.create_family(self.father_profile, self.mother_profile, children_ged)
         new_gedcom.save(output)
         
Ejemplo n.º 3
0
    def test_output_from_gedcom(self):
        '''
        It will take a gedcom dataclass and perform all executions available
        '''
        profile = gen_profile("Julián", "Gómez Gómez")
        profile.setCheckedDate("baptism_date", date(1970, 4, 2), "EXACT")
        profile.setCheckedDate("birth_date", date(1960, 4, 2), "EXACT")
        profile.setCheckedDate("death_date", date(2017, 2, 12), "EXACT")
        gedcom_profile.convert_gedcom(profile)

        new_gedcom = gedcom_file()
        new_gedcom.add_element(profile.individual)

        analysis = gen_analyzer(new_gedcom)
        analysis.execute()
    def test_gedcompy_usage(self):
        '''
        Test gedcompy wrapper use
        '''
        date_marr = date(2015, 1, 1)
        husband = gen_profile("Mario", "Vargas")
        husband.setCheckedDate("marriage_date", date_marr, "EXACT")
        wife = gen_profile("María", "Sanz")
        wife.setCheckedDate("marriage_date", date_marr, "EXACT")
        child1 = gen_profile("Francisco", "Vargas Sanz")
        child2 = gen_profile("Roberto", "Vargas Sanz")

        gedcom_profile.convert_gedcom(husband)
        gedcom_profile.convert_gedcom(wife)
        gedcom_profile.convert_gedcom(child1)
        gedcom_profile.convert_gedcom(child2)

        new_gedcom = gedcom_file()
        new_gedcom.add_element(husband.individual)
        new_gedcom.add_element(wife.individual)
        new_gedcom.add_element(child1.individual)
        new_gedcom.add_element(child2.individual)

        assert (husband.return_id() == "@I1@")
        assert (wife.return_id() == "@I2@")
        assert (child1.return_id() == "@I3@")
        assert (child2.return_id() == "@I4@")

        new_gedcom.create_family(husband, wife, [child1, child2])

        for ele in new_gedcom.__dict__["root_elements"]:
            if ele.tag == "FAM":
                for member in ele.__dict__['child_elements']:
                    if (member.tag == "HUSB"): assert (member.value == '@I1@')
                    if (member.tag == "WIFE"): assert (member.value == '@I2@')
                    if (member.tag == "CHILD"):
                        assert (member.value in ['@I3@', '@I4@'])
                    if (member.tag == "MARR"):
                        marr = member.__dict__['child_elements'][0]
                        assert (marr.value == "01 JAN 2015")
Ejemplo n.º 5
0
'''
Created on 16 oct. 2017

@author: Val

This example creates a profile, converts into GEDCOM format and builds it

'''

from pyGenealogy.common_profile import gen_profile
from pyGedcom.gedcom_profile import gedcom_profile
from pyGedcom.gedcompy_wrapper import gedcom_file

#Standard creation of a profile
profile = gen_profile("John", "Smith")
#Profile is converted into a profile prepared for gedcom
gedcom_profile.convert_gedcom(profile)
#We create the new gedcom file and we add the new profile
new_gedcom = gedcom_file()
new_gedcom.add_element(profile.individual)
#If you want to save the file...
new_gedcom.save("myoutput.ged")