当前位置: 首页>>代码示例>>Python>>正文


Python State.is_empty方法代码示例

本文整理汇总了Python中state.State.is_empty方法的典型用法代码示例。如果您正苦于以下问题:Python State.is_empty方法的具体用法?Python State.is_empty怎么用?Python State.is_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在state.State的用法示例。


在下文中一共展示了State.is_empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WPTUpdate

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import is_empty [as 别名]
class WPTUpdate(object):
    def __init__(self, logger, runner_cls=UpdateRunner, **kwargs):
        """Object that controls the running of a whole wptupdate.

        :param runner_cls: Runner subclass holding the overall list of
                           steps to run.
        :param kwargs: Command line arguments
        """
        self.runner_cls = runner_cls
        self.serve_root = kwargs["test_paths"]["/"]["tests_path"]

        if not kwargs["sync"]:
            setup_paths(self.serve_root)
        else:
            if os.path.exists(kwargs["sync_path"]):
                # If the sync path doesn't exist we defer this until it does
                setup_paths(kwargs["sync_path"])

        self.state = State(logger)
        self.kwargs = kwargs
        self.logger = logger

    def run(self, **kwargs):
        if self.kwargs["abort"]:
            self.abort()
            return exit_clean

        if not self.kwargs["continue"] and not self.state.is_empty():
            self.logger.error("Found existing state. Run with --continue to resume or --abort to clear state")
            return exit_unclean

        if self.kwargs["continue"]:
            if self.state.is_empty():
                self.logger.error("No sync in progress?")
                return exit_clean

            self.kwargs = self.state.kwargs
        else:
            self.state.kwargs = self.kwargs

        self.state.serve_root = self.serve_root

        update_runner = self.runner_cls(self.logger, self.state)
        rv = update_runner.run()
        if rv in (exit_clean, None):
            self.state.clear()

        return rv

    def abort(self):
        self.state.clear()
开发者ID:Coder206,项目名称:servo,代码行数:53,代码来源:update.py

示例2: run

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import is_empty [as 别名]
    def run( self ):
        for line in sys.stdin:
            state = State( line )

            own = []
            for i in range( 0, state.R ):
                for j in range( 0, state.C ):
                    if state.is_my_cell( i, j ):
                        own.append( ( i, j ) )

            possible = []
            for i in range( 0, state.R ):
                for j in range( 0, state.C ):
                    if not state.is_empty( i, j ): continue
                    for p in own:
                        if State.distance( p, ( i, j ) ) < 2:
                            possible.append( ( i, j ) )
                            break

            xx = ( -1, -1 )
            my = ( state.R, state.C )
            mx = ( state.R, state.C )
            for p in possible:
                if p[ 0 ] > xx[ 0 ]:
                    xx = p
                if p[ 1 ] < my[ 1 ]:
                    my = p
                if p[ 0 ] < mx[ 0 ]:
                    mx = p

            Bot.send_move( [ mx, my, xx ] )
开发者ID:DominikDitoIvosevic,项目名称:aibg,代码行数:33,代码来源:bot.py


注:本文中的state.State.is_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。