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 committed by jan
parent 7cc732248e
commit 4a94259249

View File

@ -587,8 +587,13 @@ 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: 'Tree') -> str: def __lshift__(self, other: Mapping[str, 'Pattern']) -> Optional[str]:
return self.add_tree(other) 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( def dedup(
self: ML, self: ML,