• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rero / rero-mef / 16621609190

30 Jul 2025 11:43AM UTC coverage: 84.491% (+0.008%) from 84.483%
16621609190

push

github

rerowep
chore: update dependencies

Co-Authored-by: Peter Weber <peter.weber@rero.ch>

4560 of 5397 relevant lines covered (84.49%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.11
/rero_mef/places/gnd/api.py
1
# RERO MEF
2
# Copyright (C) 2024 RERO
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU Affero General Public License as published by
6
# the Free Software Foundation, version 3 of the License.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU Affero General Public License for more details.
12
#
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15

16
"""API for manipulating Gnd agent."""
17

18
from invenio_search.api import RecordsSearch
1✔
19

20
from rero_mef.places.api import PlaceIndexer, PlaceRecord
1✔
21

22
from .fetchers import gnd_id_fetcher
1✔
23
from .minters import gnd_id_minter
1✔
24
from .models import PlaceGndMetadata
1✔
25
from .providers import PlaceGndProvider
1✔
26

27

28
class PlaceGndSearch(RecordsSearch):
1✔
29
    """RecordsSearch."""
30

31
    class Meta:
1✔
32
        """Search only on index."""
33

34
        index = "places_gnd"
1✔
35
        doc_types = None
1✔
36
        fields = ("*",)
1✔
37
        facets = {}
1✔
38

39
        default_filter = None
1✔
40

41

42
class PlaceGndRecord(PlaceRecord):
1✔
43
    """Places Authority class."""
44

45
    minter = gnd_id_minter
1✔
46
    fetcher = gnd_id_fetcher
1✔
47
    provider = PlaceGndProvider
1✔
48
    name = "gnd"
1✔
49
    viaf_source_code = "RAMEAU"
1✔
50
    pid_type = "place_gnd_pid"
1✔
51
    model_cls = PlaceGndMetadata
1✔
52
    search = PlaceGndSearch
1✔
53

54
    @classmethod
1✔
55
    def get_online_record(cls, id_, debug=False):
1✔
56
        """Get online Record.
57

58
        :param id_: Id of online record.
59
        :param debug: Debug print.
60
        :returns: record or None
61
        """
62
        from .tasks import gnd_get_record
×
63

64
        return gnd_get_record(id_=id_, debug=debug)
×
65

66
    @property
1✔
67
    def association_identifier(self):
1✔
68
        """Get associated identifier."""
69
        return self.pid
1✔
70

71
    @property
1✔
72
    def association_info(self):
1✔
73
        """Get associated record."""
74
        from rero_mef.places import PlaceIdrefRecord, PlaceIdrefSearch, PlaceMefRecord
1✔
75

76
        PlaceIdrefRecord.flush_indexes()
1✔
77
        return {
1✔
78
            "identifier": self.association_identifier,
79
            "record": self.get_association_record(
80
                association_cls=PlaceIdrefRecord, association_search=PlaceIdrefSearch
81
            ),
82
            "record_cls": PlaceIdrefRecord,
83
            "search_cls": PlaceIdrefSearch,
84
            "mef_cls": PlaceMefRecord,
85
        }
86

87

88
class PlaceGndIndexer(PlaceIndexer):
1✔
89
    """Place GND indexer."""
90

91
    record_cls = PlaceGndRecord
1✔
92

93
    def bulk_index(self, record_id_iterator):
1✔
94
        """Bulk index records.
95

96
        :param record_id_iterator: Iterator yielding record UUIDs.
97
        """
98
        super().bulk_index(
×
99
            record_id_iterator, index=PlaceGndSearch.Meta.index, doc_type="plgnd"
100
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc