Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F32455073
find_collations.py
RLazarus (Reuven Lazarus) (rzl)
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
RLazarus
Nov 6 2020, 9:10 PM
2020-11-06 21:10:58 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
find_collations.py
View Options
import
sys
from
typing
import
Dict
,
List
import
requests
def
wikis_with_collations
()
->
List
[
str
]:
wikis
=
[]
SETTINGS_URL
=
'https://noc.wikimedia.org/conf/InitialiseSettings.php.txt'
settings_lines
=
requests
.
get
(
SETTINGS_URL
)
.
text
.
splitlines
()
start_index
=
settings_lines
.
index
(
"'wgCategoryCollation' => ["
)
+
1
end_index
=
settings_lines
.
index
(
'],'
,
start_index
)
for
line
in
settings_lines
[
start_index
:
end_index
]:
try
:
line
=
line
[:
line
.
index
(
'//'
)]
except
ValueError
:
pass
line
=
line
.
strip
()
if
not
line
:
continue
wiki
,
collation
=
line
.
split
(
' => '
)
wiki
=
wiki
[
1
:
-
1
]
# Strip quotes.
collation
=
collation
[
1
:
-
2
]
# Strip quotes and trailing comma.
if
wiki
==
'default'
:
continue
wikis
.
append
(
wiki
)
return
wikis
def
all_sections
()
->
Dict
[
str
,
str
]:
'''Returns: {'enwiki': 's1', 'bgwiki': 's2', 'bgwiktionary': 's2', ...}'''
result
=
{}
SECTIONS
=
[
f
's{i}'
for
i
in
range
(
1
,
9
)]
for
section
in
SECTIONS
:
dbs
=
requests
.
get
(
f
'https://noc.wikimedia.org/conf/dblists/{section}.dblist'
)
.
text
for
line
in
dbs
.
splitlines
():
if
line
.
startswith
(
'#'
):
continue
result
[
line
]
=
section
return
result
def
main
()
->
int
:
wikis_with_collations_by_section
=
{}
sections
=
all_sections
()
for
wiki
in
wikis_with_collations
():
wikis_with_collations_by_section
.
setdefault
(
sections
[
wiki
],
[])
.
append
(
wiki
)
for
section
in
sorted
(
wikis_with_collations_by_section
):
print
(
f
'{section}:'
)
print
(
' '
+
' '
.
join
(
wikis_with_collations_by_section
[
section
]))
return
0
if
__name__
==
'__main__'
:
sys
.
exit
(
main
())
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
8616236
Default Alt Text
find_collations.py (1 KB)
Attached To
Mode
T264991: Upgrade the MediaWiki servers to ICU 63
Attached
Detach File
Event Timeline
Log In to Comment