GreenDelta / olca-ipc.py

Mozilla Public License 2.0
29 stars 17 forks source link

Returning list of flows (or other entities) with the same name #34

Closed ywang542 closed 1 month ago

ywang542 commented 3 months ago

My database has multiple flows with same name, they are used for different circumstances. I wonder if a function could be added for returning the flows (or other entities) with the same name as a list?

msrocka commented 1 month ago

I think it is not necessary to add this, as it is easy to do already with the existing functions:

import olca_schema as o
import olca_ipc as ipc

client = ipc.Client()
name = "(+-)-Citronellol"

# get the flow descriptors with the respective name
flow_infos = [f for f in client.get_descriptors(o.Flow) if f.name == name]

# do something with the full flow objects
for info in flow_infos:
    flow = client.get(o.Flow, info.id)
    print(f"id={flow.id}, category={flow.category}")