# Path: lcopt/data_store.py
# class LcoptStorage():
#     def __init__(self):
#     def load_config(self):
#     def refresh(self):
#     def write_default_config(self):
#     def write_config(self, config):
#     def models(self):
#     def search_indices(self):
#     def project_type(self):
#     def single_project_name(self):
#     def ecoinvent_version(self):
#     def ecoinvent_system_model(self):
#     def save_option(self):
# 
# Path: lcopt/constants.py
# DEFAULT_PROJECT_STEM = "LCOPT_Setup_"
# 
# DEFAULT_BIOSPHERE_PROJECT = "LCOPT_Setup_biosphere"
# 
# DEFAULT_DB_NAME = DEFAULT_PROJECT_STEM[:-1]
# 
# FORWAST_PROJECT_NAME = DEFAULT_PROJECT_STEM + "Forwast"
# 
# FORWAST_URL = r"https://lca-net.com/wp-content/uploads/forwast.bw2package.zip"
# 
# ASSET_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets')
# 
# 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"


import tempfile
import requests
import zipfile
import io
import os
import eidl
import yaml
import pickle
import getpass
import socket
    import brightway2 as bw2
from functools import partial
from .data_store import storage
from .constants import (DEFAULT_PROJECT_STEM,
                        DEFAULT_BIOSPHERE_PROJECT,
                        DEFAULT_DB_NAME,
                        FORWAST_PROJECT_NAME,
                        FORWAST_URL,
                        ASSET_PATH,
                        DEFAULT_CONFIG,
                        DEFAULT_SINGLE_PROJECT)
try:
except:                                                         # pragma: no cover
    raise ImportError('Please install the brightway2 package first')




def lcopt_bw2_setup(ecospold_path, overwrite=False, db_name=None):  # pragma: no cover

    """
    Utility function to set up brightway2 to work correctly with lcopt.

    It requires the path to the ecospold files containing the Ecoinvent 3.3 cutoff database.

    If you don't have these files, log into `ecoinvent.org  <http://www.ecoinvent.org/login-databases.html>`_ and go to the Files tab

    Download the file called ``ecoinvent 3.3_cutoff_ecoSpold02.7z``

    Extract the file somewhere sensible on your machine, you might need to download `7-zip <http://www.7-zip.org/download.html>`_ to extract the files.

    Make a note of the path of the folder that contains the .ecospold files, its probably ``<path/extracted/to>/datasets/``

    Use this path (as a string) as the first parameter in this function

    To overwrite an existing version, set overwrite=True
    """
    default_ei_name = "Ecoinvent3_3_cutoff"

    if db_name is None:
        

# Path: lcopt/data_store.py
# class LcoptStorage():
#     def __init__(self):
#     def load_config(self):
#     def refresh(self):
#     def write_default_config(self):
#     def write_config(self, config):
#     def models(self):
#     def search_indices(self):
#     def project_type(self):
#     def single_project_name(self):
#     def ecoinvent_version(self):
#     def ecoinvent_system_model(self):
#     def save_option(self):
# 
# Path: lcopt/constants.py
# DEFAULT_PROJECT_STEM = "LCOPT_Setup_"
# 
# DEFAULT_BIOSPHERE_PROJECT = "LCOPT_Setup_biosphere"
# 
# DEFAULT_DB_NAME = DEFAULT_PROJECT_STEM[:-1]
# 
# FORWAST_PROJECT_NAME = DEFAULT_PROJECT_STEM + "Forwast"
# 
# FORWAST_URL = r"https://lca-net.com/wp-content/uploads/forwast.bw2package.zip"
# 
# ASSET_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'assets')
# 
# 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"


# Path: lcopt/utils.py
import tempfile
import requests
import zipfile
import io
import os
import eidl
import yaml
import pickle
import getpass
import socket
    import brightway2 as bw2
from functools import partial
from .data_store import storage
from .constants import (DEFAULT_PROJECT_STEM,
                        DEFAULT_BIOSPHERE_PROJECT,
                        DEFAULT_DB_NAME,
                        FORWAST_PROJECT_NAME,
                        FORWAST_URL,
                        ASSET_PATH,
                        DEFAULT_CONFIG,
                        DEFAULT_SINGLE_PROJECT)

try:
except:                                                         # pragma: no cover
    raise ImportError('Please install the brightway2 package first')




def lcopt_bw2_setup(ecospold_path, overwrite=False, db_name=None):  # pragma: no cover

    """
    Utility function to set up brightway2 to work correctly with lcopt.

    It requires the path to the ecospold files containing the Ecoinvent 3.3 cutoff database.

    If you don't have these files, log into `ecoinvent.org  <http://www.ecoinvent.org/login-databases.html>`_ and go to the Files tab

    Download the file called ``ecoinvent 3.3_cutoff_ecoSpold02.7z``

    Extract the file somewhere sensible on your machine, you might need to download `7-zip <http://www.7-zip.org/download.html>`_ to extract the files.

    Make a note of the path of the folder that contains the .ecospold files, its probably ``<path/extracted/to>/datasets/``

    Use this path (as a string) as the first parameter in this function

    To overwrite an existing version, set overwrite=True
    """
    default_ei_name = "Ecoinvent3_3_cutoff"

    if db_name is None:
        

        db_name = DEFAULT_PROJECT_STEM + default_ei_name