Skip to content
Open
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
7 changes: 7 additions & 0 deletions pyswagger/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Compatability."""

try:
from collections import MutableMapping
except ImportError:
# Python 3.3+
from collections.abc import MutableMapping
3 changes: 2 additions & 1 deletion pyswagger/io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import
from .compat import MutableMapping
from .primitives.comm import PrimJSONEncoder
from .utils import final, deref, CaseInsensitiveDict
from pyswagger import errs
Expand Down Expand Up @@ -388,7 +389,7 @@ def apply_with(self, status=None, raw=None, header=None):
final(self.__op.responses.get('default', None)))

if header != None:
if isinstance(header, (collections.Mapping, collections.MutableMapping)):
if isinstance(header, (collections.Mapping, MutableMapping)):
for k, v in six.iteritems(header):
self._convert_header(r, k, v)
else:
Expand Down
4 changes: 2 additions & 2 deletions pyswagger/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import
from .compat import MutableMapping
from .consts import private
from .errs import CycleDetectionError
import six
Expand All @@ -9,7 +10,6 @@
import os
import operator
import functools
import collections

#TODO: accept varg
def scope_compose(scope, name, sep=private.SCOPE_SEPARATOR):
Expand Down Expand Up @@ -596,7 +596,7 @@ def patch_path(base_path, path):
return path


class CaseInsensitiveDict(collections.MutableMapping):
class CaseInsensitiveDict(MutableMapping):
""" a case insensitive dict:
- allow to query with case insensitive keys (get, in)
- iteration would return original key
Expand Down