def _getSmartIndenter(indenterName, qpart, indenter):
    """Get indenter by name.
    Available indenters are none, normal, cstyle, haskell, lilypond, lisp, python, ruby, xml
    Indenter name is not case sensitive
    Raise KeyError if not found
    indentText is indentation, which shall be used. i.e. '\t' for tabs, '    ' for 4 space symbols
    """
    indenterName = indenterName.lower()

    if indenterName in ('haskell', 'lilypond'):  # not supported yet
        logger.warning('Smart indentation for %s not supported yet. But you could be a hero who implemented it' % indenterName)
        from qutepart.indenter.base import IndentAlgNormal as indenterClass
    elif 'none' == indenterName:
        from qutepart.indenter.base import IndentAlgBase as indenterClass
    elif 'normal' == indenterName:
        from qutepart.indenter.base import IndentAlgNormal as indenterClass
    elif 'cstyle' == indenterName:
        from qutepart.indenter.cstyle import IndentAlgCStyle as indenterClass
    elif 'python' == indenterName:
        from qutepart.indenter.python import IndentAlgPython as indenterClass
    elif 'ruby' == indenterName:
        from qutepart.indenter.ruby import IndentAlgRuby as indenterClass
    elif 'xml' == indenterName:
        from qutepart.indenter.xmlindent import IndentAlgXml as indenterClass
    elif 'haskell' == indenterName:
        from qutepart.indenter.haskell import IndenterHaskell as indenterClass
    elif 'lilypond' == indenterName:
        from qutepart.indenter.lilypond import IndenterLilypond as indenterClass
    elif 'lisp' == indenterName:
        from qutepart.indenter.lisp import IndentAlgLisp as indenterClass
    elif 'scheme' == indenterName:
        from qutepart.indenter.scheme import IndentAlgScheme as indenterClass
    else:
        raise KeyError("Indenter %s not found" % indenterName)

    return indenterClass(qpart, indenter)
def subset_examples(example_dict, indices_to_keep, create_new_dict=False):
    """Subsets examples in dictionary.

    :param example_dict: See doc for `write_example_file`.
    :param indices_to_keep: 1-D numpy array with indices of examples to keep.
    :param create_new_dict: Boolean flag.  If True, this method will create a
        new dictionary, leaving the input dictionary untouched.
    :return: example_dict: Same as input, but possibly with fewer examples.
    """

    error_checking.assert_is_integer_numpy_array(indices_to_keep)
    error_checking.assert_is_numpy_array(indices_to_keep, num_dimensions=1)
    error_checking.assert_is_boolean(create_new_dict)

    if not create_new_dict:
        for this_key in MAIN_KEYS:
            optional_key_missing = (
                this_key not in REQUIRED_MAIN_KEYS
                and this_key not in example_dict
            )

            if optional_key_missing:
                continue

            if this_key == TARGET_MATRIX_KEY:
                if this_key in example_dict:
                    example_dict[this_key] = (
                        example_dict[this_key][indices_to_keep, ...]
                    )
                else:
                    example_dict[TARGET_VALUES_KEY] = (
                        example_dict[TARGET_VALUES_KEY][indices_to_keep]
                    )

                continue

            if this_key == FULL_IDS_KEY:
                example_dict[this_key] = [
                    example_dict[this_key][k] for k in indices_to_keep
                ]
            else:
                example_dict[this_key] = example_dict[this_key][
                    indices_to_keep, ...]

        return example_dict

    new_example_dict = {}

    for this_key in METADATA_KEYS:
        sounding_key_missing = (
            this_key in [SOUNDING_FIELDS_KEY, SOUNDING_HEIGHTS_KEY]
            and this_key not in example_dict
        )

        if sounding_key_missing:
            continue

        if this_key == TARGET_NAMES_KEY:
            if this_key in example_dict:
                new_example_dict[this_key] = example_dict[this_key]
            else:
                new_example_dict[TARGET_NAME_KEY] = example_dict[
                    TARGET_NAME_KEY]

            continue

        new_example_dict[this_key] = example_dict[this_key]

    for this_key in MAIN_KEYS:
        optional_key_missing = (
            this_key not in REQUIRED_MAIN_KEYS
            and this_key not in example_dict
        )

        if optional_key_missing:
            continue

        if this_key == TARGET_MATRIX_KEY:
            if this_key in example_dict:
                new_example_dict[this_key] = (
                    example_dict[this_key][indices_to_keep, ...]
                )
            else:
                new_example_dict[TARGET_VALUES_KEY] = (
                    example_dict[TARGET_VALUES_KEY][indices_to_keep]
                )

            continue

        if this_key == FULL_IDS_KEY:
            new_example_dict[this_key] = [
                example_dict[this_key][k] for k in indices_to_keep
            ]
        else:
            new_example_dict[this_key] = example_dict[this_key][
                indices_to_keep, ...]

    return new_example_dict