Skip to content

Add a generator/iterator method to retrieve detailed assemblies #2156

@drewj-tp

Description

@drewj-tp

The history tracker has two get* methods for retrieving detailed assemblies and blocks

  • getDetailAssemblies
  • getDetailBlocks

def getDetailAssemblies(self) -> list["Assembly"]:
"""Returns the assemblies that have been signaled as detail assemblies."""
assems = []
if not self.detailAssemblyNames:
runLog.info("No detail assemblies HistoryTrackerInterface")
for name in self.detailAssemblyNames:
try:
assems.append(self.r.core.getAssemblyByName(name))
except KeyError:
if name in {a.name for a in self.r.core}:
raise Exception("Found it")
runLog.warning(
"Cannot find detail assembly {} in assemblies-by-name lookup table, which has {} entries".format(
name, len(self.r.core.assembliesByName)
)
)
return assems
def getDetailBlocks(self) -> list["Block"]:
"""Get all blocks in all detail assemblies."""
return [block for a in self.getDetailAssemblies() for block in a]

An iterator approach would be useful for cases where a client (me in this case) may not want a list of all the assemblies / blocks because that could be manifold.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions