# Path: rakuten_ws/compat.py
#     def iteritems(d):
#     def is_bytes(x):
#     def callable(obj):
#     def iteritems(d):
#     def is_bytes(x):
# def to_unicode(obj, encoding='utf-8'):


import re
import requests
from collections import OrderedDict, MutableMapping
from shutil import copyfileobj
from mimetypes import guess_type
from io import BytesIO, open
from xmljson import Parker
from lxml.etree import Element, fromstring, tostring
from .compat import iteritems, to_unicode, is_py2, str, urlparse, pathname2url
        parts = key.split(".")
        d = unflat_dict
        for part in parts[:-1]:
            if part not in d:
                d[part] = dictionary.__class__()
            d = d[part]
        d[parts[-1]] = value

    def unflatten_list_dict(dictionary):
        unflat_list_dict = dictionary.__class__()
        for k, v in dictionary.items():
            if isinstance(v, dict):
                unflat_dict = unflatten_list_dict(v)
                if sorted(unflat_dict.keys())[0] == '@0':
                    unflat_list = []
                    for key in sorted(unflat_dict.keys()):
                        unflat_list.append(unflat_dict[key])
                    new_value = unflat_list
                else:
                    new_value = unflat_dict
                unflat_list_dict[k] = new_value
            else:
                unflat_list_dict[k] = v
        return unflat_list_dict

    return unflatten_list_dict(unflat_dict)


def load_file(url, session=None, timeout=None):
    """Load the content from the given URL and return it as a `BytesIO`"""

# Path: rakuten_ws/compat.py
#     def iteritems(d):
#     def is_bytes(x):
#     def callable(obj):
#     def iteritems(d):
#     def is_bytes(x):
# def to_unicode(obj, encoding='utf-8'):


# Path: rakuten_ws/utils.py
import re
import requests
from collections import OrderedDict, MutableMapping
from shutil import copyfileobj
from mimetypes import guess_type
from io import BytesIO, open
from xmljson import Parker
from lxml.etree import Element, fromstring, tostring
from .compat import iteritems, to_unicode, is_py2, str, urlparse, pathname2url

        parts = key.split(".")
        d = unflat_dict
        for part in parts[:-1]:
            if part not in d:
                d[part] = dictionary.__class__()
            d = d[part]
        d[parts[-1]] = value

    def unflatten_list_dict(dictionary):
        unflat_list_dict = dictionary.__class__()
        for k, v in dictionary.items():
            if isinstance(v, dict):
                unflat_dict = unflatten_list_dict(v)
                if sorted(unflat_dict.keys())[0] == '@0':
                    unflat_list = []
                    for key in sorted(unflat_dict.keys()):
                        unflat_list.append(unflat_dict[key])
                    new_value = unflat_list
                else:
                    new_value = unflat_dict
                unflat_list_dict[k] = new_value
            else:
                unflat_list_dict[k] = v
        return unflat_list_dict

    return unflatten_list_dict(unflat_dict)


def load_file(url, session=None, timeout=None):
    """Load the content from the given URL and return it as a `BytesIO`"""

    scheme = urlparse(url).scheme