From e7a1d1824a66b1ede136e38f47a56cafcd9f7b57 Mon Sep 17 00:00:00 2001 From: jan Date: Fri, 7 Apr 2023 18:13:21 -0700 Subject: [PATCH] add mktree --- masque/library.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/masque/library.py b/masque/library.py index 07c0326..45c6dd3 100644 --- a/masque/library.py +++ b/masque/library.py @@ -887,6 +887,17 @@ class Library(ILibrary): def __repr__(self) -> str: return f'' + @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): """