# Path: oscar_mws/utils.py
# def load_class(name, default=None):
#     if not name:
#         return None
#     try:
#         module_label, class_name = name.rsplit('.', 1)
#     except ValueError:
#         raise ImproperlyConfigured("cannot find class {0}".format(name))
#     imported_module = __import__(module_label, fromlist=[class_name])
#     try:
#         return _pluck_classes([imported_module], [class_name])[0]
#     except IndexError:
#         return None
# 
# def convert_camel_case(name):
#     s1 = FIRST_CAPITAL_PATTERN.sub(r'\1_\2', name)
#     return UPPERCASE_PATTERN.sub(r'\1_\2', s1).lower()


from collections import OrderedDict
from django.conf import settings
from ..utils import load_class, convert_camel_case



MWS_DEFAULT_SHIPPING_SPEED = getattr(settings, 'MWS_DEFAULT_SHIPPING_SPEED')


class BaseAdapter(object):
    REQUIRED_FIELDS = []
    OPTIONAL_FIELDS = []

    def get_required_fields(self, **kwargs):
        required_fields = OrderedDict()
        for fname in self.REQUIRED_FIELDS:
            method_name = "get_{0}".format(convert_camel_case(fname))
            required_fields[fname] = getattr(self, method_name)(**kwargs)
        return required_fields

    def get_optional_fields(self, **kwargs):
        optional_fields = OrderedDict()
        for fname in self.OPTIONAL_FIELDS:

# Path: oscar_mws/utils.py
# def load_class(name, default=None):
#     if not name:
#         return None
#     try:
#         module_label, class_name = name.rsplit('.', 1)
#     except ValueError:
#         raise ImproperlyConfigured("cannot find class {0}".format(name))
#     imported_module = __import__(module_label, fromlist=[class_name])
#     try:
#         return _pluck_classes([imported_module], [class_name])[0]
#     except IndexError:
#         return None
# 
# def convert_camel_case(name):
#     s1 = FIRST_CAPITAL_PATTERN.sub(r'\1_\2', name)
#     return UPPERCASE_PATTERN.sub(r'\1_\2', s1).lower()


# Path: oscar_mws/fulfillment/adapters.py
from collections import OrderedDict
from django.conf import settings
from ..utils import load_class, convert_camel_case




MWS_DEFAULT_SHIPPING_SPEED = getattr(settings, 'MWS_DEFAULT_SHIPPING_SPEED')


class BaseAdapter(object):
    REQUIRED_FIELDS = []
    OPTIONAL_FIELDS = []

    def get_required_fields(self, **kwargs):
        required_fields = OrderedDict()
        for fname in self.REQUIRED_FIELDS:
            method_name = "get_{0}".format(convert_camel_case(fname))
            required_fields[fname] = getattr(self, method_name)(**kwargs)
        return required_fields

    def get_optional_fields(self, **kwargs):
        optional_fields = OrderedDict()
        for fname in self.OPTIONAL_FIELDS:

            method_name = "get_{0}".format(convert_camel_case(fname))