From 3fa0b66b0bc69bb8ebb54731de99b67092b07df5 Mon Sep 17 00:00:00 2001 From: "Sebastian M. Ernst" Date: Sun, 17 Sep 2017 15:19:34 +0200 Subject: [PATCH 1/3] changed wikitools to wikitools_py3 in all files in all relevant places --- README.md | 12 ++++++------ setup.py | 6 +++--- wikitools/category.py | 3 +-- wikitools/pagelist.py | 13 ++++++------- wikitools/wikifile.py | 7 +++---- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7ee625a..a93d7f4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -wikitools -- Package for working with MediaWiki wikis +wikitools_py3 -- Package for working with MediaWiki wikis Requirements ------------ @@ -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) @@ -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") @@ -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") diff --git a/setup.py b/setup.py index efbf80e..201d2f3 100644 --- a/setup.py +++ b/setup.py @@ -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. @@ -13,6 +13,6 @@ author_email='mrzmanwiki@gmail.com', url='https://github.com/alexz-enwp/wikitools', license='GPL v3', - packages=['wikitools'], - package_data={'wikitools': ['COPYING']} + packages=['wikitools_py3'], + package_data={'wikitools_py3': ['COPYING']} ) diff --git a/wikitools/category.py b/wikitools/category.py index 6a69aac..27d103c 100644 --- a/wikitools/category.py +++ b/wikitools/category.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with wikitools. If not, see . -from wikitools.pagelist import makePage +from wikitools_py3.pagelist import makePage from . import api from . import page @@ -111,4 +111,3 @@ def __getattr__(self, name): if name != 'members': return super().__getattr__(name) return self.getAllMembers() - diff --git a/wikitools/pagelist.py b/wikitools/pagelist.py index 668d0d3..c250190 100644 --- a/wikitools/pagelist.py +++ b/wikitools/pagelist.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with wikitools. If not, see . -import wikitools +import wikitools_py3 def listFromQuery(site, queryresult): """Generate a list of Pages from an API query result @@ -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 = [] @@ -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] @@ -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 - diff --git a/wikitools/wikifile.py b/wikitools/wikifile.py index dd4751b..d940273 100644 --- a/wikitools/wikifile.py +++ b/wikitools/wikifile.py @@ -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 @@ -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) @@ -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): @@ -260,4 +260,3 @@ def __getattr__(self, name): if name != 'usage': return super().__getattr__(name) return self.getUsage() - From 774737250f1c5223b122a91ae69a84e3da88c571 Mon Sep 17 00:00:00 2001 From: "Sebastian M. Ernst" Date: Sun, 17 Sep 2017 15:20:05 +0200 Subject: [PATCH 2/3] renamed module folder --- {wikitools => wikitools_py3}/COPYING | 0 {wikitools => wikitools_py3}/__init__.py | 0 {wikitools => wikitools_py3}/api.py | 0 {wikitools => wikitools_py3}/category.py | 0 {wikitools => wikitools_py3}/exceptions.py | 0 {wikitools => wikitools_py3}/internalfunctions.py | 0 {wikitools => wikitools_py3}/page.py | 0 {wikitools => wikitools_py3}/pagelist.py | 0 {wikitools => wikitools_py3}/user.py | 0 {wikitools => wikitools_py3}/wiki.py | 0 {wikitools => wikitools_py3}/wikifile.py | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename {wikitools => wikitools_py3}/COPYING (100%) rename {wikitools => wikitools_py3}/__init__.py (100%) rename {wikitools => wikitools_py3}/api.py (100%) rename {wikitools => wikitools_py3}/category.py (100%) rename {wikitools => wikitools_py3}/exceptions.py (100%) rename {wikitools => wikitools_py3}/internalfunctions.py (100%) rename {wikitools => wikitools_py3}/page.py (100%) rename {wikitools => wikitools_py3}/pagelist.py (100%) rename {wikitools => wikitools_py3}/user.py (100%) rename {wikitools => wikitools_py3}/wiki.py (100%) rename {wikitools => wikitools_py3}/wikifile.py (100%) diff --git a/wikitools/COPYING b/wikitools_py3/COPYING similarity index 100% rename from wikitools/COPYING rename to wikitools_py3/COPYING diff --git a/wikitools/__init__.py b/wikitools_py3/__init__.py similarity index 100% rename from wikitools/__init__.py rename to wikitools_py3/__init__.py diff --git a/wikitools/api.py b/wikitools_py3/api.py similarity index 100% rename from wikitools/api.py rename to wikitools_py3/api.py diff --git a/wikitools/category.py b/wikitools_py3/category.py similarity index 100% rename from wikitools/category.py rename to wikitools_py3/category.py diff --git a/wikitools/exceptions.py b/wikitools_py3/exceptions.py similarity index 100% rename from wikitools/exceptions.py rename to wikitools_py3/exceptions.py diff --git a/wikitools/internalfunctions.py b/wikitools_py3/internalfunctions.py similarity index 100% rename from wikitools/internalfunctions.py rename to wikitools_py3/internalfunctions.py diff --git a/wikitools/page.py b/wikitools_py3/page.py similarity index 100% rename from wikitools/page.py rename to wikitools_py3/page.py diff --git a/wikitools/pagelist.py b/wikitools_py3/pagelist.py similarity index 100% rename from wikitools/pagelist.py rename to wikitools_py3/pagelist.py diff --git a/wikitools/user.py b/wikitools_py3/user.py similarity index 100% rename from wikitools/user.py rename to wikitools_py3/user.py diff --git a/wikitools/wiki.py b/wikitools_py3/wiki.py similarity index 100% rename from wikitools/wiki.py rename to wikitools_py3/wiki.py diff --git a/wikitools/wikifile.py b/wikitools_py3/wikifile.py similarity index 100% rename from wikitools/wikifile.py rename to wikitools_py3/wikifile.py From a48549f5eec8c4a3b7e31fc847a55fb882477ea9 Mon Sep 17 00:00:00 2001 From: "Sebastian M. Ernst" Date: Sun, 17 Sep 2017 15:28:28 +0200 Subject: [PATCH 3/3] fixed imports in tests --- test/test.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/test.py b/test/test.py index c53254e..23aefb5 100644 --- a/test/test.py +++ b/test/test.py @@ -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 @@ -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') @@ -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") @@ -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