From 4ca2dc4cd63647c222d927043e94b60a6d11b4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 15 Nov 2012 11:17:02 +0100 Subject: add JsonPointer.contains() --- jsonpointer.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'jsonpointer.py') diff --git a/jsonpointer.py b/jsonpointer.py index fe3cecf..80d5b50 100644 --- a/jsonpointer.py +++ b/jsonpointer.py @@ -265,6 +265,12 @@ class JsonPointer(object): + def contains(self, ptr): + """" Returns True if self contains the given ptr """ + return len(self.parts) > len(ptr.parts) and \ + self.parts[:len(ptr.parts)] == ptr.parts + + def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) -- cgit v1.2.1