| 12 | self.otypes = otypes |
| 13 | |
| 14 | def _inputs(self, *args): |
| 15 | if len(args) != len(self.itypes): |
| 16 | raise ValueError("Expect {} args, got {}".format( |
| 17 | len(self.itypes), len(args))) |
| 18 | |
| 19 | # type check |
| 20 | ipkts = [] |
| 21 | for i, v in enumerate(args): |
| 22 | if v is not None: |
| 23 | if self.itypes[i] is not None and not isinstance( |
| 24 | v, self.itypes[i]): |
| 25 | raise ValueError( |
| 26 | "Expect {}th arg type is {}, got {}".format( |
| 27 | i, self.itype[i], type(v))) |
| 28 | # else empty Packet will construct from None |
| 29 | ipkts.append(sdk.Packet(v)) |
| 30 | |
| 31 | return ipkts |
| 32 | |
| 33 | def __call__(self, *args): |
| 34 | """ |