summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-09 17:10:22 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-09 17:10:22 +0100
commitf57d4a75a186a9503674ef6fb83a8aef0ea6b4f2 (patch)
tree4d503449162a5c7c6ecbdfd2ff1c20dbac125ab2
parentd62697c988019cc83dfd37df74233a3867e18168 (diff)
downloadbuildstream-f57d4a75a186a9503674ef6fb83a8aef0ea6b4f2.tar.gz
_yaml: Move '__contains__' to MappingNode
This method is only ever used in this context and should not be on the base Node anyways
-rw-r--r--src/buildstream/_yaml.pyx9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index 1b4a9ca4c..30b44192b 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -85,12 +85,6 @@ cdef class Node:
cdef bint _shares_position_with(self, Node target):
return self.file_index == target.file_index and self.line == target.line and self.column == target.column
- def __contains__(self, what):
- # Delegate to the inner value, though this will likely not work
- # very well if the node is a list or string, it's unlikely that
- # code which has access to such nodes would do this.
- return what in (<MappingNode> self).value
-
cpdef Node copy(self):
raise NotImplementedError()
@@ -225,6 +219,9 @@ cdef class MappingNode(Node):
def __cinit__(self, int file_index, int line, int column, dict value):
self.value = value
+ def __contains__(self, what):
+ return what in self.value
+
cpdef MappingNode copy(self):
cdef dict copy = {}
cdef str key