Skip to content

Commit f21afef

Browse files
authored
chore: use set instead of list in list-translators
1 parent 492cfbe commit f21afef

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

list-translators.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
p = Path(r'.').glob('**/*.po')
88
pofiles = list(p)
99

10-
translators_credits_list = []
10+
translators_credits_set = set()
1111

1212
# Exclude bot account, duplicated entry and hashes for deleted accounts
1313
ignore_entries = [
@@ -37,19 +37,18 @@
3737
# if true, we are in the translator credits block; extract info
3838
if is_translator_credits:
3939
# remove leading sharp sign, and trailing comma and year
40-
line = line.strip('# ')
40+
line = line.strip('# ')
4141
line = line[:-7]
4242

4343
# Skip entries we do not want to add
4444
if line in ignore_entries:
4545
continue
4646

4747
# Add entry to the set
48-
if line not in translators_credits_list:
49-
translators_credits_list.append(line)
48+
translators_credits_set.add(line)
5049

5150
# if true, this is the start of the translation credits block;
52-
# flag is_translator_credits and go to the next line
51+
# flag is_translator_credits and go to the next line
5352
if line == '# Translators:\n':
5453
is_translator_credits = True
5554
continue
@@ -61,13 +60,10 @@
6160
if line == 'msgid "':
6261
break
6362

64-
# Remove parentheses that messes the reorder of the list.
65-
edit_index = translators_credits_list.index('(Douglas da Silva) <dementikovalev@yandex.ru>')
66-
translators_credits_list[edit_index] = 'Douglas da Silva <dementikovalev@yandex.ru>'
67-
68-
# Reordered in a case-insensitive way as some names were set lowercase
69-
translators_credits_list_reordered = sorted(translators_credits_list, key=str.casefold)
63+
# Remove parentheses that messes the alphabeticall order.
64+
translators_credits_set.remove('(Douglas da Silva) <dementikovalev@yandex.ru>')
65+
translators_credits_set.add('Douglas da Silva <dementikovalev@yandex.ru>')
7066

7167
# Print the resulting list to the standard output
72-
for t in translators_credits_list_reordered:
68+
for t in sorted(translators_credits_set):
7369
print(t)

0 commit comments

Comments
 (0)