Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4161008
Proof of Concept: thanks_rev() for test:test
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
darthbhyrava
Jun 13 2016, 2:10 PM
2016-06-13 14:10:12 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
Proof of Concept: thanks_rev() for test:test
View Options
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
A script which takes a revision ID on the test wiki and thanks it on behalf of the user logged in.
Syntax: python pwb.py thanks [rev]
@params;
-rev: - The value of the revisionID to be thanked.
"""
from
__future__
import
absolute_import
,
unicode_literals
import
pywikibot
from
pywikibot.comms.http
import
session
def
thank_rev
(
rev_id
):
"""
Thank the given revision ID on the wiki on behalf of the user logged in.
"""
#Login into the wiki
site
=
pywikibot
.
Site
()
site
.
login
()
#Get csrf token from site.
token
=
site
.
tokens
[
'csrf'
]
#Make the Thanks API call.
values
=
{
'rev'
:
rev_id
,
'source'
:
'test_thank'
,
'token'
:
token
}
r
=
session
.
post
(
"https://test.wikipedia.org/w/api.php?action=thank&format=json"
,
data
=
values
)
print
(
r
.
text
)
def
main
(
*
args
):
"""
Proces command line arguments and thank the rev
"""
# Process the args
local_args
=
pywikibot
.
handle_args
(
args
)
for
arg
in
local_args
:
option
,
sep
,
value
=
arg
.
partition
(
':'
)
if
option
==
'-rev'
:
rev_id
=
int
(
value
)
#Call the thank method
thank_rev
(
rev_id
)
if
__name__
==
"__main__"
:
main
()
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3795176
Default Alt Text
Proof of Concept: thanks_rev() for test:test (1 KB)
Attached To
Mode
P3234 Proof of Concept: thanks_rev() for test:test
Attached
Detach File
Event Timeline
Log In to Comment