Exemple #1
0
def train_model(parser, context, args):
    """Emit the path to the autocomplete script for use with eval $(snap autocomplete)"""

    handler = ArgumentHandler(
        usage="Method to train the model",
        description="Trains the model manually from the cli",
        epilog="Train the model manually")

    handler.add_argument('-o', '--output', dest='model_path', default='out')

    handler.add_argument('-f', '--file', dest='training_file', default=None)

    out, file = handler.parse_known_args(args)

    if not check_path_validity(out.model_path):
        try:
            os.mkdir(out.model_path)
        except TypeError:
            raise Exception("Please provide a valid path to create the model.")

    if not check_path_validity(out.training_file):
        raise Exception(
            "Training file doesn't exists please provide full path.")

    main(output_dir=out.model_path, training_file=out.training_file)
Exemple #2
0
def main():
    amo = AddonsService(login_prompter=login_prompter_impl)
    cookiedefault = os.path.expanduser('~/.amo_cookie')

    def load_context(args):
        amo.session.load(args.cookies)
        amo.session.timeout = args.timeout
        return amo

    handler = ArgumentHandler(use_subcommand_help=True)
    handler.add_argument('-c',
                         '--cookies',
                         default=cookiedefault,
                         help='the file to save the session cookies to')
    handler.add_argument('--timeout',
                         type=int,
                         default=None,
                         help='timeout for http requests')
    handler.set_logging_argument('-d',
                                 '--debug',
                                 default_level=logging.WARNING,
                                 config_fxn=init_logging)

    try:
        handler.run(sys.argv[1:], context_fxn=load_context)
        amo.persist()
    except KeyboardInterrupt:
        pass
Exemple #3
0
def main():
    handler = ArgumentHandler(
        use_subcommand_help=True,
        epilog='Get help on a subcommand: igen subcommand -h')
    handler.add_argument('-v',
                         '--version',
                         action='version',
                         version=__version__,
                         help='show the version number and exit')
    handler.run()
Exemple #4
0
def main():

    # load basic config info
    config_info = config.load_default_config_info()

    # run the program
    handler = ArgumentHandler('enchant', use_subcommand_help=True)
    handler.set_logging_argument('-L')
    handler.add_argument('-H',
                         '--host',
                         default=config_info.host,
                         help='the host for the enchant server')
    handler.add_argument('-P',
                         '--port',
                         type=int,
                         default=config_info.port,
                         help='the port for the enchant server')
    handler.add_argument('-u',
                         '--username',
                         default=config_info.username,
                         help='the username to use')
    handler.add_argument('-p',
                         '--password',
                         default=config_info.password,
                         help='the password to use')

    handler.run()
Exemple #5
0
def main():
    amo = AddonsService(login_prompter=login_prompter_impl)
    cookiedefault = os.path.expanduser('~/.amo_cookie')

    def load_context(args):
        amo.session.load(args.cookies)
        return amo

    handler = ArgumentHandler()
    handler.add_argument('-c', '--cookies', default=cookiedefault,
                         help='the file to save the session cookies to')
    handler.set_logging_argument('-d', '--debug', default_level=logging.WARNING,
                                 config_fxn=init_logging)
    handler.run(sys.argv[1:], context_fxn=load_context)
    amo.persist()
Exemple #6
0
def main():
    amo = AddonsService(login_prompter=login_prompter_impl)
    cookiedefault = os.path.expanduser('~/.amo_cookie')

    def load_context(args):
        amo.session.load(args.cookies)
        return amo

    handler = ArgumentHandler()
    handler.add_argument('-c', '--cookies', default=cookiedefault,
                         help='the file to save the session cookies to')
    handler.set_logging_argument('-d', '--debug', default_level=logging.WARNING,
                                 config_fxn=init_logging)
    handler.run(sys.argv[1:], context_fxn=load_context)
    amo.persist()
Exemple #7
0
def main():
    def load_context(args):
        if args.input == sys.stdin:
            data = codecs.getreader('utf8')(sys.stdin).read()
        else:
            data = codecs.open(args.input, encoding="utf-8").read()
        return {"gargs": args, "patch": PatchSet(data)}

    handler = ArgumentHandler()
    handler.add_argument('-f',
                         '--file',
                         default=sys.stdin,
                         dest='input',
                         help="The file to input from")

    try:
        handler.run(sys.argv[1:], context_fxn=load_context)
    except KeyboardInterrupt:
        pass
Exemple #8
0
def main():
    handler = ArgumentHandler(
        use_subcommand_help=True,
        enable_autocompletion=True,
        epilog='Get help on a subcommand: igen subcommand -h'
    )

    handler.add_argument(
        '-v', '--version',
        action='version',
        version=__version__,
        help='show the version number'
    )

    # if no parameters are provided, show help
    if len(sys.argv) == 1:
        handler.run(['-h'])
    else:
        handler.run()