Skip to content

Commit 2cb6b71

Browse files
author
Aaron Halfaker
committed
Merge branch 'a-detiste-master'
2 parents 753f851 + 5ed65c6 commit 2cb6b71

File tree

12 files changed

+12
-39
lines changed

12 files changed

+12
-39
lines changed

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MediaWiki OAuth Library
33

44
``mwoauth`` is an open licensed (MIT) library designed to provide a simple means to performing an OAuth handshake with a MediaWiki installation with the `OAuth Extension <https://www.mediawiki.org/wiki/Extension:OAuth>`_ installed.
55

6-
**Compatible with python 2.7 and 3.x**
6+
**Compatible with python 3.x**
77

88
**Install with pip:** ``pip install mwoauth``
99

@@ -15,7 +15,6 @@ Usage
1515
.. code-block:: python
1616
1717
from mwoauth import ConsumerToken, Handshaker
18-
from six.moves import input # For compatibility between python 2 and 3
1918
2019
# Construct a "consumer" from the key/secret provided by MediaWiki
2120
import config

examples/functions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from mwoauth import ConsumerToken, complete, identify, initiate
55

6-
from six.moves import input # For compatibility between python 2 and 3
7-
86
sys.path.insert(0, ".")
97

108
try:

examples/handshaker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
from mwoauth import ConsumerToken, Handshaker
55

6-
from six.moves import input # For compatibility between python 2 and 3
7-
86
try:
97
creds_doc = json.load(open("credentials.do_not_commit.json"))
108
consumer_key = creds_doc['consumer_key']

examples/request-oauthlib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from mwoauth import ConsumerToken, Handshaker
55
from requests_oauthlib import OAuth1
66

7-
from six.moves import input # For compatibility between python 2 and 3
8-
97
try:
108
creds_doc = json.load(open("credentials.do_not_commit.json"))
119
consumer_key = creds_doc['consumer_key']

mwoauth/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__name__ = "mwoauth"
2-
__version__ = "0.3.8"
2+
__version__ = "0.4.0"
33
__author__ = "Aaron Halfaker / Filippo Valsorda"
44
__author_email__ = "aaron.halfaker@gmail.com"
55
__description__ = "A generic MediaWiki OAuth handshake helper."

mwoauth/flask.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
import logging
1010
from functools import wraps
11+
from urllib.parse import urljoin
1112

1213
import flask
1314
from requests_oauthlib import OAuth1
1415

15-
from six.moves.urllib.parse import urljoin
16-
1716
from .errors import OAuthException
1817
from .handshaker import Handshaker
1918
from .tokens import AccessToken, RequestToken

mwoauth/functions.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
.. code-block:: python
77
88
from mwoauth import ConsumerToken, initiate, complete, identify
9-
from six.moves import input # For compatibility between python 2 and 3
109
1110
# Consruct a "consumer" from the key/secret provided by MediaWiki
1211
import config
@@ -35,27 +34,22 @@
3534
import json
3635
import re
3736
import time
37+
from urllib.parse import parse_qs, urlencode, urlparse
3838

3939
import jwt
4040
import requests
4141
from requests_oauthlib import OAuth1
42-
from six import PY3, text_type
43-
44-
from six.moves.urllib.parse import parse_qs, urlencode, urlparse
4542

4643
from . import defaults
4744
from .errors import OAuthException
4845
from .tokens import AccessToken, RequestToken
4946

5047

5148
def force_unicode(val, encoding="unicode-escape"):
52-
if type(val) == text_type:
49+
if type(val) == str:
5350
return val
5451
else:
55-
if PY3:
56-
return val.decode(encoding, errors="replace")
57-
else:
58-
return unicode(val, encoding, errors="replace") # noqa
52+
return val.decode(encoding, errors="replace")
5953

6054

6155
def initiate(mw_uri, consumer_token, callback='oob',

mwoauth/handshaker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
.. code-block:: python
66
77
from mwoauth import ConsumerToken, Handshaker
8-
from six.moves import input # For compatibility between python 2 and 3
98
109
# Consruct a "consumer" from the key/secret provided by MediaWiki
1110
import config

mwoauth/tests/test_functions.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
# -*- coding: UTF-8 -*-
22
import pytest
3-
from six import PY3, b
43

54
from ..errors import OAuthException
65
from ..functions import process_request_token
76

87

98
def test_process_request_token():
109
request_token = process_request_token(
11-
b("oauth_token=iamatoken&oauth_token_secret=iamasecret"))
10+
"oauth_token=iamatoken&oauth_token_secret=iamasecret")
1211
assert request_token.key == "iamatoken"
1312
assert request_token.secret == "iamasecret"
1413

1514

1615
def test_process_request_token_errors():
17-
if PY3:
18-
text = "Error: Произошла ошибка в протоколе OAuth: " + \
19-
"Invalid consumer key"
20-
content = bytes(text, "utf-8")
21-
else:
22-
content = "Error: Произошла ошибка в протоколе OAuth: " + \
23-
"Invalid consumer key"
24-
text = unicode(content, "utf-8")
16+
text = "Error: Произошла ошибка в протоколе OAuth: " + \
17+
"Invalid consumer key"
18+
#content = bytes(text, "utf-8")
2519
with pytest.raises(OAuthException, match=text[len("Error: "):]):
26-
process_request_token(content)
20+
process_request_token(text)
2721

2822
with pytest.raises(OAuthException, match="I am an error"):
2923
process_request_token("Error: I am an error")

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
PyJWT == 2.4.0
22
requests == 2.21.0
33
requests-oauthlib == 1.2.0
4-
six == 1.12.0

0 commit comments

Comments
 (0)