def boost_error_level(version, error, segments, eci, is_sa=False):
    """\
    Increases the error level if possible.

    :param int version: Version constant.
    :param int|None error: Error level constant or ``None``
    :param Segments segments: Instance of :py:class:`Segments`
    :param bool eci: Indicates if ECI designator should be written.
    :param bool is_sa: Indicates if Structured Append mode ist used.
    """
    if error not in (consts.ERROR_LEVEL_H, None) and len(segments) == 1:
        levels = [consts.ERROR_LEVEL_L, consts.ERROR_LEVEL_M,
                  consts.ERROR_LEVEL_Q, consts.ERROR_LEVEL_H]
        if version < 1:
            levels.pop()  # H isn't support by Micro QR Codes
            if version < consts.VERSION_M4:
                levels.pop()  # Error level Q isn't supported by M2 and M3
        data_length = segments.bit_length_with_overhead(version, eci, is_sa=is_sa)
        for level in levels[levels.index(error)+1:]:
            try:
                found = consts.SYMBOL_CAPACITY[version][level] >= data_length
            except KeyError:
                break
            if found:
                error = level
    return error
def boost_error_level ( version , error , segments , eci , is_sa = False ) : if error not in ( consts . ERROR_LEVEL_H , None ) and len ( segments ) == 1 : levels = [ consts . ERROR_LEVEL_L , consts . ERROR_LEVEL_M , consts . ERROR_LEVEL_Q , consts . ERROR_LEVEL_H ] if version < 1 : levels . pop ( ) if version < consts . VERSION_M4 : levels . pop ( ) data_length = segments . bit_length_with_overhead ( version , eci , is_sa = is_sa ) for level in levels [ levels . index ( error ) + 1 : ] : try : found = consts . SYMBOL_CAPACITY [ version ] [ level ] >= data_length except KeyError : break if found : error = level return error
\
    Increases the error level if possible.

    :param int version: Version constant.
    :param int|None error: Error level constant or ``None``
    :param Segments segments: Instance of :py:class:`Segments`
    :param bool eci: Indicates if ECI designator should be written.
    :param bool is_sa: Indicates if Structured Append mode ist used.