Coverage for app/venv/lib/python3.14/site-packages/weblate/checks/angularjs.py: 92%

13 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# Copyright © Philipp Wolfer <ph.wolfer@gmail.com> 

3# 

4# SPDX-License-Identifier: GPL-3.0-or-later 

5 

6from __future__ import annotations 

7 

8import re 

9 

10from django.utils.translation import gettext_lazy 

11 

12from .format import BaseFormatCheck 

13 

14ANGULARJS_INTERPOLATION_MATCH = re.compile( 

15 r""" 

16 {{ # start symbol 

17 \s* # ignore whitespace 

18 ((.+?)) 

19 \s* # ignore whitespace 

20 }} # end symbol 

21 """, 

22 re.VERBOSE, 

23) 

24 

25WHITESPACE = re.compile(r"\s+") 

26 

27 

28class AngularJSInterpolationCheck(BaseFormatCheck): 

29 """Check for AngularJS interpolation string.""" 

30 

31 check_id = "angularjs_format" 

32 name = gettext_lazy("AngularJS interpolation string") 

33 description = gettext_lazy("AngularJS interpolation strings do not match source.") 

34 regexp = ANGULARJS_INTERPOLATION_MATCH 

35 

36 def cleanup_string(self, text: str) -> str: 

37 return WHITESPACE.sub("", text)