Exemplo n.º 1
0
    def merge_person_information(self,new,trans):
        """
        Merging the person's individual information is pretty simple. The
        person 'new' is a new, empty person. The data is loaded in this
        new person. The idea is that all information that can possibly be
        preserved is preserved.
        """
        self.old_handle = self.p2.get_handle()
        self.new_handle = self.p1.get_handle()

        # Choose the handle from the target person. Since this is internal
        # only information, no user visible information is lost.
        new.set_handle(self.new_handle)

        # The gender is chosen from the primary person. This is one case
        # where data may be lost if you merge the data from two people of
        # opposite genders.
        new.set_gender(self.p1.get_gender())

        # copy the GRAMPS Ids
        self.merge_gramps_ids(new)

        # copy names
        self.merge_names(new)

        # merge the event lists
        self.merge_event_lists(new)

        GrampsDb.set_birth_death_index(self.db, new)

        # copy attributes
        new.set_attribute_list(self.p1.get_attribute_list() +
                               self.p2.get_attribute_list())

        # copy addresses
        new.set_address_list(self.p1.get_address_list() + self.p2.get_address_list())

        # copy urls
        new.set_url_list(self.p1.get_url_list() + self.p2.get_url_list())

	# merge LDS
        new.set_lds_ord_list(self.p1.get_lds_ord_list() + self.p2.get_lds_ord_list())

        # privacy
        new.set_privacy(self.p1.get_privacy() or self.p2.get_privacy())

        # sources
        new.set_source_reference_list(self.p1.get_source_references() +
                                      self.p2.get_source_references())

        # media
        for photo in self.p1.get_media_list():
            new.add_media_reference(photo)
        for photo in self.p2.get_media_list():
            new.add_media_reference(photo)

        # note
        note1 = self.p1.get_note_object()
        note2 = self.p2.get_note_object()
        new.set_note_object(self.merge_notes(note1,note2))
Exemplo n.º 2
0
    def merge_person_information(self, new, trans):
        """
        Merging the person's individual information is pretty simple. The
        person 'new' is a new, empty person. The data is loaded in this
        new person. The idea is that all information that can possibly be
        preserved is preserved.
        """
        self.old_handle = self.p2.get_handle()
        self.new_handle = self.p1.get_handle()

        # Choose the handle from the target person. Since this is internal
        # only information, no user visible information is lost.
        new.set_handle(self.new_handle)

        # The gender is chosen from the primary person. This is one case
        # where data may be lost if you merge the data from two people of
        # opposite genders.
        new.set_gender(self.p1.get_gender())

        # copy the GRAMPS Ids
        self.merge_gramps_ids(new)

        # copy names
        self.merge_names(new)

        # merge the event lists
        self.merge_event_lists(new)

        GrampsDb.set_birth_death_index(self.db, new)

        # copy attributes
        new.set_attribute_list(self.p1.get_attribute_list() +
                               self.p2.get_attribute_list())

        # copy addresses
        new.set_address_list(self.p1.get_address_list() +
                             self.p2.get_address_list())

        # copy urls
        new.set_url_list(self.p1.get_url_list() + self.p2.get_url_list())

        # merge LDS
        new.set_lds_ord_list(self.p1.get_lds_ord_list() +
                             self.p2.get_lds_ord_list())

        # privacy
        new.set_privacy(self.p1.get_privacy() or self.p2.get_privacy())

        # sources
        new.set_source_reference_list(self.p1.get_source_references() +
                                      self.p2.get_source_references())

        # media
        for photo in self.p1.get_media_list():
            new.add_media_reference(photo)
        for photo in self.p2.get_media_list():
            new.add_media_reference(photo)

        # note
        note1 = self.p1.get_note_object()
        note2 = self.p2.get_note_object()
        new.set_note_object(self.merge_notes(note1, note2))
Exemplo n.º 3
0
    db.enable_signals()
    if commit:
        db.transaction_commit(tran, "Add Person")

def print_db_content(db):
    for h in db.get_person_handles():
        print "DB contains: person %s" % h
    for h in db.get_source_handles():
        print "DB contains: source %s" % h

tmpdir = tempfile.mkdtemp()
try:
    filename1 = os.path.join(tmpdir,'test1.grdb')
    filename2 = os.path.join(tmpdir,'test2.grdb')
    print "\nUsing Database file: %s" % filename1
    db = GrampsDb.gramps_db_factory(const.app_gramps)()
    db.load( filename1, dummy_callback, "w")
    print "Add person 1"
    add_person( db,"Anton", "Albers",True,False)
    print "Add source"
    add_source( db,"A short test",True,False)
    print "Add person 2 without commit"
    add_person( db,"Bernd","Beta",False,False)
    print "Add source"
    add_source( db,"A short test",True,False)
    print "Add person 3"
    add_person( db,"Chris","Connor",True,False)
    print_db_content( db)    
    print "Closing Database file: %s" % filename1
    #db.close()
Exemplo n.º 4
0
        db.transaction_commit(tran, "Add Person")


def print_db_content(db):
    for h in db.get_person_handles():
        print "DB contains: person %s" % h
    for h in db.get_source_handles():
        print "DB contains: source %s" % h


tmpdir = tempfile.mkdtemp()
try:
    filename1 = os.path.join(tmpdir, 'test1.grdb')
    filename2 = os.path.join(tmpdir, 'test2.grdb')
    print "\nUsing Database file: %s" % filename1
    db = GrampsDb.gramps_db_factory(const.app_gramps)()
    db.load(filename1, dummy_callback, "w")
    print "Add person 1"
    add_person(db, "Anton", "Albers", True, False)
    print "Add source"
    add_source(db, "A short test", True, False)
    print "Add person 2 without commit"
    add_person(db, "Bernd", "Beta", False, False)
    print "Add source"
    add_source(db, "A short test", True, False)
    print "Add person 3"
    add_person(db, "Chris", "Connor", True, False)
    print_db_content(db)
    print "Closing Database file: %s" % filename1
    #db.close()