Beispiel #1
0
 def column_title(self, data):
     handle = data[0]
     cached, value = self.get_cached_value(handle, "PLACE")
     if not cached:
         place = Place()
         place.unserialize(data)
         value = place_displayer.display(self.db, place)
         self.set_cached_value(handle, "PLACE", value)
     return value
Beispiel #2
0
 def column_title(self, data):
     handle = data[0]
     cached, value = self.get_cached_value(handle, "PLACE")
     if not cached:
         place = Place()
         place.unserialize(data)
         value = place_displayer.display(self.db, place)
         self.set_cached_value(handle, "PLACE", value)
     return value
Beispiel #3
0
    def __get_level0(self):
        countries = []
        with self.dbstate.db.get_place_cursor() as cursor:
            pair = cursor.first()
            while pair:
                (handle, data) = pair
                print(pair)
                place = Place()
                place.unserialize(data)
                placetype = place.get_type().value
                print(placetype)
                #                if getattr(PlaceType, place['type']).upper() == PlaceType.COUNTRY:
                if placetype == PlaceType.COUNTRY:
                    print("Country found")
                    countries.append(place)
                pair = cursor.next()
#            print(countries)
        return countries
Beispiel #4
0
    def _process(self, count, total, sql):
        # ---------------------------------
        # Process note
        # ---------------------------------
        notes = sql.query("""select * from note;""")
        for note in notes:
            (handle, gid, text, _format, note_type1, note_type2, change,
             private) = note
            styled_text = [text, []]
            markups = sql.query(
                """select * from link where from_handle = ? """
                """and to_type = 'markup';""", handle)
            for markup_link in markups:
                _from_type, _from_handle, _to_type, to_handle = markup_link
                markup_detail = sql.query(
                    """select * from markup where handle = ?;""", to_handle)
                for markup in markup_detail:
                    (_mhandle, markup0, markup1, value,
                     start_stop_list) = markup
                    ss_list = eval(start_stop_list)
                    styled_text[1] += [((markup0, markup1), value, ss_list)]

            tags = self.get_links(sql, "note", handle, "tag")

            g_note = Note()
            g_note.unserialize(
                (handle, gid, styled_text, _format, (note_type1, note_type2),
                 change, tags, bool(private)))
            self.db.add_note(g_note, self.trans)
            count += 1
            self.callback(100 * count / total)

        # ---------------------------------
        # Process event
        # ---------------------------------
        events = sql.query("""select * from event;""")
        for event in events:
            (handle, gid, the_type0, the_type1, description, change,
             private) = event

            note_list = self.get_note_list(sql, "event", handle)
            citation_list = self.get_citation_list(sql, "event", handle)
            media_list = self.get_media_list(sql, "event", handle)
            attribute_list = self.get_attribute_list(sql, "event", handle)

            date_handle = self.get_link(sql, "event", handle, "date")
            date = self.get_date(sql, date_handle)

            place_handle = self.get_link(sql, "event", handle, "place")
            place = self.get_place_from_handle(sql, place_handle)

            tags = self.get_links(sql, "event", handle, "tag")
            data = (handle, gid, (the_type0, the_type1), date, description,
                    place, citation_list, note_list, media_list,
                    attribute_list, change, tags, bool(private))

            g_event = Event()
            g_event.unserialize(data)
            self.db.add_event(g_event, self.trans)

            count += 1
            self.callback(100 * count / total)

        # ---------------------------------
        # Process person
        # ---------------------------------
        people = sql.query("""select * from person;""")
        for person in people:
            if person is None:
                continue
            (
                handle,  # 0
                gid,  # 1
                gender,  # 2
                death_ref_handle,  # 5
                birth_ref_handle,  # 6
                change,  # 17
                private,  # 19
            ) = person
            primary_name = self.get_names(sql, "person", handle, True)  # one
            alternate_names = self.get_names(sql, "person", handle, False)
            event_ref_list = self.get_event_ref_list(sql, "person", handle)
            family_list = self.get_family_list(sql, "person", handle)
            parent_family_list = self.get_parent_family_list(
                sql, "person", handle)
            media_list = self.get_media_list(sql, "person", handle)
            address_list = self.get_address_list(sql,
                                                 "person",
                                                 handle,
                                                 with_parish=False)
            attribute_list = self.get_attribute_list(sql, "person", handle)
            urls = self.get_url_list(sql, "person", handle)
            lds_ord_list = self.get_lds_list(sql, "person", handle)
            pcitation_list = self.get_citation_list(sql, "person", handle)
            pnote_list = self.get_note_list(sql, "person", handle)
            person_ref_list = self.get_person_ref_list(sql, "person", handle)
            death_ref_index = lookup(death_ref_handle, event_ref_list)
            birth_ref_index = lookup(birth_ref_handle, event_ref_list)
            tags = self.get_links(sql, "person", handle, "tag")

            data = (
                handle,  # 0
                gid,  # 1
                gender,  # 2
                primary_name,  # 3
                alternate_names,  # 4
                death_ref_index,  # 5
                birth_ref_index,  # 6
                event_ref_list,  # 7
                family_list,  # 8
                parent_family_list,  # 9
                media_list,  # 10
                address_list,  # 11
                attribute_list,  # 12
                urls,  # 13
                lds_ord_list,  # 14
                pcitation_list,  # 15
                pnote_list,  # 16
                change,  # 17
                tags,
                bool(private),  # 19
                person_ref_list,
            )  # 20

            g_pers = Person()
            g_pers.unserialize(data)
            self.db.add_person(g_pers, self.trans)
            count += 1
            self.callback(100 * count / total)
        # ---------------------------------
        # Process family
        # ---------------------------------
        families = sql.query("""select * from family;""")
        for family in families:
            (handle, gid, father_handle, mother_handle, the_type0, the_type1,
             change, private) = family

            child_ref_list = self.get_child_ref_list(sql, "family", handle)
            event_ref_list = self.get_event_ref_list(sql, "family", handle)
            media_list = self.get_media_list(sql, "family", handle)
            attribute_list = self.get_attribute_list(sql, "family", handle)
            lds_seal_list = self.get_lds_list(sql, "family", handle)
            citation_list = self.get_citation_list(sql, "family", handle)
            note_list = self.get_note_list(sql, "family", handle)
            tags = self.get_links(sql, "family", handle, "tag")

            data = (handle, gid, father_handle, mother_handle, child_ref_list,
                    (the_type0, the_type1), event_ref_list, media_list,
                    attribute_list, lds_seal_list, citation_list, note_list,
                    change, tags, private)
            g_fam = Family()
            g_fam.unserialize(data)
            self.db.add_family(g_fam, self.trans)

            count += 1
            self.callback(100 * count / total)
        # ---------------------------------
        # Process repository
        # ---------------------------------
        repositories = sql.query("""select * from repository;""")
        for repo in repositories:
            (handle, gid, the_type0, the_type1, name, change, private) = repo

            note_list = self.get_note_list(sql, "repository", handle)
            address_list = self.get_address_list(sql,
                                                 "repository",
                                                 handle,
                                                 with_parish=False)
            urls = self.get_url_list(sql, "repository", handle)
            tags = self.get_links(sql, "repository", handle, "tag")
            data = (handle, gid, (the_type0, the_type1), name, note_list,
                    address_list, urls, change, tags, private)
            g_rep = Repository()
            g_rep.unserialize(data)
            self.db.add_repository(g_rep, self.trans)
            count += 1
            self.callback(100 * count / total)
        # ---------------------------------
        # Process place
        # ---------------------------------
        places = sql.query("""select * from place;""")
        for place in places:
            count += 1
            (handle, gid, title, value, the_type0, the_type1, code, long, lat,
             lang, change, private) = place

            # We could look this up by "place_main", but we have the handle:
            #main_loc = self.get_main_location(sql, handle, with_parish=True)
            alt_loc_list = self.get_location_list(sql,
                                                  "place_alt",
                                                  handle,
                                                  with_parish=True)
            urls = self.get_url_list(sql, "place", handle)
            media_list = self.get_media_list(sql, "place", handle)
            citation_list = self.get_citation_list(sql, "place", handle)
            note_list = self.get_note_list(sql, "place", handle)
            tags = self.get_links(sql, "place", handle, "tag")
            place_type = (the_type0, the_type1)
            alt_place_name_list = self.get_alt_place_name_list(sql, handle)
            place_ref_list = self.get_place_ref_list(sql, handle)
            data = (handle, gid, title, long, lat, place_ref_list,
                    PlaceName(value=value,
                              lang=lang).serialize(), alt_place_name_list,
                    place_type, code, alt_loc_list, urls, media_list,
                    citation_list, note_list, change, tags, private)
            g_plac = Place()
            g_plac.unserialize(data)
            self.db.commit_place(g_plac, self.trans)
            self.callback(100 * count / total)

        # ---------------------------------
        # Process citation
        # ---------------------------------
        citations = sql.query("""select * from citation;""")
        for citation in citations:
            (handle, gid, confidence, page, source_handle, change,
             private) = citation
            date_handle = self.get_link(sql, "citation", handle, "date")
            date = self.get_date(sql, date_handle)
            note_list = self.get_note_list(sql, "citation", handle)
            media_list = self.get_media_list(sql, "citation", handle)
            datamap = self.get_datamap_list(sql, "citation", handle)
            tags = self.get_links(sql, "citation", handle, "tag")
            data = (handle, gid, date, page, confidence, source_handle,
                    note_list, media_list, datamap, change, tags, private)
            g_cit = Citation()
            g_cit.unserialize(data)
            self.db.commit_citation(g_cit, self.trans)
            count += 1
            self.callback(100 * count / total)

        # ---------------------------------
        # Process source
        # ---------------------------------
        sources = sql.query("""select * from source;""")
        for source in sources:
            (handle, gid, title, author, pubinfo, abbrev, change,
             private) = source
            note_list = self.get_note_list(sql, "source", handle)
            media_list = self.get_media_list(sql, "source", handle)
            datamap = self.get_datamap_list(sql, "source", handle)
            reporef_list = self.get_repository_ref_list(sql, "source", handle)
            tags = self.get_links(sql, "source", handle, "tag")

            data = (handle, gid, title, author, pubinfo, note_list, media_list,
                    abbrev, change, datamap, reporef_list, tags, private)
            g_src = Source()
            g_src.unserialize(data)
            self.db.commit_source(g_src, self.trans)
            count += 1
            self.callback(100 * count / total)
        # ---------------------------------
        # Process media
        # ---------------------------------
        media = sql.query("""select * from media;""")
        for med in media:
            (handle, gid, path, mime, desc, checksum, change, private) = med

            attribute_list = self.get_attribute_list(sql, "media", handle)
            citation_list = self.get_citation_list(sql, "media", handle)
            note_list = self.get_note_list(sql, "media", handle)

            date_handle = self.get_link(sql, "media", handle, "date")
            date = self.get_date(sql, date_handle)
            tags = self.get_links(sql, "media", handle, "tag")

            data = (handle, gid, path, mime, desc, checksum, attribute_list,
                    citation_list, note_list, change, date, tags, private)
            g_med = Media()
            g_med.unserialize(data)
            self.db.commit_media(g_med, self.trans)
            count += 1
            self.callback(100 * count / total)
        # ---------------------------------
        # Process tag
        # ---------------------------------
        tags = sql.query("""select * from tag;""")
        for tag in tags:
            (handle, name, color, priority, change) = tag

            data = (handle, name, color, priority, change)
            g_tag = Tag()
            g_tag.unserialize(data)
            self.db.commit_tag(g_tag, self.trans)
            count += 1
            self.callback(100 * count / total)
Beispiel #5
0
 def column_title(self, data):
     place = Place()
     place.unserialize(data)
     return place_displayer.display(self.db, place)
Beispiel #6
0
 def column_title(self, data):
     place = Place()
     place.unserialize(data)
     return place_displayer.display(self.db, place)