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
43bc256a
Commit
43bc256a
authored
17 years ago
by
Bryan Tong Minh
Browse files
Options
Downloads
Patches
Plain Diff
Postpone initialization on closed wikis
parent
60f4c394
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
+45
-27
45 additions, 27 deletions
mwclient/client.py
with
45 additions
and
27 deletions
mwclient/client.py
+
45
−
27
View file @
43bc256a
...
@@ -60,33 +60,47 @@ class Site(object):
...
@@ -60,33 +60,47 @@ class Site(object):
self
.
connection
=
http
.
HTTPPool
()
self
.
connection
=
http
.
HTTPPool
()
else
:
else
:
self
.
connection
=
pool
self
.
connection
=
pool
self
.
Pages
=
listing
.
PageList
(
self
)
self
.
Categories
=
listing
.
PageList
(
self
,
namespace
=
14
)
self
.
Images
=
listing
.
PageList
(
self
,
namespace
=
6
)
self
.
namespaces
=
self
.
default_namespaces
self
.
initialized
=
False
if
do_init
:
if
do_init
:
meta
=
self
.
api
(
'
query
'
,
meta
=
'
siteinfo|userinfo
'
,
try
:
siprop
=
'
general|namespaces
'
,
uiprop
=
'
groups|rights
'
)
self
.
site_init
()
self
.
site
=
meta
[
'
query
'
][
'
general
'
]
except
errors
.
APIError
,
e
:
self
.
namespaces
=
dict
(((
i
[
'
id
'
],
i
.
get
(
'
*
'
,
''
))
for
i
in
meta
[
'
query
'
][
'
namespaces
'
].
itervalues
()))
# Private wiki, do init after login
if
e
[
0
]
!=
u
'
unknown_action
'
:
raise
if
self
.
site
[
'
generator
'
].
startswith
(
'
MediaWiki
'
):
def
site_init
(
self
):
version
=
self
.
site
[
'
generator
'
][
10
:].
split
(
'
.
'
)
meta
=
self
.
api
(
'
query
'
,
meta
=
'
siteinfo|userinfo
'
,
if
len
(
version
)
==
2
and
version
[
1
].
endswith
(
'
alpha
'
):
siprop
=
'
general|namespaces
'
,
uiprop
=
'
groups|rights
'
)
self
.
version
=
(
int
(
version
[
0
]),
int
(
version
[
1
][:
-
5
]),
'
alpha
'
)
self
.
site
=
meta
[
'
query
'
][
'
general
'
]
elif
len
(
version
)
==
3
:
self
.
namespaces
=
dict
(((
i
[
'
id
'
],
i
.
get
(
'
*
'
,
''
))
for
i
in
meta
[
'
query
'
][
'
namespaces
'
].
itervalues
()))
self
.
version
=
(
int
(
version
[
0
]),
int
(
version
[
1
]),
int
(
version
[
2
]))
else
:
if
self
.
site
[
'
generator
'
].
startswith
(
'
MediaWiki
'
):
raise
errors
.
MediaWikiVersionError
(
'
Unknown MediaWiki %s
'
%
'
.
'
.
join
(
version
))
version
=
self
.
site
[
'
generator
'
][
10
:].
split
(
'
.
'
)
if
len
(
version
)
==
2
and
version
[
1
].
endswith
(
'
alpha
'
):
self
.
version
=
(
int
(
version
[
0
]),
int
(
version
[
1
][:
-
5
]),
'
alpha
'
)
elif
len
(
version
)
==
3
:
self
.
version
=
(
int
(
version
[
0
]),
int
(
version
[
1
]),
int
(
version
[
2
]))
else
:
else
:
raise
errors
.
MediaWikiVersionError
(
'
Unknown generator %s
'
%
self
.
site
[
'
generator
'
])
raise
errors
.
MediaWikiVersionError
(
'
Unknown MediaWiki %s
'
%
'
.
'
.
join
(
version
))
# Require 1.11 until some compatibility issues are fixed
else
:
self
.
require
(
1
,
11
)
raise
errors
.
MediaWikiVersionError
(
'
Unknown generator %s
'
%
self
.
site
[
'
generator
'
])
# Require 1.11 until some compatibility issues are fixed
self
.
require
(
1
,
11
)
userinfo
=
compatibility
.
userinfo
(
meta
,
self
.
require
(
1
,
12
,
raise_error
=
False
))
userinfo
=
compatibility
.
userinfo
(
meta
,
self
.
require
(
1
,
12
,
raise_error
=
False
))
self
.
groups
=
userinfo
.
get
(
'
groups
'
,
[])
self
.
groups
=
userinfo
.
get
(
'
groups
'
,
[])
self
.
rights
=
userinfo
.
get
(
'
rights
'
,
[])
self
.
rights
=
userinfo
.
get
(
'
rights
'
,
[])
self
.
initialized
=
True
self
.
Pages
=
listing
.
PageList
(
self
)
self
.
Categories
=
listing
.
PageList
(
self
,
namespace
=
14
)
self
.
Images
=
listing
.
PageList
(
self
,
namespace
=
6
)
default_namespaces
=
{
0
:
u
''
,
1
:
u
'
Talk
'
,
2
:
u
'
User
'
,
3
:
u
'
User talk
'
,
4
:
u
'
Project
'
,
5
:
u
'
Project talk
'
,
default_namespaces
=
{
0
:
u
''
,
1
:
u
'
Talk
'
,
2
:
u
'
User
'
,
3
:
u
'
User talk
'
,
4
:
u
'
Project
'
,
5
:
u
'
Project talk
'
,
6
:
u
'
Image
'
,
7
:
u
'
Image talk
'
,
8
:
u
'
MediaWiki
'
,
9
:
u
'
MediaWiki talk
'
,
10
:
u
'
Template
'
,
11
:
u
'
Template talk
'
,
6
:
u
'
Image
'
,
7
:
u
'
Image talk
'
,
8
:
u
'
MediaWiki
'
,
9
:
u
'
MediaWiki talk
'
,
10
:
u
'
Template
'
,
11
:
u
'
Template talk
'
,
...
@@ -228,7 +242,7 @@ class Site(object):
...
@@ -228,7 +242,7 @@ class Site(object):
def
login
(
self
,
username
=
None
,
password
=
None
,
cookies
=
None
):
def
login
(
self
,
username
=
None
,
password
=
None
,
cookies
=
None
):
self
.
require
(
1
,
10
)
if
self
.
initialized
:
self
.
require
(
1
,
10
)
if
username
and
password
:
if
username
and
password
:
self
.
credentials
=
(
username
,
password
)
self
.
credentials
=
(
username
,
password
)
...
@@ -241,11 +255,15 @@ class Site(object):
...
@@ -241,11 +255,15 @@ class Site(object):
login
=
self
.
api
(
'
login
'
,
lgname
=
self
.
credentials
[
0
],
lgpassword
=
self
.
credentials
[
1
])
login
=
self
.
api
(
'
login
'
,
lgname
=
self
.
credentials
[
0
],
lgpassword
=
self
.
credentials
[
1
])
if
login
[
'
login
'
][
'
result
'
]
!=
'
Success
'
:
if
login
[
'
login
'
][
'
result
'
]
!=
'
Success
'
:
raise
errors
.
LoginError
(
self
,
login
[
'
login
'
])
raise
errors
.
LoginError
(
self
,
login
[
'
login
'
])
info
=
self
.
api
(
'
query
'
,
meta
=
'
userinfo
'
,
uiprop
=
'
groups|rights
'
)
userinfo
=
compatibility
.
userinfo
(
info
,
self
.
require
(
1
,
12
,
raise_error
=
False
))
if
self
.
initialized
:
self
.
groups
=
userinfo
.
get
(
'
groups
'
,
[])
info
=
self
.
api
(
'
query
'
,
meta
=
'
userinfo
'
,
uiprop
=
'
groups|rights
'
)
self
.
rights
=
userinfo
.
get
(
'
rights
'
,
[])
userinfo
=
compatibility
.
userinfo
(
info
,
self
.
require
(
1
,
12
,
raise_error
=
False
))
self
.
tokens
=
{}
self
.
groups
=
userinfo
.
get
(
'
groups
'
,
[])
self
.
rights
=
userinfo
.
get
(
'
rights
'
,
[])
self
.
tokens
=
{}
else
:
self
.
site_init
()
def
upload
(
self
,
file
,
filename
,
description
,
license
=
''
,
ignore
=
False
,
file_size
=
None
):
def
upload
(
self
,
file
,
filename
,
description
,
license
=
''
,
ignore
=
False
,
file_size
=
None
):
...
...
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