#
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#

"""
This module is a storage for different types of workarounds.
"""

import sys


try:
    from collections import OrderedDict  # noqa
except ImportError:
    # NOTE(andreykurilin): Python 2.6 issue. OrderedDict is not
    # present in `collections` library.
    from ordereddict import OrderedDict  # noqa


def is_py26():
    return sys.version_info[:2] == (2, 6)


if is_py26():
    import simplejson as json
else:
    import json


def json_loads(*args, **kwargs):
    """Deserialize a str or unicode instance to a Python object.

    'simplejson' is used in Python 2.6 environment, because standard 'json'
    library not include several important features(for example
    'object_pairs_hook', which allows to deserialize input object to
    OrderedDict)
    """

    return json.loads(*args, **kwargs)
