Пример #1
0
        def eval_func(excel_formula, cse_array_address=None):
            """ Call the compiled lambda to evaluate the cell """

            if excel_formula.compiled_lambda is None:
                missing = load_function(excel_formula, locals())
                if missing:
                    msg_fmt = 'Function {} is not implemented. '
                    excel_formula.msg = '\n'.join(
                        msg_fmt.format(f.upper()) +
                        func_status_msg(f)[1] for f in sorted(missing))

            try:
                with in_array_formula_context(cse_array_address):
                    ret_val = in_array_formula_context.fit_to_range(
                        excel_formula.compiled_lambda())

            except NameError:
                error_logger('error', excel_formula.python_code,
                             msg=excel_formula.msg, exc=UnknownFunction)

            except Exception:
                error_logger('error', excel_formula.python_code,
                             exc=FormulaEvalError)

            if error_messages:
                level = 'warning' if ret_val in ERROR_CODES else 'info'
                error_logger(level, excel_formula.python_code)

            return ret_val if ret_val not in (None, EMPTY) else 0
Пример #2
0
        def eval_func(excel_formula, cse_array_address=None):
            """ Call the compiled lambda to evaluate the cell """

            if excel_formula.compiled_lambda is None:
                missing = load_function(excel_formula, locals())
                if missing:
                    msg_fmt = 'Function {} is not implemented. '
                    excel_formula.msg = '\n'.join(
                        msg_fmt.format(f.upper()) + func_status_msg(f)[1]
                        for f in sorted(missing))

            try:
                with in_array_formula_context(cse_array_address):
                    ret_val = in_array_formula_context.fit_to_range(
                        excel_formula.compiled_lambda())

            except NameError:
                error_logger('error',
                             excel_formula.python_code,
                             msg=excel_formula.msg,
                             exc=UnknownFunction)

            except Exception:
                error_logger('error',
                             excel_formula.python_code,
                             exc=FormulaEvalError)

            if error_messages:
                level = 'warning' if ret_val in ERROR_CODES else 'info'
                error_logger(level, excel_formula.python_code)

            return ret_val if ret_val not in (None, EMPTY) else 0
Пример #3
0
def test_array_formula_context_fit_to_range(address, value, result):
    if address is not None:
        address = AddressRange(address, sheet='s')
    with in_array_formula_context(address):
        assert in_array_formula_context.fit_to_range(value) == result
Пример #4
0
def test_array_formula_context_fit_to_range(address, value, result):
    if address is not None:
        address = AddressRange(address, sheet='s')
    with in_array_formula_context(address):
        assert in_array_formula_context.fit_to_range(value) == result