Skip to content
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

Migrate to Python3 #59

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.pyc
dist/*
*~
#*#
.#*
.DS_Store
._.*
124 changes: 0 additions & 124 deletions CHANGELOG

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changes since 3.0.0:
* `wikitools3` uses Python 3 syntax, and Python 2 is no longer supported.

For earlier versions, see the original [`wikitools`](https://pypi.org/project/wikitools/).
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

124 changes: 47 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,47 @@
wikitools -- Package for working with MediaWiki wikis

Requirements
------------

* Python 2.5+. Not compatible with Python 3; not tested on older versions
* Bob Ippolito's simplejson module, if using Python < 2.6
<http://pypi.python.org/pypi/simplejson>
* To upload files or import XML, you need Chris AtLee's poster package
<http://pypi.python.org/pypi/poster>
* The wiki this is used for should be running at least MediaWiki version 1.13 and have the API enabled.

Installation
------------

* Run "python setup.py install" or copy the wikitools directory
to an appropriate Python module directory.
* An exe installer for Windows is also available (should be run as an
administrator to avoid errors)
* An RPM for Linux is also available.
* Arch Linux users may use AUR package for their convenience:
<https://aur.archlinux.org/packages/python2-wikitools/>

Available modules
-----------------

* api.py - Contains the APIRequest class, for doing queries directly,
see API examples below
* wiki.py - Contains the Wiki class, used for logging in to the site,
storing cookies, and storing basic site information
* page.py - Contains the Page class for dealing with individual pages
on the wiki. Can be used to get page info and text, as well as edit and
other actions if enabled on the wiki
* category.py - Category is a subclass of Page with extra functions for
working with categories
* wikifile.py - File is a subclass of Page with extra functions for
working with files - note that there may be some issues with shared
repositories, as the pages for files on shared repos technically don't
exist on the local wiki.
* user.py - Contains the User class for getting information about and
blocking/unblocking users
* pagelist.py - Contains several functions for getting a list of Page
objects from lists of titles, pageids, or API query results

Further documentation
---------------------
* https://code.google.com/p/python-wikitools/wiki/Documentation

Current limitations
-------------------

* Can only do what the API can do. On a site without the edit-API enabled
(disabled by default prior to MediaWiki 1.14), you cannot edit/delete/
protect pages, only retrieve information about them.
* May have issues with some non-ASCII characters. Most of these bugs
should be resolved, though full UTF-8 support is still a little flaky
* Usage on restricted-access (logged-out users can't read) wikis is
mostly untested

Quick start
-----------
# `wikitools3` — Package for working with MediaWiki wikis

## Requirements

* Python 3. Not compatible with Python 2. If you are using Python 2, use the original [`wikitools`](https://pypi.org/project/wikitools/) instead.
* `wikitools3` uses [`poetry`](https://python-poetry.org/) for dependency management. If you are installing via `pip`, you should not need to install `poetry` separately.
* To upload files or import XML, you need Chris AtLee's [`poster3`](http://pypi.python.org/pypi/poster3) package. This should be automatically installed by `pip` and/or `poetry` when you install `wikitools3`.
* The MediaWiki instance you are working with should be version 1.13 or later and have the API enabled.

## Installation

* Run `pip install wikitools3`. This is the preferred installation method.
* Alternately, download the source repository and run `poetry install` within the `wikitools3` directory or copy the `wikitools3/wikitools3` subdirectory directly into the top-level directory of your project.

## Available modules

* `api.py` - Contains the `APIRequest` class, for doing queries directly, see API examples below
* `wiki.py` - Contains the `Wiki` class, used for logging in to the site, storing cookies, and storing basic site information
* `page.py` - Contains the `Page` class for dealing with individual pages on the wiki. Can be used to get page info and text, as well as edit and other actions if enabled on the wiki
* `category.py` - `Category` is a subclass of `Page` with extra functions for working with categories
* `wikifile.py` - `File` is a subclass of `Page` with extra functions for working with files - note that there may be some issues with shared repositories, as the pages for files on shared repos technically don't exist on the local wiki.
* `user.py` - Contains the `User` class for getting information about and blocking/unblocking users
* `pagelist.py` - Contains several functions for getting a list of `Page` objects from lists of titles, pageids, or API query results

## Further documentation

* See also: the legacy `wikitools` documentation at [Google Code](https://code.google.com/p/python-wikitools/wiki/Documentation).

## Current limitations

* Can only do what the API can do. On a site without the edit-API enabled (disabled by default prior to MediaWiki 1.14), you cannot edit/delete/protect pages, only retrieve information about them.
* May have issues with some non-ASCII characters. Most of these bugs should be resolved, though full UTF-8 support is still a little flaky.
* Usage on restricted-access (logged-out users can't read) wikis is mostly untested.
* `wikitools3` has not been tested beyond the needs of `wikiteam`. If functionality from `wikitools` for Python 2 works for you, but the same functionality does not work for you in `wikitools3`, please submit a bug report at [github.com/elsiehupp/wikitools3/issues](https://github.com/elsiehupp/wikitools3/issues).

## Quick start

To make a simple query:

```python
#!/usr/bin/python
#!/usr/bin/env python3

from wikitools import wiki
from wikitools import api
from wikitools3 import wiki
from wikitools3 import api

# create a Wiki object
site = wiki.Wiki("http://my.wikisite.org/w/api.php")
Expand Down Expand Up @@ -100,15 +75,13 @@ token = api.APIRequest(site, params).query()['query']['tokens']['csrftoken']
params = { 'action':'thank', 'rev':diff, 'token':token }
```

For most normal usage, you may not have to do API queries yourself and can just
use the various classes. For example, to add a template to the top of all the
pages in namespace 0 in a category:
For most normal usage, you may not have to do API queries yourself and can just use the various classes. For example, to add a template to the top of all the pages in namespace `0` in a category:

```python
#!/usr/bin/python
#!/usr/bin/env python3

from wikitools import wiki
from wikitools import category
from wikitools3 import wiki
from wikitools3 import category

site = wiki.Wiki("http://my.wikisite.org/w/api.php")
site.login("username", "password")
Expand All @@ -120,16 +93,13 @@ for article in cat.getAllMembersGen(namespaces=[0]):
article.edit(prependtext="{{template}}\n")
```

See the MediaWiki API documentation at <http://www.mediawiki.org/wiki/API>
for more information about using the MediaWiki API. You can get an example of
what query results will look like by doing the queries in your web browser using
the "jsonfm" format option

Licensed under the GNU General Public License, version 3. A copy of the
license is included with this release.
See the [MediaWiki API documentation](https://www.mediawiki.org/wiki/API:Main_page) for more information about using the MediaWiki API. You can get an example of what query results will look like by doing the queries in your web browser using the `jsonfm` format option.

Licensed under the [GNU General Public License, version 3](https://www.gnu.org/licenses/gpl-3.0.en.html). A copy of the license is included with this release.

Authors
-------

* Original source code Alex Z. (User:Mr.Z-man @ en.wikipedia) <[email protected]>
* Some code/assistance (User:Bjweeks @ en.wikipedia)
* Python 3 migration Elsie Hupp ([github.com/elsiehupp](https://github.com/elsiehupp))
20 changes: 20 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tool.poetry]
name = "wikitools3"
version = "3.0.0"
description = "Python package for interacting with a MediaWiki wiki. It is used by WikiTeam for archiving MediaWiki wikis."
authors = ["Alex Zaddach <[email protected]>", "Elsie Hupp <github at elsiehupp dot com>"]
maintainers = ["Elsie Hupp <[email protected]>"]
readme = "README.md"
repository = "https://github.com/elsiehupp/wikitools3"
keywords = ["wikipedia", "mediawiki", "archive", "scrape", "archiveteam"]
license = "GPL-3.0-or-later"
include = ["CHANGELOG.md"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Natural Language :: English",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Wiki",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[tool.poetry.dependencies]
python = "^3"
poster3 = "^0.8.1"

[tool.poetry.dev-dependencies]
twine = "*"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
18 changes: 0 additions & 18 deletions setup.py

This file was deleted.

Loading