lshift operator shouldn't special-case trees

Instead, just call .tops() if there are multiple cells, and fail if
there are multiple tops
This commit is contained in:
jan 2023-04-07 15:29:14 -07:00
parent 438b81e62e
commit e8b5c7dec8

View File

@ -586,13 +586,18 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
return rename_map.get(name, name)
def __lshift__(self, other: Mapping[str, 'Pattern']) -> str:
if isinstance(other, Tree):
return self.add_tree(other) # Add library and return topcell name
# if isinstance(other, Tree):
# return self.add_tree(other) # Add library and return topcell name
if len(other) != 1:
raise LibraryError('Received a non-Tree library containing multiple cells')
if len(other) == 1:
name = next(iter(other))
else:
tops = other.tops()
if len(other.tops()) > 1:
raise LibraryError('Received a library containing multiple topcells!')
name = tops[0]
name = next(iter(other))
rename_map = self.add(other)
return rename_map.get(name, name)