From c5487a446429f0e4b4bc47ad42de0d7b8068bb85 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sat, 29 Nov 2014 22:43:30 -0500 Subject: [PATCH] Add compat file for Py26 OrderedDict. --- moto/compat.py | 5 +++++ moto/dynamodb/models.py | 8 +------- moto/dynamodb2/models.py | 8 +------- moto/kinesis/models.py | 7 +------ moto/sns/models.py | 2 +- 5 files changed, 9 insertions(+), 21 deletions(-) create mode 100644 moto/compat.py diff --git a/moto/compat.py b/moto/compat.py new file mode 100644 index 000000000..a92a5f67b --- /dev/null +++ b/moto/compat.py @@ -0,0 +1,5 @@ +try: + from collections import OrderedDict # flake8: noqa +except ImportError: + # python 2.6 or earlier, use backport + from ordereddict import OrderedDict # flake8: noqa diff --git a/moto/dynamodb/models.py b/moto/dynamodb/models.py index 4251445d4..6039238e7 100644 --- a/moto/dynamodb/models.py +++ b/moto/dynamodb/models.py @@ -3,13 +3,7 @@ from collections import defaultdict import datetime import json -try: - from collections import OrderedDict -except ImportError: - # python 2.6 or earlier, use backport - from ordereddict import OrderedDict - - +from moto.compat import OrderedDict from moto.core import BaseBackend from .comparisons import get_comparison_func from .utils import unix_time diff --git a/moto/dynamodb2/models.py b/moto/dynamodb2/models.py index 5df0c0c28..bc79b7e9a 100644 --- a/moto/dynamodb2/models.py +++ b/moto/dynamodb2/models.py @@ -3,13 +3,7 @@ from collections import defaultdict import datetime import json -try: - from collections import OrderedDict -except ImportError: - # python 2.6 or earlier, use backport - from ordereddict import OrderedDict - - +from moto.compat import OrderedDict from moto.core import BaseBackend from .comparisons import get_comparison_func from .utils import unix_time diff --git a/moto/kinesis/models.py b/moto/kinesis/models.py index 52a5e91f7..0b01881a4 100644 --- a/moto/kinesis/models.py +++ b/moto/kinesis/models.py @@ -1,16 +1,11 @@ from __future__ import unicode_literals import boto.kinesis +from moto.compat import OrderedDict from moto.core import BaseBackend from .exceptions import StreamNotFoundError, ShardNotFoundError from .utils import compose_shard_iterator, compose_new_shard_iterator, decompose_shard_iterator -try: - from collections import OrderedDict -except ImportError: - # python 2.6 or earlier, use backport - from ordereddict import OrderedDict - class Record(object): def __init__(self, partition_key, data, sequence_number): diff --git a/moto/sns/models.py b/moto/sns/models.py index 39e1d46b2..4897c5762 100644 --- a/moto/sns/models.py +++ b/moto/sns/models.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -from collections import OrderedDict import datetime import uuid @@ -8,6 +7,7 @@ import boto.sns import requests import six +from moto.compat import OrderedDict from moto.core import BaseBackend from moto.core.utils import iso_8601_datetime from moto.sqs import sqs_backends