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-11 18:34:22 +0100
commitfd7003f0348722e50121cad0f291d1a9f0a595dc (patch)
treeb54879b38cb2408e917b857536d28cb80dab32e5
parent2ab9c4524e2c2aa5bbb58d3ed69df17883737346 (diff)
downloadbuildstream-fd7003f0348722e50121cad0f291d1a9f0a595dc.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 db080289b..e2593d95e 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