Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf21afef

Browse files
authored
chore: use set instead of list in list-translators
1 parent492cfbe commitf21afef

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
ifis_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
iflineinignore_entries:
4545
continue
4646

4747
# Add entry to the set
48-
iflinenotintranslators_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
ifline=='# Translators:\n':
5453
is_translator_credits=True
5554
continue
@@ -61,13 +60,10 @@
6160
ifline=='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-
fortintranslators_credits_list_reordered:
68+
fortinsorted(translators_credits_set):
7369
print(t)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp