Skip to content

Commit e6fa005

Browse files
committed
refactor: use extract of ecoinvent
still have a fallback if the provided file is 7z
1 parent bd5c355 commit e6fa005

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

activity_browser/ui/wizards/db_import_wizard.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import io
3+
import os.path
34
import shutil
45
import typing
56
from functools import lru_cache
@@ -824,13 +825,17 @@ def run_ecoinvent(self) -> None:
824825
"""Run the ecoinvent downloader from start to finish."""
825826
archive_file = self.run_download()
826827

827-
with tempfile.TemporaryDirectory() as tempdir:
828-
temp_dir = Path(tempdir)
829-
if not import_signals.cancel_sentinel:
830-
self.run_extract(archive_file, temp_dir)
831-
if not import_signals.cancel_sentinel:
832-
dataset_dir = temp_dir.joinpath("datasets")
833-
self.run_import(dataset_dir)
828+
if os.path.isdir(archive_file):
829+
import_signals.unarchive_finished.emit()
830+
self.run_import(archive_file.joinpath("datasets"))
831+
else:
832+
with tempfile.TemporaryDirectory() as tempdir:
833+
temp_dir = Path(tempdir)
834+
if not import_signals.cancel_sentinel:
835+
self.run_extract(archive_file, temp_dir)
836+
if not import_signals.cancel_sentinel:
837+
dataset_dir = temp_dir.joinpath("datasets")
838+
self.run_import(dataset_dir)
834839

835840
def run_forwast(self) -> None:
836841
"""Adapted from pjamesjoyce/lcopt."""
@@ -1503,7 +1508,7 @@ def download(self) -> Path:
15031508
version=self.version,
15041509
system_model=self.system_model,
15051510
release_type=self.release_type,
1506-
extract=False,
1511+
extract=True,
15071512
)
15081513

15091514
@staticmethod

0 commit comments

Comments
 (0)