Only allow 1-sized Libraries

This commit is contained in:
Jan Petykiewicz 2023-02-04 09:27:31 -08:00 committed by jan
parent 4a94259249
commit 4a6584a60a

View File

@ -587,12 +587,15 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
self.add(tree.library, rename_theirs=rename_theirs)
return name
def __lshift__(self, other: Mapping[str, 'Pattern']) -> Optional[str]:
def __lshift__(self, other: Mapping[str, 'Pattern']) -> str:
if isinstance(other, Tree):
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
lib.add(other)
if len(other) != 1:
raise LibraryError('Received a non-Tree library containing multiple cells')
name = next(iter(other))
self.add(other)
return name
def dedup(