Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relinking #1015

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion activity_browser/controllers/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import brightway2 as bw
from bw2data.backends.peewee.proxies import Activity, ExchangeProxyBase
from PySide2.QtCore import QObject, Slot
from PySide2.QtCore import QObject, Slot, Qt
from PySide2 import QtWidgets

from activity_browser.bwutils import AB_metadata, commontasks as bc
Expand Down Expand Up @@ -217,10 +217,12 @@ def relink_activity_exchange(self, key: tuple) -> None:
dialog = ActivityLinkingDialog.relink_sqlite(actvty['name'], options, self.window)
relinking_results = {}
if dialog.exec_() == ActivityLinkingDialog.Accepted:
QtWidgets.QApplication.setOverrideCursor(Qt.WaitCursor)
for old, new in dialog.relink.items():
other = bw.Database(new)
failed, succeeded, examples = relink_activity_exchanges(actvty, old, other)
relinking_results[f"{old} --> {other.name}"] = (failed, succeeded)
QtWidgets.QApplication.restoreOverrideCursor()
if failed > 0:
relinking_dialog = ActivityLinkingResultsDialog.present_relinking_results(self.window, relinking_results, examples)
relinking_dialog.exec_()
Expand Down
4 changes: 3 additions & 1 deletion activity_browser/controllers/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bw2data.backends.peewee import sqlite3_lci_db
from bw2data.parameters import Group
from PySide2 import QtWidgets
from PySide2.QtCore import QObject, Slot
from PySide2.QtCore import QObject, Slot, Qt

from ..bwutils import commontasks as bc
from ..bwutils.strategies import relink_exchanges_existing_db
Expand Down Expand Up @@ -136,10 +136,12 @@ def relink_database(self, db_name: str) -> None:
relinking_results = dict()
if dialog.exec_() == DatabaseLinkingDialog.Accepted:
# Now, start relinking.
QtWidgets.QApplication.setOverrideCursor(Qt.WaitCursor)
for old, new in dialog.relink.items():
other = bw.Database(new)
failed, succeeded, examples = relink_exchanges_existing_db(db, old, other)
relinking_results[f"{old} --> {other.name}"] = (failed, succeeded)
QtWidgets.QApplication.restoreOverrideCursor()
if failed > 0:
relinking_dialog = DatabaseLinkingResultsDialog.present_relinking_results(self.window, relinking_results, examples)
relinking_dialog.exec_()
Expand Down
Loading