#!/opt/anaconda1anaconda2anaconda3/bin/python
# -*- coding: utf-8
"""A script to upgrade the description in an anvi'o db"""

import sys
import argparse

import anvio
import anvio.dbops as dbops
import anvio.terminal as terminal

from anvio.errors import ConfigError, FilesNPathsError


__author__ = "Developers of anvi'o (see AUTHORS.txt)"
__copyright__ = "Copyleft 2015-2018, the Meren Lab (http://merenlab.org/)"
__credits__ = []
__license__ = "GPL 3.0"
__version__ = anvio.__version__
__maintainer__ = "A. Murat Eren"
__email__ = "a.murat.eren@gmail.com"


run = terminal.Run()

def main(args):
    dbops.update_description_in_db_from_file(args.db_path, args.description)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Update the description in an anvi'o database")

    parser.add_argument('db_path', metavar='DB', help="An anvi'o database.")
    parser.add_argument(*anvio.A('description'), **anvio.K('description', {'required': True}))

    args = anvio.get_args(parser)

    try:
        main(args)
    except ConfigError as e:
        print(e)
        sys.exit(-1)
    except FilesNPathsError as e:
        print(e)
        sys.exit(-1)
