Skip to content

Renaming wikitools for Python 3 to wikitools_py3 #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: py3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wikitools -- Package for working with MediaWiki wikis
wikitools_py3 -- Package for working with MediaWiki wikis

Requirements
------------
Expand All @@ -11,7 +11,7 @@ Requirements
Installation
------------

* Run "python setup.py install" or copy the wikitools directory
* Run "python setup.py install" or copy the wikitools_py3 directory
to an appropriate Python module directory.
* An exe installer for Windows is also available (should be run as an
administrator to avoid errors)
Expand Down Expand Up @@ -59,8 +59,8 @@ To make a simple query:
```python
#!/usr/bin/python

from wikitools import wiki
from wikitools import api
from wikitools_py3 import wiki
from wikitools_py3 import api

# create a Wiki object
site = wiki.Wiki("http://my.wikisite.org/w/api.php")
Expand Down Expand Up @@ -93,8 +93,8 @@ pages in namespace 0 in a category:
```python
#!/usr/bin/python

from wikitools import wiki
from wikitools import category
from wikitools_py3 import wiki
from wikitools_py3 import category

site = wiki.Wiki("http://my.wikisite.org/w/api.php")
site.login("username", "password")
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from distutils.core import setup

setup(name='wikitools',
setup(name='wikitools_py3',
version='1.2',
description='Python package for interacting with a MediaWiki wiki',
long_description = """A Python package for interacting with a MediaWiki wiki using the MediaWiki API.
Expand All @@ -13,6 +13,6 @@
author_email='[email protected]',
url='https://github.com/alexz-enwp/wikitools',
license='GPL v3',
packages=['wikitools'],
package_data={'wikitools': ['COPYING']}
packages=['wikitools_py3'],
package_data={'wikitools_py3': ['COPYING']}
)
28 changes: 14 additions & 14 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import unittest
from wikitools import api
from wikitools import wiki
from wikitools import page
from wikitools import category
from wikitools import wikifile
from wikitools import user
from wikitools import pagelist
import wikitools.exceptions
from wikitools_py3 import api
from wikitools_py3 import wiki
from wikitools_py3 import page
from wikitools_py3 import category
from wikitools_py3 import wikifile
from wikitools_py3 import user
from wikitools_py3 import pagelist
import wikitools_py3.exceptions
import warnings
import requests.exceptions
import os
Expand Down Expand Up @@ -132,8 +132,8 @@ def test_logout(self):
def test_hash(self):
newsite = wiki.Wiki('http://localhost/w/api.php')
d = {self.site : 'Foo' }
self.assertTrue(newsite in d.keys())
self.assertTrue(newsite in d.keys())

def test_equality(self):
newsite = wiki.Wiki('http://localhost/w/api.php')
othersite = wiki.Wiki('https://en.wikipedia.org/w/api.php')
Expand Down Expand Up @@ -244,12 +244,12 @@ def test_setNamespace(self):
def test_setSection_valid_name(self):
p1 = page.Page(self.site, "Page")
p1.setSection("Section 1")
self.assertEqual(p1.section, 1)
self.assertEqual(p1.section, 1)

def test_setSection_invalid_name(self):
p1 = page.Page(self.site, "Page")
p1.setSection("Section Q")
self.assertIs(p1.section, None)
self.assertIs(p1.section, None)

def test_toggleTalk(self):
p1 = page.Page(self.site, "Page")
Expand Down Expand Up @@ -534,13 +534,13 @@ def test_constructor_notexists(self):
api.logging = True
u1 = user.User(self.site, "Doesn't exist")
self.assertEqual(len(api.querylog), 1)
self.assertFalse(u1.exists)
self.assertFalse(u1.exists)

def test_constructor_blocked(self):
api.logging = True
u1 = user.User(self.site, "Vandal1")
self.assertEqual(len(api.querylog), 1)
self.assertTrue(u1.blocked)
self.assertTrue(u1.blocked)

def test_isblocked(self):
api.logging = True
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions wikitools/category.py → wikitools_py3/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with wikitools. If not, see <http://www.gnu.org/licenses/>.

from wikitools.pagelist import makePage
from wikitools_py3.pagelist import makePage
from . import api
from . import page

Expand Down Expand Up @@ -111,4 +111,3 @@ def __getattr__(self, name):
if name != 'members':
return super().__getattr__(name)
return self.getAllMembers()

File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 6 additions & 7 deletions wikitools/pagelist.py → wikitools_py3/pagelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with wikitools. If not, see <http://www.gnu.org/licenses/>.

import wikitools
import wikitools_py3

def listFromQuery(site, queryresult):
"""Generate a list of Pages from an API query result
Expand Down Expand Up @@ -46,7 +46,7 @@ def listFromTextList(site, sequence, datatype, check=True, followRedir=False):
if datatype == 'pageids':
sequence = [int(i) for i in sequence]
opt = datatype[:-1]
return [wikitools.page.Page(site, check=False, followRedir=followRedir, **{opt:item}) for item in sequence]
return [wikitools_py3.page.Page(site, check=False, followRedir=followRedir, **{opt:item}) for item in sequence]
start = 0
end = 0
ret = []
Expand All @@ -61,7 +61,7 @@ def listFromTextList(site, sequence, datatype, check=True, followRedir=False):
}
if followRedir:
params['redirects'] = ''
req = wikitools.api.APIRequest(site, params)
req = wikitools_py3.api.APIRequest(site, params)
res = req.query(False)
for key in res['query']['pages']:
obj = res['query']['pages'][key]
Expand Down Expand Up @@ -114,14 +114,13 @@ def makePage(result, site, followRedir):
if 'pageid' in result and result['pageid'] > 0:
pageid = result['pageid']
if ns == site.NS_CATEGORY:
item = wikitools.category.Category(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
item = wikitools_py3.category.Category(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
elif ns == site.NS_FILE:
item = wikitools.wikifile.File(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
item = wikitools_py3.wikifile.File(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
else:
item = wikitools.page.Page(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
item = wikitools_py3.page.Page(site, title=title, check=False, followRedir=followRedir, pageid=pageid)
if 'missing' in result:
item.exists = False
elif pageid:
item.exists = True
return item

File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions wikitools/wikifile.py → wikitools_py3/wikifile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from . import exceptions
from . import page
from . import internalfunctions
from wikitools.pagelist import makePage
from wikitools_py3.pagelist import makePage
import io
import os.path
import warnings
Expand Down Expand Up @@ -74,7 +74,7 @@ def getFileHistory(self, exif=True, limit='all'):
if exif:
iiprop+='|metadata'
iimetadataversion = 'latest'
return internalfunctions.getList(self, 'prop', 'imageinfo', 'ii', limit=limit,
return internalfunctions.getList(self, 'prop', 'imageinfo', 'ii', limit=limit,
titles=self.title, iiprop=iiprop, iimetadataversion=iimetadataversion)


Expand All @@ -92,7 +92,7 @@ def getFileHistoryGen(self, exif=True, limit='all'):
if exif:
iiprop+='|metadata'
iimetadataversion = 'latest'
return internalfunctions.getListGen(self, 'prop', 'imageinfo', 'ii', limit=limit,
return internalfunctions.getListGen(self, 'prop', 'imageinfo', 'ii', limit=limit,
titles=self.title, iiprop=iiprop, iimetadataversion=iimetadataversion)

def getUsage(self, titleonly=False, force=False, namespaces=None):
Expand Down Expand Up @@ -260,4 +260,3 @@ def __getattr__(self, name):
if name != 'usage':
return super().__getattr__(name)
return self.getUsage()