@@ -131,15 +131,30 @@ def build_df(self, exchanges) -> pd.DataFrame:
131131
132132 # Create a DataFrame from the exchanges
133133 exc_df = pd .DataFrame (exchanges , columns = ["amount" , "input" , "formula" , "uncertainty type" , "comment" ])
134+ exc_df ["type" ] = [x ["type" ] for x in exchanges ]
134135 act_df = AB_metadata .get_metadata (exc_df ["input" ].unique (), cols )
135136
137+ processor_keys = act_df ["processor" ].dropna ().unique ()
138+ processor_df = AB_metadata .get_metadata (processor_keys , ["key" , "name" ]).rename ({"name" : "processor_name" }, axis = "columns" )
139+
136140 # Merge the exchanges DataFrame with the metadata DataFrame
137141 df = exc_df .merge (
138142 act_df ,
139143 left_on = "input" ,
140144 right_on = "key"
141145 ).drop (columns = ["key" ])
142146
147+ df = df .merge (
148+ processor_df ,
149+ left_on = "processor" ,
150+ right_on = "key" ,
151+ how = "left" ,
152+ ).drop (columns = ["key" ])
153+
154+ # Use "product" if available otherwise use "name"
155+ df ["producer" ] = df [df ["type" ].isin (["technosphere" ])]["name" ]
156+ df .update (df ["processor_name" ].rename ("producer" ))
157+
143158 # Use "product" if available otherwise use "name"
144159 df .update (df ["product" ].rename ("name" ))
145160
@@ -179,7 +194,7 @@ def build_df(self, exchanges) -> pd.DataFrame:
179194 axis = "columns" , inplace = True )
180195
181196 # Define the order of columns for the final DataFrame
182- cols = ["amount" , "unit" , "name" , "location" , "categories" , "database" ]
197+ cols = ["amount" , "unit" , "name" , "producer" , " location" , "categories" , "database" ]
183198 cols += ["substitute_name" , "substitution_factor" ] if "substitute_name" in df .columns else []
184199 cols += ["allocation_factor" ] if not database_is_legacy (self .activity .get ("database" )) else []
185200 cols += [col for col in df .columns if col .startswith ("property" )]
@@ -243,7 +258,6 @@ def get_exchange_type(activity_key: tuple) -> str | None:
243258 return None
244259
245260
246-
247261class DropOverlay (QtWidgets .QWidget ):
248262 def __init__ (self , parent = None ):
249263 super ().__init__ (parent )
@@ -553,7 +567,7 @@ def decorationData(self, col, key):
553567 Returns:
554568 The decoration data for the item.
555569 """
556- if key not in ["name" , "substitute_name" , "amount" ] or not self .displayData (col , key ):
570+ if key not in ["name" , "substitute_name" , "amount" , "producer" ] or not self .displayData (col , key ):
557571 return
558572
559573 if key == "amount" :
@@ -562,6 +576,9 @@ def decorationData(self, col, key):
562576 return icons .qicons .empty
563577 return icons .qicons .parameterized
564578
579+ if key == "producer" and self ["producer" ]:
580+ return icons .qicons .process
581+
565582 if key == "name" :
566583 activity_type = self .exchange .input .get ("type" )
567584 else : # key is "substitute_name"
0 commit comments