Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Arguments:
* ``data`` (list): Database output from Ocelot system model
* ``database_name`` (str): Name of new database. Should not already exist in the current project.
"""
if not bw2:
raise ImportError("Brightway2 not found")
assert isinstance(database_name, str), "Database name must be a string"
print("Creating database `{}` in project `{}`".format(
database_name, bw2.projects.current)
)
assert database_name not in bw2.databases
# Don't store two copies in memory
data[:] = list(Brightway2Converter.convert_to_brightway2(data, database_name))
importer = LCIImporter(database_name)
# Already have products
del importer.strategies[2]
importer.data = data
importer.apply_strategies()
importer.match_database("biosphere3")
stats = importer.statistics()
if not stats[2]:
print("Writing database")
importer.write_database()
return bw2.Database(database_name)
else:
print("Unlinked exchanges; not writing database")
print(importer.statistics())
return importer