Skip to content

Commit b7b14ed

Browse files
committed
Opening processes using duck-typing
1 parent 8247f03 commit b7b14ed

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

activity_browser/actions/activity/activity_open.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def run(activities: list[tuple | int | bd.Node]):
5050

5151
for act in activities:
5252
# Check if the activity type is supported
53-
if act.get("type") not in ["process", "nonfunctional", "multifunctional", "processwithreferenceproduct"]:
53+
if not bwutils.is_node_process(act):
5454
log.warning(f"Can't open activity {act.key} - opening type: `{act.get('type')}` not supported")
5555
continue
5656

activity_browser/bwutils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .commontasks import cleanup_deleted_bw_projects as cleanup
99
from .commontasks import (refresh_node, refresh_node_or_none, refresh_parameter, refresh_edge, refresh_edge_or_none,
1010
parameters_in_scope, exchanges_to_sdf, database_is_locked, database_is_legacy, projects_by_last_opened,
11-
node_group, is_node_product, is_node_biosphere)
11+
node_group, is_node_product, is_node_biosphere, is_node_process)
1212
from .metadata import AB_metadata
1313
from .montecarlo import MonteCarloLCA
1414
from .multilca import MLCA, Contributions

activity_browser/bwutils/commontasks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ def is_node_biosphere(node: tuple | int | bd.Node) -> bool:
216216
return True
217217
return False
218218

219+
def is_node_process(node: tuple | int | bd.Node) -> bool:
220+
node = refresh_node(node)
221+
raw_type = node._document.type
222+
223+
if raw_type in ["process", "nonfunctional", "multifunctional", "processwithreferenceproduct"]:
224+
return True
225+
return False
226+
219227

220228
def refresh_node(node: tuple | int | bd.Node) -> bd.Node:
221229
if isinstance(node, bd.Node):

0 commit comments

Comments
 (0)