Exemplo n.º 1
0
def _main(argv, standard_out, standard_error):
    import argparse
    parser = argparse.ArgumentParser(
        description=__doc__, prog='sudoku', version=_version.get_versions()['version'])
    parser.add_argument('-i', dest='sourcefile', action='store', required=True,
                        help='source file')
    parser.add_argument('-o', dest='output_format', action='store', choices=game.get_output_formats(), default='sdk',
                        help='output format')

    cfg = parser.parse_args(argv[1:])

    try:
        variant = SudokuGame.guess_variant(cfg.sourcefile)
    except UnsupportedVariantException:
        print('File format {} is not supported'.format(
            cfg.sourcefile), file=standard_error)
        return 1

    player = BruteForceSudokuPlayer('Chuck Norris')
    game.set_player(player)
    game.set_game_variant(variant)
    game.set_source_file(cfg.sourcefile)
    game.set_output_format(cfg.output_format)
    game.run()
    return 0
Exemplo n.º 2
0
def _main(argv, standard_out, standard_error):
    import argparse
    parser = argparse.ArgumentParser(
        description=__doc__,
        prog='sudoku',
        version=_version.get_versions()['version'])
    parser.add_argument('-i',
                        dest='sourcefile',
                        action='store',
                        required=True,
                        help='source file')
    parser.add_argument('-o',
                        dest='output_format',
                        action='store',
                        choices=game.get_output_formats(),
                        default='sdk',
                        help='output format')

    cfg = parser.parse_args(argv[1:])

    try:
        variant = SudokuGame.guess_variant(cfg.sourcefile)
    except UnsupportedVariantException:
        print('File format {} is not supported'.format(cfg.sourcefile),
              file=standard_error)
        return 1

    player = BruteForceSudokuPlayer('Chuck Norris')
    game.set_player(player)
    game.set_game_variant(variant)
    game.set_source_file(cfg.sourcefile)
    game.set_output_format(cfg.output_format)
    game.run()
    return 0