# Path: lcopt/constants.py
# ASSET_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets')
# 
# BIOSPHERE_SI = 'biosphere3.pickle'
# 
# FORWAST_SI = 'forwast.pickle'
# 
# ECOINVENT_EXAMPLE = 'ecoinvent_example.lcopt'
# 
# FORWAST_EXAMPLE = 'forwast_example.lcopt'
# 
# DEFAULT_CONFIG = {
#     'ecoinvent':{
#     	'username': None,
#     	'password': None,
#         'version': DEFAULT_ECOINVENT_VERSION,
#         'system_model': DEFAULT_ECOINVENT_SYSTEM_MODEL,
#     },
#     'model_storage': {
#         'location': DEFAULT_SAVE_OPTION,
#         'project': DEFAULT_PROJECT_TYPE,
#         },
#     }
# 
# DEFAULT_SINGLE_PROJECT = "LCOPT_Models"
# 
# DEFAULT_ECOINVENT_VERSION = '3.3'
# 
# DEFAULT_ECOINVENT_SYSTEM_MODEL = 'cutoff'
# 
# DEFAULT_SAVE_OPTION = 'appdir'
# 
# DEFAULT_PROJECT_TYPE = 'unique'


import os
import yaml
import glob
import shutil
import appdirs
from .constants import (ASSET_PATH,
                        BIOSPHERE_SI, 
                        FORWAST_SI, 
                        ECOINVENT_EXAMPLE, 
                        FORWAST_EXAMPLE,
                        DEFAULT_CONFIG,
                        DEFAULT_SINGLE_PROJECT,
                        DEFAULT_ECOINVENT_VERSION,
                        DEFAULT_ECOINVENT_SYSTEM_MODEL,
                        DEFAULT_SAVE_OPTION,
                        DEFAULT_PROJECT_TYPE)



class LcoptStorage():
    def __init__(self):
        self.lcopt_dir = appdirs.user_data_dir(
            appname='Lcopt',
            appauthor='Lcopt'
        )
        if not os.path.isdir(self.lcopt_dir):
            os.makedirs(self.lcopt_dir)

        # Models
        self.model_dir = os.path.join(self.lcopt_dir, 'models')
        if not os.path.isdir(self.model_dir):
            os.mkdir(self.model_dir)

        # Copy the example models
        if not os.path.isfile(os.path.join(self.model_dir, ECOINVENT_EXAMPLE)):

# Path: lcopt/constants.py
# ASSET_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets')
# 
# BIOSPHERE_SI = 'biosphere3.pickle'
# 
# FORWAST_SI = 'forwast.pickle'
# 
# ECOINVENT_EXAMPLE = 'ecoinvent_example.lcopt'
# 
# FORWAST_EXAMPLE = 'forwast_example.lcopt'
# 
# DEFAULT_CONFIG = {
#     'ecoinvent':{
#     	'username': None,
#     	'password': None,
#         'version': DEFAULT_ECOINVENT_VERSION,
#         'system_model': DEFAULT_ECOINVENT_SYSTEM_MODEL,
#     },
#     'model_storage': {
#         'location': DEFAULT_SAVE_OPTION,
#         'project': DEFAULT_PROJECT_TYPE,
#         },
#     }
# 
# DEFAULT_SINGLE_PROJECT = "LCOPT_Models"
# 
# DEFAULT_ECOINVENT_VERSION = '3.3'
# 
# DEFAULT_ECOINVENT_SYSTEM_MODEL = 'cutoff'
# 
# DEFAULT_SAVE_OPTION = 'appdir'
# 
# DEFAULT_PROJECT_TYPE = 'unique'


# Path: lcopt/data_store.py
import os
import yaml
import glob
import shutil
import appdirs
from .constants import (ASSET_PATH,
                        BIOSPHERE_SI, 
                        FORWAST_SI, 
                        ECOINVENT_EXAMPLE, 
                        FORWAST_EXAMPLE,
                        DEFAULT_CONFIG,
                        DEFAULT_SINGLE_PROJECT,
                        DEFAULT_ECOINVENT_VERSION,
                        DEFAULT_ECOINVENT_SYSTEM_MODEL,
                        DEFAULT_SAVE_OPTION,
                        DEFAULT_PROJECT_TYPE)




class LcoptStorage():
    def __init__(self):
        self.lcopt_dir = appdirs.user_data_dir(
            appname='Lcopt',
            appauthor='Lcopt'
        )
        if not os.path.isdir(self.lcopt_dir):
            os.makedirs(self.lcopt_dir)

        # Models
        self.model_dir = os.path.join(self.lcopt_dir, 'models')
        if not os.path.isdir(self.model_dir):
            os.mkdir(self.model_dir)

        # Copy the example models
        if not os.path.isfile(os.path.join(self.model_dir, ECOINVENT_EXAMPLE)):

            shutil.copy(os.path.join(ASSET_PATH, ECOINVENT_EXAMPLE), os.path.join(self.model_dir, ECOINVENT_EXAMPLE))