# -*- coding: UTF-8 -*-
# Python
"""
07-12-2022
@author: jeremy auclair
"""
# Create class that contains configuration file data

from json import load  # to open config file


class config:
    """
    The `Config` class contains input parameters necessary for the modspa chain to run.
    
    It loads all these parameters from the ``.json`` input file and loads it automatically.

    Attributes
    ==========
    
    - start_date: ``str``
    - end_date: ``str``
    - mode: ``str``
    - run_name: ``str``
    - path_to_eodag_config_file: ``str``
    - preferred_provider: ``str``
    - cloud_cover_limit: ``int``
    - data_path: ``str``
    - output_path: ``str``
    - soil_path: ``str``
    - landcover_path: ``str``
    - irrigation_mask_path: ``str``
    - shapefile_path: ``str``
    - param_csv_file: ``str``
    - init_RU_path: ``str``
    - resolution: ``int``
    - ndvi_overwrite: ``bool``
    - weather_overwrite: ``bool``
    - open_browser: ``bool``
    - max_cpu: ``int``
    - max_ram: ``int``
    - compress_outputs: ``bool``
    - additional_output: ``dict``
    - parcel_shapefile_vars: ``list``
    """

    # Constructor 
    def __init__(self, config_file: str) -> None:

        # Load json file
        with open(config_file, "r") as read_file:
            input_data = load(read_file)

        # Add attributes in new object
        for key, value in input_data.items():
            setattr(self, key.strip(), value)