Giter Site home page Giter Site logo

iliana / python-simplemediawiki Goto Github PK

View Code? Open in Web Editor NEW
27.0 6.0 18.0 50 KB

Extremely low-level wrapper to the MediaWiki API

Home Page: http://pypi.python.org/pypi/simplemediawiki

License: GNU Lesser General Public License v2.1

Python 100.00%

python-simplemediawiki's Introduction

simplemediawiki is an extremely low-level wrapper to the MediaWiki API. It requires Python 2.6 or later or Python 3.3 or later.

This project is looking for a new maintainer! Please file an issue if you are interested in taking over maintainership of the PyPI repository.

python-simplemediawiki's People

Contributors

andrewwang43 avatar hamano avatar hefee avatar iliana avatar itaiin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python-simplemediawiki's Issues

On defining separate methods for Pythons 2 and 3

Here, you added if sys.version[blah] in the body of a method.

When you import it, the sys.version is already static, every line of code will be running in the same interpreter which you already know is 2.7.4 or 3.3.1 or something. Putting an if statement like that in the body of the method is saying "HEY WHAT VERSION IS THIS" every time you call the method.

We do not know the version beforehand. But we can define a method for Python 2 and another one for Python 3. Another if statement can check the Python version once, and then set the corresponding method for the class. This would decrease the method call time and make debugging clearer.

Connecting to mediawiki with basic-auth fails

  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 251, in login
    return do_login(self, user, passwd)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 242, in do_login
    result = self.call(data)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 184, in call
    return json.loads(self._fetch_http(self._api_url, params))
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 153, in _fetch_http
    base64string = base64.encodestring(auth_str).replace('\n', '')
TypeError: expected bytes, bytearray or buffer compatible object

the problem is that the arguments passed to replace must be of the same type. So line 153 should read:

            base64string = base64.encodestring(auth_str).replace(b'\n', b'')

even after that change, the request fails:

  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 251, in login
    return do_login(self, user, passwd)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 242, in do_login
    result = self.call(data)
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 184, in call
    return json.loads(self._fetch_http(self._api_url, params))
  File "/usr/lib64/python3.3/site-packages/simplemediawiki.py", line 156, in _fetch_http
    response = self._opener.open(request)
  File "/usr/lib64/python3.3/urllib/request.py", line 475, in open
    response = meth(req, response)
  File "/usr/lib64/python3.3/urllib/request.py", line 587, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python3.3/urllib/request.py", line 513, in error
    return self._call_chain(*args)
  File "/usr/lib64/python3.3/urllib/request.py", line 447, in _call_chain
    result = func(*args)
  File "/usr/lib64/python3.3/urllib/request.py", line 595, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Authorization Required

handle tokens for edits

It would be very useful if simplemediawiki automatically handled the process of acquiring various forms of edit tokens.

import datetime

In MediaWiki.parse_date, datetime module is used but it's not imported.

apt-get install pythonsimplemediawiki should auto-install python-iso8601

I installed python-simplemediawiki with apt-get install on Ubuntu 14.04, which didn't raise any errors.

When I opened python and typed "import simplemediawiki" I got the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/simplemediawiki.py", line 36, in <module>
    import iso8601
ImportError: No module named iso8601

Running "sudo apt-get install python-iso8601" solved the problem, but python-simplemediawiki should auto-install needed dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.