From 3a9eca91b5138440429c4afac70a4b477f9a3497 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sun, 1 Nov 2020 19:34:47 -0800 Subject: [PATCH] add `addsp()` convenience function to Pattern --- masque/pattern.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/masque/pattern.py b/masque/pattern.py index ff3b8b5..bad19ac 100644 --- a/masque/pattern.py +++ b/masque/pattern.py @@ -806,6 +806,21 @@ class Pattern(LockableImpl, AnnotatableImpl, metaclass=AutoSlots): and len(self.shapes) == 0 and len(self.labels) == 0) + def addsp(self: P, *args: Any, **kwargs: Any) -> P: + """ + Convenience function which constructs a subpattern object and adds it + to this pattern. + + Args: + *args: Passed to `SubPattern()` + **kwargs: Passed to `SubPattern()` + + Returns: + self + """ + self.subpatterns.append(SubPattern(*args, **kwargs)) + return self + def lock(self: P) -> P: """ Lock the pattern, raising an exception if it is modified.