# 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

    def get_optional_fields(self, **kwargs):
        optional_fields = OrderedDict()
        for fname in self.OPTIONAL_FIELDS:
            method_name = "get_{0}".format(convert_camel_case(fname))
            value = getattr(self, method_name)(**kwargs)
            if value:
                optional_fields[fname] = value
        return optional_fields

    def get_fields(self, **kwargs):
        fields = self.get_required_fields(**kwargs)
        fields.update(self.get_optional_fields(**kwargs))
        return fields


class OrderLineAdapter(BaseAdapter):
    REQUIRED_FIELDS = [
        'SellerSKU',
        'SellerFulfillmentOrderItemId',
        'Quantity',
    ]
    OPTIONAL_FIELDS = [
        'DisplayableComment',
        'FulfillmentNetworkSKU',
        'OrderItemDisposition',
        'PerUnitDeclaredValue',
    ]

    def __init__(self, line):

# 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


    def get_optional_fields(self, **kwargs):
        optional_fields = OrderedDict()
        for fname in self.OPTIONAL_FIELDS:
            method_name = "get_{0}".format(convert_camel_case(fname))
            value = getattr(self, method_name)(**kwargs)
            if value:
                optional_fields[fname] = value
        return optional_fields

    def get_fields(self, **kwargs):
        fields = self.get_required_fields(**kwargs)
        fields.update(self.get_optional_fields(**kwargs))
        return fields


class OrderLineAdapter(BaseAdapter):
    REQUIRED_FIELDS = [
        'SellerSKU',
        'SellerFulfillmentOrderItemId',
        'Quantity',
    ]
    OPTIONAL_FIELDS = [
        'DisplayableComment',
        'FulfillmentNetworkSKU',
        'OrderItemDisposition',
        'PerUnitDeclaredValue',
    ]

    def __init__(self, line):

        super(OrderLineAdapter, self).__init__()