# Path: pytablereader/_constant.py
# class SourceType:
#     TEXT = "text"
#     FILE = "file"
#     URL = "url"
#     OBJECT = "object"
# 
# Path: pytablereader/_constant.py
# class TableNameTemplate:
#     __FORMAT = "%({:s})s"
#     DEFAULT = __FORMAT.format("default")
#     FILENAME = __FORMAT.format("filename")
#     FORMAT_NAME = __FORMAT.format("format_name")
#     FORMAT_ID = __FORMAT.format("format_id")
#     GLOBAL_ID = __FORMAT.format("global_id")
#     KEY = __FORMAT.format("key")
#     TITLE = __FORMAT.format("title")
#     SHEET = __FORMAT.format("sheet")
# 
# Path: pytablereader/error.py
# class ValidationError(Exception):
#     """
#     Exception raised when data is not properly formatted.
#     """
# 
# Path: pytablereader/formatter.py
# class TableFormatter(LoaderAcceptor, TableFormatterInterface):
#     """
#     The abstract class of |TableData| formatter.
#     """
# 
#     def _validate_source_data(self):
#         if not self._source_data:
#             raise DataError("source data is empty")
# 
#     def __init__(self, source_data):
#         self._source_data = source_data
# 
#         self._validate_source_data()
# 
#     def _extract_type_hints(self, headers=None):
#         if self._loader.type_hints:
#             return self._loader.type_hints
# 
#         if not self._loader.type_hint_rules or not headers:
#             return []
# 
#         type_hints = []
#         for header in headers:
#             for regexp, type_hint in self._loader.type_hint_rules.items():
#                 if regexp.search(header):
#                     type_hints.append(type_hint)
#                     break
#             else:
#                 type_hints.append(None)
# 
#         logger.debug(
#             dedent(
#                 """\
#                 extracted type hints:
#                 {}
#                 """
#             ).format(
#                 json.dumps(
#                     OrderedDict(
#                         {header: str(type_hint) for header, type_hint in zip(headers, type_hints)}
#                     ),
#                     indent=4,
#                 )
#             )
#         )
# 
#         return type_hints


import abc
import jsonschema
from tabledata import TableData
from .._constant import SourceType
from .._constant import TableNameTemplate as tnt
from ..error import ValidationError
from ..formatter import TableFormatter
            {"type": "null"},
            {"type": "object"},
        ]
    }

    def __init__(self, json_buffer):
        self._buffer = json_buffer

    @abc.abstractproperty
    def _schema(self):  # pragma: no cover
        pass

    def _validate_source_data(self):
        """
        :raises ValidationError:
        """

        try:
            jsonschema.validate(self._buffer, self._schema)
        except jsonschema.ValidationError as e:
            raise ValidationError(e)


class SingleJsonTableConverterBase(JsonConverter):
    def _make_table_name(self):
        kv_mapping = self._loader._get_basic_tablename_keyvalue_mapping()
        kv_mapping[tnt.KEY] = self._loader.get_format_key()

        if self._loader.source_type == SourceType.FILE:
            kv_mapping[tnt.DEFAULT] = tnt.FILENAME

# Path: pytablereader/_constant.py
# class SourceType:
#     TEXT = "text"
#     FILE = "file"
#     URL = "url"
#     OBJECT = "object"
# 
# Path: pytablereader/_constant.py
# class TableNameTemplate:
#     __FORMAT = "%({:s})s"
#     DEFAULT = __FORMAT.format("default")
#     FILENAME = __FORMAT.format("filename")
#     FORMAT_NAME = __FORMAT.format("format_name")
#     FORMAT_ID = __FORMAT.format("format_id")
#     GLOBAL_ID = __FORMAT.format("global_id")
#     KEY = __FORMAT.format("key")
#     TITLE = __FORMAT.format("title")
#     SHEET = __FORMAT.format("sheet")
# 
# Path: pytablereader/error.py
# class ValidationError(Exception):
#     """
#     Exception raised when data is not properly formatted.
#     """
# 
# Path: pytablereader/formatter.py
# class TableFormatter(LoaderAcceptor, TableFormatterInterface):
#     """
#     The abstract class of |TableData| formatter.
#     """
# 
#     def _validate_source_data(self):
#         if not self._source_data:
#             raise DataError("source data is empty")
# 
#     def __init__(self, source_data):
#         self._source_data = source_data
# 
#         self._validate_source_data()
# 
#     def _extract_type_hints(self, headers=None):
#         if self._loader.type_hints:
#             return self._loader.type_hints
# 
#         if not self._loader.type_hint_rules or not headers:
#             return []
# 
#         type_hints = []
#         for header in headers:
#             for regexp, type_hint in self._loader.type_hint_rules.items():
#                 if regexp.search(header):
#                     type_hints.append(type_hint)
#                     break
#             else:
#                 type_hints.append(None)
# 
#         logger.debug(
#             dedent(
#                 """\
#                 extracted type hints:
#                 {}
#                 """
#             ).format(
#                 json.dumps(
#                     OrderedDict(
#                         {header: str(type_hint) for header, type_hint in zip(headers, type_hints)}
#                     ),
#                     indent=4,
#                 )
#             )
#         )
# 
#         return type_hints


# Path: pytablereader/json/formatter.py
import abc
import jsonschema
from tabledata import TableData
from .._constant import SourceType
from .._constant import TableNameTemplate as tnt
from ..error import ValidationError
from ..formatter import TableFormatter

            {"type": "null"},
            {"type": "object"},
        ]
    }

    def __init__(self, json_buffer):
        self._buffer = json_buffer

    @abc.abstractproperty
    def _schema(self):  # pragma: no cover
        pass

    def _validate_source_data(self):
        """
        :raises ValidationError:
        """

        try:
            jsonschema.validate(self._buffer, self._schema)
        except jsonschema.ValidationError as e:
            raise ValidationError(e)


class SingleJsonTableConverterBase(JsonConverter):
    def _make_table_name(self):
        kv_mapping = self._loader._get_basic_tablename_keyvalue_mapping()
        kv_mapping[tnt.KEY] = self._loader.get_format_key()

        if self._loader.source_type == SourceType.FILE:
            kv_mapping[tnt.DEFAULT] = tnt.FILENAME

        elif self._loader.source_type == SourceType.TEXT: