这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import itertools
import logging
import os
import re
from datetime import datetime, timedelta
from functools import reduce
Expand Down Expand Up @@ -380,11 +381,13 @@ def evaluate(input_str: str) -> Any:
# Don't use str.replace to make sure we replace just the first occurrence
input_str = f"{TRY_STR_REPLACEMENT}{input_str[3:]}"
asteval = get_asteval()
log_level = os.getenv("LOG_LEVEL")
should_log_asteval_errors = log_level == "DEBUG"
if RANGE_PATTERN.match(input_str):
temp_eval = asteval(input_str)
temp_eval = asteval(input_str, show_errors=should_log_asteval_errors)
evaluated = input_str if temp_eval < 0 else temp_eval
else:
evaluated = asteval(input_str)
evaluated = asteval(input_str, show_errors=should_log_asteval_errors)

if asteval.error:
error_messages = [err.get_error() for err in asteval.error]
Expand Down
Loading