# Path: lcopt/utils.py
# 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
# 
#     if db_name in bw2.projects:
#         if overwrite:                                           
#             bw2.projects.delete_project(name=db_name, delete_dir=True)
#         else:
#             print('Looks like bw2 is already set up - if you want to overwrite the existing version run lcopt.utils.lcopt_bw2_setup in a python shell using overwrite = True')
#             return False
# 
#     bw2.projects.set_current(db_name)
#     bw2.bw2setup()
#     ei = bw2.SingleOutputEcospold2Importer(fix_mac_path_escapes(ecospold_path), default_ei_name)
#     ei.apply_strategies()
#     ei.statistics()
#     ei.write_database()
# 
#     return True


from sys import argv
from lcopt.utils import lcopt_bw2_setup


def main():
    ecospold_path = argv[1]
    lcopt_bw2_setup(ecospold_path)


if __name__ == "__main__":

# Path: lcopt/utils.py
# 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
# 
#     if db_name in bw2.projects:
#         if overwrite:                                           
#             bw2.projects.delete_project(name=db_name, delete_dir=True)
#         else:
#             print('Looks like bw2 is already set up - if you want to overwrite the existing version run lcopt.utils.lcopt_bw2_setup in a python shell using overwrite = True')
#             return False
# 
#     bw2.projects.set_current(db_name)
#     bw2.bw2setup()
#     ei = bw2.SingleOutputEcospold2Importer(fix_mac_path_escapes(ecospold_path), default_ei_name)
#     ei.apply_strategies()
#     ei.statistics()
#     ei.write_database()
# 
#     return True


# Path: lcopt/bin/lcopt_bw2_setup.py
from sys import argv
from lcopt.utils import lcopt_bw2_setup



def main():
    ecospold_path = argv[1]
    lcopt_bw2_setup(ecospold_path)


if __name__ == "__main__":

    main()