Handle OrderedDict import attempt in cassandra.util
This commit is contained in:
@@ -31,6 +31,7 @@ from cassandra.marshal import (int8_pack, int8_unpack, uint16_pack, uint16_unpac
|
||||
int32_pack, int32_unpack, int64_pack, int64_unpack,
|
||||
float_pack, float_unpack, double_pack, double_unpack,
|
||||
varint_pack, varint_unpack)
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
apache_cassandra_type_prefix = 'org.apache.cassandra.db.marshal.'
|
||||
|
||||
@@ -46,11 +47,6 @@ except ImportError:
|
||||
|
||||
sortedset = set
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
|
||||
|
||||
def trim_if_startswith(s, prefix):
|
||||
if s.startswith(prefix):
|
||||
|
||||
@@ -9,11 +9,6 @@ import sys
|
||||
import types
|
||||
from uuid import UUID
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
@@ -30,6 +25,7 @@ from cassandra.cqltypes import (AsciiType, BytesType, BooleanType,
|
||||
InetAddressType, IntegerType, ListType,
|
||||
LongType, MapType, SetType, TimeUUIDType,
|
||||
UTF8Type, UUIDType, lookup_casstype)
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
from bisect import bisect_right
|
||||
from collections import defaultdict
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
from hashlib import md5
|
||||
from itertools import islice, cycle
|
||||
import json
|
||||
@@ -21,6 +17,7 @@ except ImportError:
|
||||
import cassandra.cqltypes as types
|
||||
from cassandra.marshal import varint_unpack
|
||||
from cassandra.pool import Host
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
# OrderedDict from Python 2.7+
|
||||
|
||||
# Copyright (c) 2009 Raymond Hettinger
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation files
|
||||
# (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
# and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
from UserDict import DictMixin
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
# OrderedDict from Python 2.7+
|
||||
|
||||
class OrderedDict(dict, DictMixin):
|
||||
# Copyright (c) 2009 Raymond Hettinger
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation files
|
||||
# (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
# and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
class OrderedDict(dict, DictMixin): # noqa
|
||||
""" A dictionary which maintains the insertion order of keys. """
|
||||
|
||||
def __init__(self, *args, **kwds):
|
||||
|
||||
@@ -5,11 +5,7 @@ except ImportError:
|
||||
|
||||
from cassandra.cluster import Cluster
|
||||
from cassandra.decoder import tuple_factory, named_tuple_factory, dict_factory, ordered_dict_factory
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
|
||||
class TestFactories(unittest.TestCase):
|
||||
|
||||
@@ -16,10 +16,7 @@ from cassandra import InvalidRequest
|
||||
from cassandra.cluster import Cluster
|
||||
from cassandra.cqltypes import Int32Type, EMPTY
|
||||
from cassandra.decoder import dict_factory
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from cassandra.util import OrderedDict # noqa
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
from tests.integration import get_server_versions
|
||||
|
||||
|
||||
@@ -13,13 +13,8 @@ try:
|
||||
except ImportError:
|
||||
sortedset = set
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
|
||||
|
||||
from cassandra.cqltypes import lookup_casstype
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
marshalled_value_pairs = (
|
||||
# binary form, type, python native type
|
||||
|
||||
@@ -6,11 +6,7 @@ except ImportError:
|
||||
from cassandra.query import bind_params, ValueSequence
|
||||
from cassandra.query import PreparedStatement, BoundStatement
|
||||
from cassandra.cqltypes import Int32Type
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError: # Python <2.7
|
||||
from cassandra.util import OrderedDict # NOQA
|
||||
from cassandra.util import OrderedDict
|
||||
|
||||
|
||||
class ParamBindingTest(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user