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

rero / sonar / 17425918180

03 Sep 2025 07:11AM UTC coverage: 95.796% (-0.6%) from 96.378%
17425918180

push

github

PascalRepond
translations: extract messages

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>

7816 of 8159 relevant lines covered (95.8%)

0.96 hits per line

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

94.44
/sonar/modules/documents/ext.py
1
# Swiss Open Access Repository
2
# Copyright (C) 2021 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
"""Document extension."""
17

18
from invenio_base.signals import app_loaded
1✔
19
from invenio_oaiharvester.signals import oaiharvest_finished
1✔
20

21
from sonar.modules.documents.receivers import (
1✔
22
    export_json,
23
    set_boosting_query_fields,
24
    transform_harvested_records,
25
)
26

27
from . import config
1✔
28

29

30
class Documents:
1✔
31
    """SONAR documents extension."""
32

33
    def __init__(self, app=None):
1✔
34
        """Extension initialization."""
35
        if app:
1✔
36
            self.init_app(app)
1✔
37

38
    def init_app(self, app):
1✔
39
        """Flask application initialization."""
40
        self.init_config(app)
1✔
41
        app.extensions["sonar_documents"] = self
1✔
42

43
        # Connect to oaiharvester signal
44
        oaiharvest_finished.connect(transform_harvested_records, weak=False)
1✔
45
        oaiharvest_finished.connect(export_json, weak=False)
1✔
46

47
        # Expand configuration.
48
        app_loaded.connect(set_boosting_query_fields)
1✔
49

50
    def init_config(self, app):
1✔
51
        """Initialize configuration."""
52
        for k in dir(app.config):
1✔
53
            if k.startswith("SONAR_DOCUMENTS_"):
1✔
54
                app.config.setdefault(k, getattr(config, k))
×
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