-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.py
38 lines (34 loc) · 1.4 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from brightway2 import *
import os, click
@click.command()
@click.option('--project_name', help='Name to give Brightway project', type=str)
@click.option('--ecospold_dirpath', help='Path to directory with ecoSPold2 files', type=str)
@click.option('--database_name', type=str, help='Name to give imported database')
@click.option('--overwrite_database', type=bool, default=False, help='Overwrite database if it already exists')
def setup(project_name, ecospold_dirpath, database_name, overwrite_database):
assert isinstance(project_name, str)
assert isinstance(database_name, str)
projects.set_current(project_name)
print("Created project {}".format(project_name))
bw2setup()
should_import=True
if database_name in databases:
if not overwrite_database:
print("Database {} already imported".format(database_name))
should_import = False
else:
print("Database {} already existed, it will be deleted".format(database_name))
Database(database_name).delete()
Database(database_name).deregister()
should_import=True
if should_import:
importer = SingleOutputEcospold2Importer(
dirpath=ecospold_dirpath,
db_name = database_name
)
importer.apply_strategies()
importer.write_database()
return None
if __name__ == "__main__":
__spec__ = None
setup()