X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/6adc93a079b4b252b2047c0d59f51e5973a9c469..35420dab7a0a8df8a53b552d34e4081be3c4cf19:/imago_pack/imago.py diff --git a/imago_pack/imago.py b/imago_pack/imago.py index c0e6202..7c6c1f2 100755 --- a/imago_pack/imago.py +++ b/imago_pack/imago.py @@ -18,6 +18,7 @@ import linef import manual import intrsc import gridf +import output def argument_parser(): parser = argparse.ArgumentParser(description=__doc__) @@ -35,6 +36,8 @@ def argument_parser(): help="save images instead of displaying them") parser.add_argument('-c', '--cache', dest='l_cache', action='store_true', help="use cached lines") + parser.add_argument('-S', '--sgf', dest='sgf_output', action='store_true', + help="output in SGF") parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help="report progress") return parser @@ -101,22 +104,33 @@ def main(): board = intrsc.board(image, lines, show_all, do_something) - #simple ASCII output: - for line in board: - print ' '.join(line) + if len(args.files) == 1: + + if args.sgf_output: + print board.asSGFsetPos() + else: + print board - if len(args.files) > 1: + else: + game = output.Game(19, board) #TODO size parameter for f in args.files[1:]: try: image = Image.open(f) except IOError, msg: print >> sys.stderr, msg continue + if verbose: + print >> sys.stderr, "Opening", f if image.mode == 'P': image = image.convert('RGB') board = intrsc.board(image, lines, show_all, do_something) - for line in board: - print ' '.join(line) + if args.sgf_output: + game.addMove(board) + else: + print board + + if args.sgf_output: + print game.asSGF() return 0 @@ -139,5 +153,5 @@ if __name__ == '__main__': try: sys.exit(main()) except KeyboardInterrupt: #TODO does this work? - print "Interrupted." + print >> sys.stderr, "Interrupted." sys.exit(1)