#!/usr/bin/env python

"""This script reruns the `create_results_summary.py` script for a named case."""

# ############################ LICENSE INFORMATION ############################
# This file is part of the E3 RESOLVE Model.

# Copyright (C) 2019 Energy and Environmental Economics, Inc.
# For contact information, go to www.ethree.com

# The E3 RESOLVE Model 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, either version 3 of the License, or
# (at your option) any later version.

# The E3 RESOLVE Model 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 the E3 RESOLVE Model (in the file LICENSE.TXT). If not,
# see <http://www.gnu.org/licenses/>.
# #############################################################################

import os
import sys

import create_results_summary
import util


def main():
    """Main methods that reruns `create_results_summary.create_summaries()`."""

    # Scenario to run is given as first script argument (0th argument is the script name)
    # this must be the same name as a folder in the 'inputs' directory
    scenario_name = sys.argv[1]

    code_directory = os.getcwd()

    dir_str = util.DirStructure(code_directory, scenario_name)
    dir_str.make_directories()
    dir_str.get_feature_toggles()

    # Directories
    scenario_results_directory = os.path.join(
        dir_str.SCENARIO_RESULTS_DIRECTORY
    )

    # Create results summaries
    create_results_summary.create_summaries(scenario_results_directory)

    print('Done rerunning results summary for scenario: {}.'.format(scenario_name))


if __name__ == "__main__":
    main()
