# Path: cjktools/common.py
# class _NullContextWrapper(object):
#     """
#     Class for wrapping contexts so that they are passed through in a
#     with statement.
#     """
#     def __init__(self, context):
#         self.context = context
# 
#     def __enter__(self):
#         return self.context
# 
#     def __exit__(*args, **kwargs):
#         pass
# 
# Path: cjktools/resources/auto_format.py
# def iter_entries(istream):
#     """
#     Iterates over dictionary entries, without storing them all in memory
#     at once.
#     """
#     lines = iter(istream)
#     header = next(lines)
#     return detect_format(header).iter_entries(lines)


import re
import six
from collections import defaultdict
from cjktools.common import _NullContextWrapper as NullContextWrapper
from .auto_format import iter_entries
# -*- coding: utf-8 -*-
#
#  split_by_codes.py
#  cjktools
#





def load_coded_dictionary(file_or_stream):
    """ Load a dictionary which is split by the codes within it. """
    if isinstance(file_or_stream, (six.text_type, six.string_types)):
        file_or_stream = open(file_or_stream)
    else:

# Path: cjktools/common.py
# class _NullContextWrapper(object):
#     """
#     Class for wrapping contexts so that they are passed through in a
#     with statement.
#     """
#     def __init__(self, context):
#         self.context = context
# 
#     def __enter__(self):
#         return self.context
# 
#     def __exit__(*args, **kwargs):
#         pass
# 
# Path: cjktools/resources/auto_format.py
# def iter_entries(istream):
#     """
#     Iterates over dictionary entries, without storing them all in memory
#     at once.
#     """
#     lines = iter(istream)
#     header = next(lines)
#     return detect_format(header).iter_entries(lines)


# Path: cjktools/resources/split_by_codes.py
import re
import six
from collections import defaultdict
from cjktools.common import _NullContextWrapper as NullContextWrapper
from .auto_format import iter_entries

# -*- coding: utf-8 -*-
#
#  split_by_codes.py
#  cjktools
#





def load_coded_dictionary(file_or_stream):
    """ Load a dictionary which is split by the codes within it. """
    if isinstance(file_or_stream, (six.text_type, six.string_types)):
        file_or_stream = open(file_or_stream)
    else:

        file_or_stream = NullContextWrapper(file_or_stream)