import argparse
import autoencoder


def addTrainablesArg(parser):
    parser.add_argument('--model', dest='model', help='Trained model', default='model.pt')

def addExchangeArg(parser):
    parser.add_argument('--exchange', dest='exchange', help='File with exchanged data', required=True)


parser = argparse.ArgumentParser()

subparsers = parser.add_subparsers(dest="action")

encode_parser = subparsers.add_parser('encode')
addTrainablesArg(encode_parser)
encode_parser.add_argument('--input', dest='input', help='Input image file name', required=True)
addExchangeArg(encode_parser)

decode_parser = subparsers.add_parser('decode')
addTrainablesArg(decode_parser)
addExchangeArg(decode_parser)
decode_parser.add_argument('--output', dest='output', help='Output image file name', required=True)

opts = parser.parse_args()

if opts.action == 'encode':
    autoencoder.encode(opts.model, opts.input, opts.exchange)
elif opts.action == 'decode':
    autoencoder.decode(opts.model, opts.exchange, opts.output)

[((12, 9, 12, 34), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ({}, {}), '()', False, 'import argparse\n'), ((29, 4, 29, 61), 'autoencoder.encode', 'autoencoder.encode', ({(29, 23, 29, 33): 'opts.model', (29, 35, 29, 45): 'opts.input', (29, 47, 29, 60): 'opts.exchange'}, {}), '(opts.model, opts.input, opts.exchange)', False, 'import autoencoder\n'), ((31, 4, 31, 62), 'autoencoder.decode', 'autoencoder.decode', ({(31, 23, 31, 33): 'opts.model', (31, 35, 31, 48): 'opts.exchange', (31, 50, 31, 61): 'opts.output'}, {}), '(opts.model, opts.exchange, opts.output)', False, 'import autoencoder\n')]