(self, input, final=False)
| 2742 | self.i, self.o = i ^ 1, o ^ 1 |
| 2743 | |
| 2744 | def decode(self, input, final=False): |
| 2745 | output = '' |
| 2746 | for b in input: |
| 2747 | if self.i == 0: # variable-length, terminated with period |
| 2748 | if b == ord('.'): |
| 2749 | if self.buffer: |
| 2750 | output += self.process_word() |
| 2751 | else: |
| 2752 | self.buffer.append(b) |
| 2753 | else: # fixed-length, terminate after self.i bytes |
| 2754 | self.buffer.append(b) |
| 2755 | if len(self.buffer) == self.i: |
| 2756 | output += self.process_word() |
| 2757 | if final and self.buffer: # EOF terminates the last word |
| 2758 | output += self.process_word() |
| 2759 | return output |
| 2760 | |
| 2761 | def process_word(self): |
| 2762 | output = '' |
no test coverage detected