Skip to content

Commit

Permalink
Removed dependency on past
Browse files Browse the repository at this point in the history
  • Loading branch information
tpazderka committed Jan 31, 2019
1 parent 6cd393a commit 3d1a964
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
1 change: 0 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
force_single_line = 1
known_first_party = oic
known_third_party = jwkest,pytest
known_future_library = past
default_section = THIRDPARTY
16 changes: 7 additions & 9 deletions src/oic/oauth2/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from past.builtins import basestring

import copy
import json
import logging
Expand Down Expand Up @@ -954,18 +952,18 @@ def json_deserializer(txt, sformat="urlencoded"):
VDESER = 3
VNULLALLOWED = 4

SINGLE_REQUIRED_STRING = (basestring, True, None, None, False)
SINGLE_OPTIONAL_STRING = (basestring, False, None, None, False)
SINGLE_REQUIRED_STRING = (str, True, None, None, False)
SINGLE_OPTIONAL_STRING = (str, False, None, None, False)
SINGLE_OPTIONAL_INT = (int, False, None, None, False)
OPTIONAL_LIST_OF_STRINGS = ([basestring], False, list_serializer,
OPTIONAL_LIST_OF_STRINGS = ([str], False, list_serializer,
list_deserializer, False)
REQUIRED_LIST_OF_STRINGS = ([basestring], True, list_serializer,
REQUIRED_LIST_OF_STRINGS = ([str], True, list_serializer,
list_deserializer, False)
OPTIONAL_LIST_OF_SP_SEP_STRINGS = ([basestring], False, sp_sep_list_serializer,
OPTIONAL_LIST_OF_SP_SEP_STRINGS = ([str], False, sp_sep_list_serializer,
sp_sep_list_deserializer, False)
REQUIRED_LIST_OF_SP_SEP_STRINGS = ([basestring], True, sp_sep_list_serializer,
REQUIRED_LIST_OF_SP_SEP_STRINGS = ([str], True, sp_sep_list_serializer,
sp_sep_list_deserializer, False)
SINGLE_OPTIONAL_JSON = (basestring, False, json_serializer, json_deserializer,
SINGLE_OPTIONAL_JSON = (str, False, json_serializer, json_deserializer,
False)

REQUIRED = [SINGLE_REQUIRED_STRING, REQUIRED_LIST_OF_STRINGS,
Expand Down
11 changes: 3 additions & 8 deletions src/oic/utils/time_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
from datetime import datetime
from datetime import timedelta

try:
from past.builtins import basestring
except ImportError:
pass

TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
TIME_FORMAT_WITH_FRAGMENT = re.compile(r"^(\d{4,4}-\d{2,2}-\d{2,2}T\d{2,2}:\d{2,2}:\d{2,2})\.\d*Z$")

Expand Down Expand Up @@ -300,7 +295,7 @@ def before(point):
if not point:
return True

if isinstance(point, basestring):
if isinstance(point, str):
point = str_to_time(point)
elif isinstance(point, int):
point = time.gmtime(point)
Expand Down Expand Up @@ -328,12 +323,12 @@ def after(point):

def later_than(after, before):
""" True if then is later or equal to that """
if isinstance(after, basestring):
if isinstance(after, str):
after = str_to_time(after)
elif isinstance(after, int):
after = time.gmtime(after)

if isinstance(before, basestring):
if isinstance(before, str):
before = str_to_time(before)
elif isinstance(before, int):
before = time.gmtime(before)
Expand Down
24 changes: 9 additions & 15 deletions src/oic/utils/webfinger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
import json
import logging
import re
Expand All @@ -10,11 +9,6 @@
from oic.exception import PyoidcError
from oic.utils.time_util import in_a_while

try:
from past.builtins import basestring
except ImportError:
pass

__author__ = 'rolandh'

logger = logging.getLogger(__name__)
Expand All @@ -39,12 +33,12 @@ def __setitem__(self, item, val):
try:
spec = self.c_param[item]
except KeyError:
spec = {"type": basestring, "required": False} # default
spec = {"type": str, "required": False} # default

try:
t1, t2 = spec["type"]
if t1 == list: # Should always be
assert not isinstance(val, basestring)
assert not isinstance(val, str)
assert isinstance(val, list)
res = []
if t2 == LINK:
Expand Down Expand Up @@ -120,19 +114,19 @@ def __contains__(self, item):

class LINK(Base):
c_param = {
"rel": {"type": basestring, "required": True},
"type": {"type": basestring, "required": False},
"href": {"type": basestring, "required": False},
"rel": {"type": str, "required": True},
"type": {"type": str, "required": False},
"href": {"type": str, "required": False},
"titles": {"type": dict, "required": False},
"properties": {"type": dict, "required": False},
}


class JRD(Base):
c_param = {
"expires": {"type": basestring, "required": False}, # Optional
"subject": {"type": basestring, "required": False}, # Should
"aliases": {"type": (list, basestring), "required": False}, # Optional
"expires": {"type": str, "required": False}, # Optional
"subject": {"type": str, "required": False}, # Should
"aliases": {"type": (list, str), "required": False}, # Optional
"properties": {"type": dict, "required": False}, # Optional
"links": {"type": (list, LINK), "required": False}, # Optional
}
Expand Down Expand Up @@ -232,7 +226,7 @@ def query(self, resource, rel=None):
if rel is None:
if self.default_rel:
info.append(("rel", self.default_rel))
elif isinstance(rel, basestring):
elif isinstance(rel, str):
info.append(("rel", rel))
else:
for val in rel:
Expand Down

0 comments on commit 3d1a964

Please sign in to comment.