(self, data)
| 677 | d["__label"] = self._current_label |
| 678 | |
| 679 | def handle_data(self, data): |
| 680 | debug("%s", data) |
| 681 | |
| 682 | if self._option is not None: |
| 683 | # self._option is a dictionary of the OPTION element's HTML |
| 684 | # attributes, but it has two special keys, one of which is the |
| 685 | # special "contents" key contains text between OPTION tags (the |
| 686 | # other is the "__select" key: see the end_option method) |
| 687 | map = self._option |
| 688 | key = "contents" |
| 689 | elif self._textarea is not None: |
| 690 | map = self._textarea |
| 691 | key = "value" |
| 692 | data = normalize_line_endings(data) |
| 693 | # not if within option or textarea |
| 694 | elif self._current_label is not None: |
| 695 | map = self._current_label |
| 696 | key = "__text" |
| 697 | else: |
| 698 | return |
| 699 | |
| 700 | if data and key not in map: |
| 701 | # according to |
| 702 | # http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1 line break |
| 703 | # immediately after start tags or immediately before end tags must |
| 704 | # be ignored, but real browsers only ignore a line break after a |
| 705 | # start tag, so we'll do that. |
| 706 | if data[0:2] == "\r\n": |
| 707 | data = data[2:] |
| 708 | elif data[0:1] in ["\n", "\r"]: |
| 709 | data = data[1:] |
| 710 | map[key] = data |
| 711 | else: |
| 712 | map[key] = (map[key].decode("utf8", "replace") if isinstance(map[key], six.binary_type) else map[key]) + data |
| 713 | |
| 714 | def do_button(self, attrs): |
| 715 | debug("%s", attrs) |
no test coverage detected