add mktree

This commit is contained in:
jan 2023-04-07 18:13:21 -07:00
parent 9c9d3c3928
commit e7a1d1824a

View File

@ -887,6 +887,17 @@ class Library(ILibrary):
def __repr__(self) -> str:
return f'<Library ({type(self.mapping)}) with keys\n' + pformat(list(self.keys())) + '>'
@classmethod
def mktree(cls, name: str) -> tuple['Tree', 'Pattern']:
"""
Create a new Library and immediately add a pattern
"""
from .pattern import Pattern
tree = cls()
pat = Pattern()
tree[name] = pat
return tree, pat
class LazyLibrary(ILibrary):
"""