cli.py 文件源码

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

项目:solarwolf 作者: pygame 项目源码 文件源码
def main():
    #figure out our directories
    global DATADIR, CODEDIR

    # first try to get the path from the solarwolf package.
    try:
        import solarwolf
        if type(solarwolf.__path__) == list:
            localpath = os.path.abspath(solarwolf.__path__[0])
        else:
            localpath = os.path.abspath(solarwolf.__path__._path[0])
    except ImportError:
        localpath = os.path.split(os.path.abspath(sys.argv[0]))[0]

    testdata = localpath
    testcode = os.path.join(localpath, '.')

    if os.path.isdir(os.path.join(testdata, 'data')):
        DATADIR = testdata
    if os.path.isdir(testcode):
        CODEDIR = testcode

    #apply our directories and test environment
    os.chdir(DATADIR)
    sys.path.insert(0, CODEDIR)
    checkdependencies()

    #install pychecker if debugging
    try:
        import game
        if game.DEBUG >= 2:
            import pychecker.checker
            print('Pychecker Enabled')
    except ImportError:
        pass

    #run game and protect from exceptions
    try:
        import main, pygame
        main.main(sys.argv)
    except KeyboardInterrupt:
        print('Keyboard Interrupt (Control-C)...')
    except:
        #must wait on any threading
        if game.thread:
            game.threadstop = 1
            while game.thread:
                pygame.time.wait(10)
                print('waiting on thread...')
        exception_handler()
        if game.DEBUG:
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号