File: customdata.py

package info (click to toggle)
pyro5 5.15-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,112 kB
  • sloc: python: 14,291; makefile: 163; sh: 66; javascript: 62
file content (26 lines) | stat: -rw-r--r-- 696 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# note: this module is shared with the listeners so they can understand the data passed in


class CustomData(object):
    serialized_classname = "blobdispatch.CustomData"

    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c

    def to_dict(self):
        """for (serpent) serialization"""
        return {
            "__class__": self.serialized_classname,
            "a": self.a,
            "b": self.b,
            "c": self.c
        }

    @classmethod
    def from_dict(cls, classname, d):
        """for (serpent) deserialization"""
        assert classname == cls.serialized_classname
        obj = cls(d["a"], d["b"], d["c"])
        return obj