(self, end)
| 131 | # and data to be processed by a subsequent call. If 'end' is |
| 132 | # true, force handling all data as if followed by EOF marker. |
| 133 | def goahead(self, end): |
| 134 | rawdata = self.rawdata |
| 135 | i = 0 |
| 136 | n = len(rawdata) |
| 137 | while i < n: |
| 138 | if self.convert_charrefs and not self.cdata_elem: |
| 139 | j = rawdata.find('<', i) |
| 140 | if j < 0: |
| 141 | # if we can't find the next <, either we are at the end |
| 142 | # or there's more text incoming. If the latter is True, |
| 143 | # we can't pass the text to handle_data in case we have |
| 144 | # a charref cut in half at end. Try to determine if |
| 145 | # this is the case before proceeding by looking for an |
| 146 | # & near the end and see if it's followed by a space or ;. |
| 147 | amppos = rawdata.rfind('&', max(i, n-34)) |
| 148 | if (amppos >= 0 and |
| 149 | not re.compile(r'[\s;]').search(rawdata, amppos)): |
| 150 | break # wait till we get all the text |
| 151 | j = n |
| 152 | else: |
| 153 | match = self.interesting.search(rawdata, i) # < or & |
| 154 | if match: |
| 155 | j = match.start() |
| 156 | else: |
| 157 | if self.cdata_elem: |
| 158 | break |
| 159 | j = n |
| 160 | if i < j: |
| 161 | if self.convert_charrefs and not self.cdata_elem: |
| 162 | self.handle_data(unescape(rawdata[i:j])) |
| 163 | else: |
| 164 | self.handle_data(rawdata[i:j]) |
| 165 | i = self.updatepos(i, j) |
| 166 | if i == n: break |
| 167 | startswith = rawdata.startswith |
| 168 | if startswith('<', i): |
| 169 | if starttagopen.match(rawdata, i): # < + letter |
| 170 | k = self.parse_starttag(i) |
| 171 | elif startswith("</", i): |
| 172 | k = self.parse_endtag(i) |
| 173 | elif startswith("<!--", i): |
| 174 | k = self.parse_comment(i) |
| 175 | elif startswith("<?", i): |
| 176 | k = self.parse_pi(i) |
| 177 | elif startswith("<!", i): |
| 178 | k = self.parse_html_declaration(i) |
| 179 | elif (i + 1) < n: |
| 180 | self.handle_data("<") |
| 181 | k = i + 1 |
| 182 | else: |
| 183 | break |
| 184 | if k < 0: |
| 185 | if not end: |
| 186 | break |
| 187 | k = rawdata.find('>', i + 1) |
| 188 | if k < 0: |
| 189 | k = rawdata.find('<', i + 1) |
| 190 | if k < 0: |
no test coverage detected