(self, input, final=False)
| 82 | self.i, self.o = i ^ 1, o ^ 1 |
| 83 | |
| 84 | def decode(self, input, final=False): |
| 85 | output = '' |
| 86 | for b in input: |
| 87 | if self.i == 0: # variable-length, terminated with period |
| 88 | if b == ord('.'): |
| 89 | if self.buffer: |
| 90 | output += self.process_word() |
| 91 | else: |
| 92 | self.buffer.append(b) |
| 93 | else: # fixed-length, terminate after self.i bytes |
| 94 | self.buffer.append(b) |
| 95 | if len(self.buffer) == self.i: |
| 96 | output += self.process_word() |
| 97 | if final and self.buffer: # EOF terminates the last word |
| 98 | output += self.process_word() |
| 99 | return output |
| 100 | |
| 101 | def process_word(self): |
| 102 | output = '' |
no test coverage detected