Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mwclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WebU
shared
mwclient
Commits
f32efc16
Commit
f32efc16
authored
10 years ago
by
Dan Michael O. Heggø
Browse files
Options
Downloads
Patches
Plain Diff
[#69] Add docstring for Site.api()
parent
40b13090
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mwclient/client.py
+17
-1
17 additions, 1 deletion
mwclient/client.py
with
17 additions
and
1 deletion
mwclient/client.py
+
17
−
1
View file @
f32efc16
...
@@ -161,7 +161,23 @@ class Site(object):
...
@@ -161,7 +161,23 @@ class Site(object):
return
"
<Site object
'
%s%s
'
>
"
%
(
self
.
host
,
self
.
path
)
return
"
<Site object
'
%s%s
'
>
"
%
(
self
.
host
,
self
.
path
)
def
api
(
self
,
action
,
*
args
,
**
kwargs
):
def
api
(
self
,
action
,
*
args
,
**
kwargs
):
"""
An API call. Handles errors and returns dict object.
"""
"""
Perform a generic API call and handle errors. All arguments will be passed on.
Example:
To get coordinates from the GeoData MediaWiki extension at English Wikipedia:
>>>
site
=
Site
(
'
en.wikipedia.org
'
)
>>>
result
=
site
.
api
(
'
query
'
,
prop
=
'
coordinates
'
,
titles
=
'
Oslo|Copenhagen
'
)
>>>
for
page
in
result
[
'
query
'
][
'
pages
'
].
values
():
...
if
'
coordinates
'
in
page
:
...
print
page
[
'
title
'
],
page
[
'
coordinates
'
][
0
][
'
lat
'
],
page
[
'
coordinates
'
][
0
][
'
lon
'
]
Oslo
59.95
10.75
Copenhagen
55.6761
12.5683
Returns:
The raw response from the API call, as a dictionary.
"""
kwargs
.
update
(
args
)
kwargs
.
update
(
args
)
if
action
==
'
query
'
:
if
action
==
'
query
'
:
if
'
meta
'
in
kwargs
:
if
'
meta
'
in
kwargs
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment