From ee6d857cad2e2643376ce06a2348eb132f370c6b Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 4 Feb 2023 09:08:05 -0800 Subject: [PATCH] Allow lshift to operate on any library. If only one name, return it, else None --- masque/library.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/masque/library.py b/masque/library.py index e121636..0114d49 100644 --- a/masque/library.py +++ b/masque/library.py @@ -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,