<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst

import io
import sys

from ..utils import OrderedDict

__all__ = ['register_reader', 'register_writer', 'register_identifier',
           'identify_format', 'get_reader', 'get_writer', 'read', 'write']

__doctest_skip__ = ['register_identifier']

_readers = OrderedDict()
_writers = OrderedDict()
_identifiers = OrderedDict()


def get_formats(data_class=None):
    """
    Get the list of registered I/O formats as a Table.

    Parameters
    ----------
    data_class : classobj
        Filter readers/writer to match data class (default = all classes)

    Returns
    -------
    format_table: Table
        Table of available I/O formats
    """
    from ..table import Table
    format_classes = sorted(set(_readers) | set(_writers))
    rows = []

    for format_class in format_classes:
        if data_class is not None and format_class[1] is not data_class:
            continue

        has_read = 'Yes' if format_class in _readers else 'No'
        has_write = 'Yes' if format_class in _writers else 'No'
        has_identify = 'Yes' if format_class in _identifiers else 'No'

        rows.append((format_class[1].__name__, format_class[0], has_read, has_write, has_identify))

    format_table = Table(zip(*rows),
                         names=('Data class', 'Format', 'Read', 'Write', 'Auto-identify'))
    format_table.sort(['Data class', 'Format'])

    return format_table

<commit_msg>Check for no formats matching input data_class<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst

import io
import sys

from ..utils import OrderedDict

__all__ = ['register_reader', 'register_writer', 'register_identifier',
           'identify_format', 'get_reader', 'get_writer', 'read', 'write']

__doctest_skip__ = ['register_identifier']

_readers = OrderedDict()
_writers = OrderedDict()
_identifiers = OrderedDict()


def get_formats(data_class=None):
    """
    Get the list of registered I/O formats as a Table.

    Parameters
    ----------
    data_class : classobj
        Filter readers/writer to match data class (default = all classes)

    Returns
    -------
    format_table: Table
        Table of available I/O formats
    """
    from ..table import Table
    format_classes = sorted(set(_readers) | set(_writers))
    rows = []

    for format_class in format_classes:
        if data_class is not None and format_class[1] is not data_class:
            continue

        has_read = 'Yes' if format_class in _readers else 'No'
        has_write = 'Yes' if format_class in _writers else 'No'
        has_identify = 'Yes' if format_class in _identifiers else 'No'

        rows.append((format_class[1].__name__, format_class[0], has_read, has_write, has_identify))

    if not rows:
        raise ValueError('No formats have data class {!r:}'.format(data_class.__name__))

    format_table = Table(zip(*rows),
                         names=('Data class', 'Format', 'Read', 'Write', 'Auto-identify'))
    format_table.sort(['Data class', 'Format'])

    return format_table


{'fraction_non_alphanumeric': 0.11093247588424437, 'fraction_numerical': 0.002572347266881029, 'mean_word_length': 3.0613577023498695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6776993', 'n_tokens_mistral': 936, 'n_tokens_neox': 907, 'n_words': 280}