Allow lshift to operate on any library. If only one name, return it, else None

This commit is contained in:
Jan Petykiewicz 2023-02-04 09:08:05 -08:00
parent 5e2018a1a1
commit ee6d857cad

View File

@ -587,8 +587,13 @@ class MutableLibrary(Library, MutableMapping[str, 'Pattern'], metaclass=ABCMeta)
self.add(tree.library, rename_theirs=rename_theirs)
return name
def __lshift__(self, other: 'Tree') -> str:
return self.add_tree(other)
def __lshift__(self, other: Mapping[str, 'Pattern']) -> Optional[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)
return name
def dedup(
self: ML,