Only allow 1-sized Libraries

This commit is contained in:
Jan Petykiewicz 2023-02-04 09:27:31 -08:00
parent ee6d857cad
commit 369bad9ae4

View File

@ -587,12 +587,15 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
self.add(tree.library, rename_theirs=rename_theirs) self.add(tree.library, rename_theirs=rename_theirs)
return name return name
def __lshift__(self, other: Mapping[str, 'Pattern']) -> Optional[str]: def __lshift__(self, other: Mapping[str, 'Pattern']) -> str:
if isinstance(other, Tree): if isinstance(other, Tree):
return self.add_tree(other) # Add library and return topcell name return self.add_tree(other) # Add library and return topcell name
name = next(other.keys()) if len(other) == 1 else None # If only one name, return it if len(other) != 1:
lib.add(other) raise LibraryError('Received a non-Tree library containing multiple cells')
name = next(iter(other))
self.add(other)
return name return name
def dedup( def dedup(