context.py 文件源码

python
阅读 44 收藏 0 点赞 0 评论 0

项目:curious 作者: SunDwarf 项目源码 文件源码
def can_run(self, cmd) -> Tuple[bool, list]:
        """
        Checks if a command can be ran.

        :return: If it can be ran, and a list of conditions that failed.
        """
        conditions = getattr(cmd, "cmd_conditions", [])
        failed = []
        for condition in conditions:
            try:
                success = condition(self)
                if inspect.isawaitable(success):
                    success = await success
            except CommandsError:
                raise
            except Exception:
                failed.append(condition)
            else:
                if not success:
                    failed.append(success)

        if failed:
            return False, failed

        return True, []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号