Pass more data into the parser. As much as possible is processed - but nothing is returned from this method.
(self, data)
| 54 | return data |
| 55 | |
| 56 | def feed(self, data): |
| 57 | """Pass more data into the parser. |
| 58 | As much as possible is processed - but nothing is returned from this method. |
| 59 | """ |
| 60 | self.index = -1 |
| 61 | self.tempindex = 0 |
| 62 | self.buffer = self.buffer + data |
| 63 | outlist = [] |
| 64 | thischunk = [] |
| 65 | while self.index < len(self.buffer)-1: # rewrite with a list of all the occurences of '<' and jump between them, much faster than character by character - which is fast enough to be fair... |
| 66 | self.index += 1 |
| 67 | inchar = self.buffer[self.index] |
| 68 | if inchar == '<': |
| 69 | outlist.append(self.pdata(''.join(thischunk))) |
| 70 | thischunk = [] |
| 71 | result = self.tagstart() |
| 72 | if result: outlist.append(result) |
| 73 | if self.tempindex: break |
| 74 | else: |
| 75 | thischunk.append(inchar) |
| 76 | if self.tempindex: |
| 77 | self.buffer = self.buffer[self.tempindex:] |
| 78 | else: |
| 79 | self.buffer = '' |
| 80 | if thischunk: self.buffer = ''.join(thischunk) |
| 81 | self.outfile = self.outfile + ''.join(outlist) |
| 82 | |
| 83 | def tagstart(self): |
| 84 | """We have reached the start of a tag. |
no test coverage detected