Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F36948310
purge-all-in-namespace.py
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Lucas_Werkmeister_WMDE
Apr 12 2023, 2:07 PM
2023-04-12 14:07:59 (UTC+0)
Size
908 B
Referenced Files
None
Subscribers
None
purge-all-in-namespace.py
View Options
#!/usr/bin/env python3
# based on https://github.com/lucaswerkmeister/tool-lexeme-forms/blob/282a7b6b186e32cbb92101500a8690470c179f64/purge-all-lexemes.py
import
time
import
mwapi
wiki
=
'ks.wikipedia.org'
namespace
=
828
user_agent
=
'purge-all-in-namespace (Lucas Werkmeister; mail@lucaswerkmeister.de)'
session
=
mwapi
.
Session
(
host
=
f
'https://{wiki}'
,
user_agent
=
user_agent
)
for
result
in
session
.
post
(
action
=
'purge'
,
generator
=
'allpages'
,
gapnamespace
=
namespace
,
gaplimit
=
30
,
# rate limit permits 30 purges per 60 seconds
forcelinkupdate
=
True
,
continuation
=
True
):
pages
=
result
[
'purge'
]
first_title
=
pages
[
0
][
'title'
]
last_title
=
pages
[
-
1
][
'title'
]
print
(
f
'Purged {first_title:>32} ... {last_title:>32}'
,
flush
=
True
)
time
.
sleep
(
75
)
# rate limit permits 30 purges per 60 seconds, +15s for some buffer
print
(
'Done.'
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10796494
Default Alt Text
purge-all-in-namespace.py (908 B)
Attached To
Mode
P46551 purge-all-in-namespace.py
Attached
Detach File
Event Timeline
Log In to Comment