Merge pull request #441 from Pokechu22/mwclient-session

Pass requests session to mwclient
pull/442/head
nemobis 2 years ago committed by GitHub
commit 25329be008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -258,7 +258,7 @@ def getPageTitlesAPI(config={}, session=None):
c = 0 c = 0
print ' Retrieving titles in the namespace %d' % (namespace) print ' Retrieving titles in the namespace %d' % (namespace)
apiurl = urlparse(config['api']) apiurl = urlparse(config['api'])
site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme) site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme, pool=session)
for page in site.allpages(namespace=namespace): for page in site.allpages(namespace=namespace):
title = page.name title = page.name
titles.append(title) titles.append(title)
@ -798,7 +798,7 @@ def getXMLRevisions(config={}, session=None, allpages=False, start=None):
apiurl = urlparse(config['api']) apiurl = urlparse(config['api'])
# FIXME: force the protocol we asked for! Or don't verify SSL if we asked HTTP? # FIXME: force the protocol we asked for! Or don't verify SSL if we asked HTTP?
# https://github.com/WikiTeam/wikiteam/issues/358 # https://github.com/WikiTeam/wikiteam/issues/358
site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme) site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme, pool=session)
if not 'all' in config['namespaces']: if not 'all' in config['namespaces']:
namespaces = config['namespaces'] namespaces = config['namespaces']
@ -1959,7 +1959,7 @@ def checkRetryAPI(api=None, retries=5, apiclient=False, session=None):
if check and apiclient: if check and apiclient:
apiurl = urlparse(api) apiurl = urlparse(api)
try: try:
site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme) site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme, pool=session)
except KeyError: except KeyError:
# Probably KeyError: 'query' # Probably KeyError: 'query'
if apiurl.scheme == "https": if apiurl.scheme == "https":
@ -1971,7 +1971,7 @@ def checkRetryAPI(api=None, retries=5, apiclient=False, session=None):
print("WARNING: The provided API URL did not work with mwclient. Switched protocol to: {}".format(newscheme)) print("WARNING: The provided API URL did not work with mwclient. Switched protocol to: {}".format(newscheme))
try: try:
site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=newscheme) site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=newscheme, pool=session)
except KeyError: except KeyError:
check = False check = False

Loading…
Cancel
Save