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 _check_layer_operation(example_dict, operation_dict):
    """Error-checks layer operation.

    Such operations are used for dimensionality reduction (to convert radar data
    from 3-D to 2-D).

    :param example_dict: See doc for `reduce_examples_3d_to_2d`.
    :param operation_dict: Dictionary with the following keys.
    operation_dict["radar_field_name"]: Field to which operation will be
        applied.
    operation_dict["operation_name"]: Name of operation (must be in list
        `VALID_LAYER_OPERATION_NAMES`).
    operation_dict["min_height_m_agl"]: Minimum height of layer over which
        operation will be applied.
    operation_dict["max_height_m_agl"]: Max height of layer over which operation
        will be applied.

    :raises: ValueError: if something is wrong with the operation params.
    """

    if operation_dict[RADAR_FIELD_KEY] in AZIMUTHAL_SHEAR_FIELD_NAMES:
        error_string = (
            'Layer operations cannot be applied to azimuthal-shear fields '
            '(such as "{0:s}").'
        ).format(operation_dict[RADAR_FIELD_KEY])

        raise ValueError(error_string)

    if (operation_dict[RADAR_FIELD_KEY] == radar_utils.REFL_NAME
            and REFL_IMAGE_MATRIX_KEY in example_dict):
        pass

    else:
        if (operation_dict[RADAR_FIELD_KEY]
                not in example_dict[RADAR_FIELDS_KEY]):
            error_string = (
                '\n{0:s}\nExamples contain only radar fields listed above, '
                'which do not include "{1:s}".'
            ).format(
                str(example_dict[RADAR_FIELDS_KEY]),
                operation_dict[RADAR_FIELD_KEY]
            )

            raise ValueError(error_string)

    if operation_dict[OPERATION_NAME_KEY] not in VALID_LAYER_OPERATION_NAMES:
        error_string = (
            '\n{0:s}\nValid operations (listed above) do not include '
            '"{1:s}".'
        ).format(
            str(VALID_LAYER_OPERATION_NAMES), operation_dict[OPERATION_NAME_KEY]
        )

        raise ValueError(error_string)

    min_height_m_agl = operation_dict[MIN_HEIGHT_KEY]
    max_height_m_agl = operation_dict[MAX_HEIGHT_KEY]

    error_checking.assert_is_geq(
        min_height_m_agl, numpy.min(example_dict[RADAR_HEIGHTS_KEY])
    )
    error_checking.assert_is_leq(
        max_height_m_agl, numpy.max(example_dict[RADAR_HEIGHTS_KEY])
    )
    error_checking.assert_is_greater(max_height_m_agl, min_height_m_agl)