"""Helpers for printing out credits for software use"""

"""
This file is part of RAPD

Copyright (C) 2017, Cornell University
All rights reserved.

RAPD is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3.

RAPD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

__created__ = "2017-04-24"
__maintainer__ = "YFrank Murphy"
__email__ = "fmurphy@anl.gov"
__status__ = "Development"

# Standard imports
import sys

HEADER = "\nRAPD depends on the work of others"

BEST = [
    "BEST",
    "Reference: Bourenkov GP and Popov AN (2006) Acta Cryst. D62:58-64",
    "Website: http://www.embl-hamburg.de/BEST/\n"
]

CCTBX = [
    "CCTBX - Computational Crystallography Toolbox",
    "Reference: Grosse-Kunstleve et al (2002) J. Appl. Cryst. 35:126-136",
    "Website: https://cctbx.github.io/\n"
]

MOLREP = [
    "Molrep",
    "Reference: Vagin A and Teplyakov A (1997) J. Appl. Cryst. 30:1022-1025",
    "Website: http://www.ccp4.ac.uk/html/molrep.html\n"
]

MOSFLM = [
    "Mosflm",
    "Reference: Leslie AGW (1992) Joint CCP4 + ESF-EAMCB Newsletter on Protein Crystallography, No.\
 26",
    "Website: http://www.mrc-lmb.cam.ac.uk/harry/mosflm/\n"
]

PHASER = [
    "Phaser",
    "Reference: McCoy AJ, et al. (2007) J. Appl. Cryst. 40:658-674",
    "Website: http://www.phenix-online.org/documentation/phaser.htm\n"
]

PHENIX = [
    "Phenix",
    "Reference: Sauter NK, et al. (2004) J. Appl. Cryst. 37:399-409",
    "Website:   http://adder.lbl.gov/labelit/\n",
]

RADDOSE = [
    "Raddose",
    "Reference: Paithankar, et al. (2009) J. Synch. Rad. 16:152-162",
    "Website:   http://biop.ox.ac.uk/www/garman/lab_tools.html/\n",
]

MAIN_MODULE = sys.modules[__name__]

def get_credit(requested_program="PHENIX"):
    """Return credit lines for requested program"""
    return getattr(MAIN_MODULE, requested_program.upper())

def get_credits_text(programs, indent=""):
    """Return text for printing out credits"""

    return_text = ""

    for program in programs:
        raw_lines = get_credit(program.upper())
        for line in raw_lines:
            return_text += (indent + line + "\n")

    return return_text

@@ -901,16 +901,170 @@
 thers%22%0A%0A
+AIMLESS = %5B%0A    %22Aimless%22%0A    %22Reference: Evans PR (2006) Acta Cryst. D62:72-82.%22,%0A    %22Website: http://www.mrc-lmb.cam.ac.uk/harry/pre/aimless.html%22,%0A%5D%0A%0A
 BEST = %5B
@@ -1202,16 +1202,120 @@
 /%5Cn%22%0A%5D%0A%0A
+CCP4 = %5B%0A    %22CCP4%22,%0A    %22Reference: Acta Cryst. D50:760-763%22,%0A    %22Website: http://www.ccp4.ac.uk%22,%0A%5D%0A%0A
 CCTBX = 
@@ -2162,16 +2162,177 @@
 %5Cn%22,%0A%5D%0A%0A
+POINTLESS = %5B%0A    %22Pointless%22,%0A    %22Reference: Evans PR (2006) Acta Cryst. D62:72-82.%22,%0A    %22Website: http://www.mrc-lmb.cam.ac.uk/harry/pre/pointless.html%22,%0A%5D%0A%0A
 RADDOSE 
@@ -2491,16 +2491,148 @@
 %5Cn%22,%0A%5D%0A%0A
+XDS = %5B%0A    %22XDS%22,%0A    %22Reference: Kabsch W (2010) Acta Cryst. D66:125-132%22,%0A    %22Website: http://xds.mpimf-heidelberg.mpg.de/%22,%0A%5D%0A%0A
 MAIN_MOD

Add some more software to the credits