| 1154 | |
| 1155 | |
| 1156 | class Label: |
| 1157 | def __init__(self, attrs): |
| 1158 | self.id = attrs.get("for") |
| 1159 | self._text = attrs.get("__text").strip() |
| 1160 | self._ctext = compress_text(self._text) |
| 1161 | self.attrs = attrs |
| 1162 | self._backwards_compat = False # maintained by HTMLForm |
| 1163 | |
| 1164 | def __getattr__(self, name): |
| 1165 | if name == "text": |
| 1166 | if self._backwards_compat: |
| 1167 | return self._text |
| 1168 | else: |
| 1169 | return self._ctext |
| 1170 | return getattr(Label, name) |
| 1171 | |
| 1172 | def __setattr__(self, name, value): |
| 1173 | if name == "text": |
| 1174 | # don't see any need for this, so make it read-only |
| 1175 | raise AttributeError("text attribute is read-only") |
| 1176 | self.__dict__[name] = value |
| 1177 | |
| 1178 | def __str__(self): |
| 1179 | return "<Label(id=%r, text=%r)>" % (self.id, self.text) |
| 1180 | |
| 1181 | |
| 1182 | def _get_label(attrs): |
no outgoing calls
no test coverage detected
searching dependent graphs…