Coverage for src/robotide/localization/tr_credits.py: 100%
24 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# -*- coding: utf-8 -*-
2# Copyright 2024- Robot Framework Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
16from os.path import abspath, join, dirname
17import re
20def tr_credits(filename="TRANSLATORS.adoc"):
21 """ Returns the list of translators taken from TRANSLATORS.adoc to be used in About dialog."""
23 # Added parameter filename because of unit tests
24 isref = re.compile("(http.*)(\\[.*])(:)(.*)") 1abcdefg
25 try: 1abcdefg
26 with open(join(dirname(abspath(__file__)), filename), 'r', encoding='utf-8') as trf: 1abcdefg
27 content = trf.readlines() 1abcdef
28 except FileNotFoundError: 1g
29 return "" 1g
30 lines = [] 1abcdef
31 lines += ["<ul>\n"] 1abcdef
32 for tr in content: 1abcdef
33 if tr.startswith('-'): 1abcdef
34 row = tr.strip('- ') 1abcdef
35 href = isref.findall(row) 1abcdef
36 if href: 1abcdef
37 href = href[0] 1abcdef
38 url = href[0] 1abcdef
39 name = href[1].strip('[]') 1abcdef
40 langs = href[-1].strip() 1abcdef
41 row = f'<a href="{url}">{name}</a>: {langs}' 1abcdef
42 lines += [f"<li>{row.strip()}</li>\n"] 1abcdef
43 lines += ["</ul>"] 1abcdef
45 return "".join(lines) 1abcdef