diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-07-16 12:41:09 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-24 12:27:10 +0000 |
commit | e02a2dcfe18fd3374c28624dcc61dbb3244630a9 (patch) | |
tree | b4b781a95d2670fd97d4e47e205bea92f8e030c0 /src/buildstream/node.pyx | |
parent | ab3b89f1fe412afea6daed5cf5a5a9703c4db09d (diff) | |
download | buildstream-e02a2dcfe18fd3374c28624dcc61dbb3244630a9.tar.gz |
node: picklable {Scalar,Mapping,Sequence}Node
Make ScalarNode, MappingNode, and SequenceNode pickable by implementing
`__reduce__` for them.
Diffstat (limited to 'src/buildstream/node.pyx')
-rw-r--r-- | src/buildstream/node.pyx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/buildstream/node.pyx b/src/buildstream/node.pyx index 8a66514e1..ea63151b9 100644 --- a/src/buildstream/node.pyx +++ b/src/buildstream/node.pyx @@ -289,6 +289,12 @@ cdef class ScalarNode(Node): self.value = value + def __reduce__(self): + return ( + ScalarNode.__new__, + (ScalarNode, self.file_index, self.line, self.column, self.value), + ) + ############################################################# # Public Methods # ############################################################# @@ -435,6 +441,12 @@ cdef class MappingNode(Node): def __cinit__(self, int file_index, int line, int column, dict value): self.value = value + def __reduce__(self): + return ( + MappingNode.__new__, + (MappingNode, self.file_index, self.line, self.column, self.value), + ) + def __contains__(self, what): return what in self.value @@ -1078,6 +1090,12 @@ cdef class SequenceNode(Node): def __cinit__(self, int file_index, int line, int column, list value): self.value = value + def __reduce__(self): + return ( + SequenceNode.__new__, + (SequenceNode, self.file_index, self.line, self.column, self.value), + ) + def __iter__(self): return iter(self.value) |