You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am still trying to migrate a python 2.7 script to python3, using wikitools3, as in issues #8 and #9. in fact I now using the local branch I made that seems to fix my problem in #9.
This time my script is also attempting to access a page from my wiki :
#!/usr/bin/env python""" quick and dirty script aimed at debugging wikitools3 """""" see issues https://github.com/mediawiki-client-tools/wikitools3/issues """importosfromwikitools3importwiki, page# now I am using my company's wiki apiapi_url=os.environ.get('WIKI_URL')
username=os.environ.get('WIKI_USER')
password=os.environ.get('WIKI_PASSWORD')
print("api_url: "+str(api_url) +" username: "+username)
ifnotpassword:
print("Empty variable: WIKI_PASSWORD")
sys.exit(1)
site=wiki.Wiki(api_url, username, password, True)
# This "Test title" page does not exist but I get the same result with existing titlesp=page.Page(site, "Test title")
It fails like this:
Traceback (most recent call last):
File "./test_wikitools.py", line 17, in <module>
p = page.Page(site, "test title")
File "/workdir/wikitools3/page.py", line 132, in __init__
self.setPageInfo()
File "/workdir/wikitools3/page.py", line 169, in setPageInfo
self.pageid = response["query"]["pages"].keys()[0]
TypeError: 'dict_keys' object is not subscriptable
I suggest the following patch for page.py line 169:
The call to list() solves the TypeError: 'dict_keys' object is not subscriptable, and the call to int() averts a TypeError: '>' not supported between instances of 'str' and 'int' at line 170.
The text was updated successfully, but these errors were encountered:
lcoustillac
added a commit
to lcoustillac/wikitools3
that referenced
this issue
Nov 6, 2023
Hi, I am still trying to migrate a python 2.7 script to python3, using wikitools3, as in issues #8 and #9. in fact I now using the local branch I made that seems to fix my problem in #9.
This time my script is also attempting to access a page from my wiki :
It fails like this:
I suggest the following patch for page.py line 169:
The call to list() solves the
TypeError: 'dict_keys' object is not subscriptable
, and the call to int() averts aTypeError: '>' not supported between instances of 'str' and 'int'
at line 170.The text was updated successfully, but these errors were encountered: