# Path: nmt_chainer/__main__.py
# def main(arguments=None):
#     # create the top-level parser
#     parser = argparse.ArgumentParser(description="Kyoto-NMT: an Implementation of the RNNSearch model",
#                                      formatter_class=argparse.ArgumentDefaultsHelpFormatter,
#                                      prog="knmt")
# 
#     parser.add_argument("--run_in_pdb", default=False, action="store_true", help="run knmt in pdb (python debugger)")
# 
#     parser.add_argument("--run_in_cprofile", default=False, action="store_true", help="run knmt in cProfile")
# 
#     subparsers = parser.add_subparsers(dest="__subcommand_name")
# 
#     # create the parser for the "make_data" command
#     parser_make_data = subparsers.add_parser('make_data', description="Prepare data for training.", help="Prepare data for training", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     make_data.define_parser(parser_make_data)
# 
#     # create the parser for the "train" command
#     parser_train = subparsers.add_parser('train', description="Train a model.", help="Train a model", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     train.define_parser(parser_train)
# 
#     # create the parser for the "eval" command
#     parser_eval = subparsers.add_parser('eval', description="Use a model.", help="Use a model", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     eval_module.define_parser(parser_eval)
# 
#     # create the parser for the "version" command
#     parser_version = subparsers.add_parser('version', description="Get version infos.", help="Get version infos", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# 
#     parser_utils = subparsers.add_parser('utils', description="Call a utility script.", help="Call a utility script", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     utils_command.define_parser(parser_utils)
# 
# #     import argcomplete
#     if argcomplete is not None:
#         argcomplete.autocomplete(parser)
# 
#     args = parser.parse_args(args=arguments)
#     if arguments is not None:
#         args.__original_argument_list = arguments
#     else:
#         args.__original_argument_list = sys.argv
# 
#     if args.__subcommand_name is None:
#         parser.print_help()
#         sys.exit(1)
# 
#     func = {"make_data": make_data.do_make_data,
#             "train": train.do_train,
#             "eval": eval_module.do_eval,
#             "version": versioning_tools.main,
#             "utils": utils_command.do_utils}[args.__subcommand_name]
# 
#     if args.run_in_pdb:
#         try:
#             import ipdb
#             run_in_ipdb(func, args)
#         except ImportError:
#             run_in_pdb(func, args)
#         # import pdb
#         # pdb.runcall(func, args)
#         # def debug_signal_handler(signal, frame):
#         #     import pdb
#         #     pdb.set_trace()
#         # import signal
#         # signal.signal(signal.SIGINT, debug_signal_handler)
# 
#     elif args.run_in_cprofile:
#         import cProfile
#         cProfile.runctx("func(args)", globals(), locals(), sort="cumtime")
#     
#     else:
#         try:
#             func(args)
#         except train.CommandLineValuesException as e:
#             parser_train.error(e.args[0])
#         except eval_module.CommandLineValuesException as e:
#             parser_eval.error(e.args[0])
#         except make_data.CommandLineValuesException as e:
#             parser_make_data.error(e.args[0])


import os.path
import pytest
from nmt_chainer.__main__ import main
from __future__ import absolute_import, division, print_function, unicode_literals



class TestCommandLine:
    """
    Some simple tests checking that no command line option lead to an error
    """

    def test_make_data(self, tmpdir, gpu):
        test_data_dir = os.path.join(
            os.path.dirname(
                os.path.abspath(__file__)),
            "../tests_data")
        train_dir = tmpdir.mkdir("train")
        data_prefix = str(train_dir.join("test1.data"))
        data_src_file = os.path.join(test_data_dir, "src2.txt")
        data_tgt_file = os.path.join(test_data_dir, "tgt2.txt")
        args = 'make_data {0} {1} {2} --dev_src {0} --dev_tgt {1} --src_voc_size 512 --tgt_voc_size 3 --max_nb_ex 3 --test_src {0} --test_tgt {1} --tgt_segmentation_type char --src_segmentation_type word'.format(
            data_src_file, data_tgt_file, data_prefix).split(' ')

