insert value before nodes
(self, value)
| 1294 | return self |
| 1295 | |
| 1296 | def before(self, value): |
| 1297 | """insert value before nodes |
| 1298 | """ |
| 1299 | root, root_text = self._get_root(value) |
| 1300 | for i, tag in enumerate(self): |
| 1301 | previous = tag.getprevious() |
| 1302 | if previous is not None: |
| 1303 | if not previous.tail: |
| 1304 | previous.tail = '' |
| 1305 | previous.tail += root_text |
| 1306 | else: |
| 1307 | parent = tag.getparent() |
| 1308 | if not parent.text: |
| 1309 | parent.text = '' |
| 1310 | parent.text += root_text |
| 1311 | if i > 0: |
| 1312 | root = deepcopy(list(root)) |
| 1313 | parent = tag.getparent() |
| 1314 | index = parent.index(tag) |
| 1315 | parent[index:index] = root |
| 1316 | root = parent[index:len(root)] |
| 1317 | return self |
| 1318 | |
| 1319 | @with_camel_case_alias |
| 1320 | def insert_before(self, value): |
no test coverage detected