vnpy/tools/check/utils.py
nanoric 8bb0bb5fbf [Mod] 再次进行一些格式修改
[Add] 增加对binding和tests的代码质量检查
[Add] 更新README.md
2019-01-24 09:06:31 -04:00

22 lines
537 B
Python

import logging
import os
from typing import Callable
logger = logging.getLogger(__file__)
def check_and_warning(*args, fast_fail: bool = False):
passed = True
for i in args:
if isinstance(i, Callable):
print(f"check using {i}")
cwd = os.getcwd()
res = i()
os.chdir(cwd)
if not res:
passed = False
logger.warning("check of %s failed!", i)
if not passed and fast_fail:
return False
return passed