# Path: nmt_chainer/__main__.py
# def main(arguments=None):
#     # create the top-level parser
#     parser = argparse.ArgumentParser(description="Kyoto-NMT: an Implementation of the RNNSearch model",
#                                      formatter_class=argparse.ArgumentDefaultsHelpFormatter,
#                                      prog="knmt")
# 
#     parser.add_argument("--run_in_pdb", default=False, action="store_true", help="run knmt in pdb (python debugger)")
# 
#     parser.add_argument("--run_in_cprofile", default=False, action="store_true", help="run knmt in cProfile")
# 
#     subparsers = parser.add_subparsers(dest="__subcommand_name")
# 
#     # create the parser for the "make_data" command
#     parser_make_data = subparsers.add_parser('make_data', description="Prepare data for training.", help="Prepare data for training", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     make_data.define_parser(parser_make_data)
# 
#     # create the parser for the "train" command
#     parser_train = subparsers.add_parser('train', description="Train a model.", help="Train a model", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     train.define_parser(parser_train)
# 
#     # create the parser for the "eval" command
#     parser_eval = subparsers.add_parser('eval', description="Use a model.", help="Use a model", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     eval_module.define_parser(parser_eval)
# 
#     # create the parser for the "version" command
#     parser_version = subparsers.add_parser('version', description="Get version infos.", help="Get version infos", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# 
#     parser_utils = subparsers.add_parser('utils', description="Call a utility script.", help="Call a utility script", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
#     utils_command.define_parser(parser_utils)
# 
# #     import argcomplete
#     if argcomplete is not None:
#         argcomplete.autocomplete(parser)
# 
#     args = parser.parse_args(args=arguments)
#     if arguments is not None:
#         args.__original_argument_list = arguments
#     else:
#         args.__original_argument_list = sys.argv
# 
#     if args.__subcommand_name is None:
#         parser.print_help()
#         sys.exit(1)
# 
#     func = {"make_data": make_data.do_make_data,
#             "train": train.do_train,
#             "eval": eval_module.do_eval,
#             "version": versioning_tools.main,
#             "utils": utils_command.do_utils}[args.__subcommand_name]
# 
#     if args.run_in_pdb:
#         try:
#             import ipdb
#             run_in_ipdb(func, args)
#         except ImportError:
#             run_in_pdb(func, args)
#         # import pdb
#         # pdb.runcall(func, args)
#         # def debug_signal_handler(signal, frame):
#         #     import pdb
#         #     pdb.set_trace()
#         # import signal
#         # signal.signal(signal.SIGINT, debug_signal_handler)
# 
#     elif args.run_in_cprofile:
#         import cProfile
#         cProfile.runctx("func(args)", globals(), locals(), sort="cumtime")
#     
#     else:
#         try:
#             func(args)
#         except train.CommandLineValuesException as e:
#             parser_train.error(e.args[0])
#         except eval_module.CommandLineValuesException as e:
#             parser_eval.error(e.args[0])
#         except make_data.CommandLineValuesException as e:
#             parser_make_data.error(e.args[0])


# Path: tests/suite1/command_line_test.py
import os.path
import pytest
from nmt_chainer.__main__ import main

from __future__ import absolute_import, division, print_function, unicode_literals



class TestCommandLine:
    """
    Some simple tests checking that no command line option lead to an error
    """

    def test_make_data(self, tmpdir, gpu):
        test_data_dir = os.path.join(
            os.path.dirname(
                os.path.abspath(__file__)),
            "../tests_data")
        train_dir = tmpdir.mkdir("train")
        data_prefix = str(train_dir.join("test1.data"))
        data_src_file = os.path.join(test_data_dir, "src2.txt")
        data_tgt_file = os.path.join(test_data_dir, "tgt2.txt")
        args = 'make_data {0} {1} {2} --dev_src {0} --dev_tgt {1} --src_voc_size 512 --tgt_voc_size 3 --max_nb_ex 3 --test_src {0} --test_tgt {1} --tgt_segmentation_type char --src_segmentation_type word'.format(
            data_src_file, data_tgt_file, data_prefix).split(' ')

        main(arguments=args)