Adds a child to the Tag To retrieve the child call get_child or access to the Tag.children[key] dictionary. Args: key (str): Unique child's identifier, or iterable of keys value (Tag, str): can be a Tag, an iterable of Tag or a str. In case of iterable
(self, key, value)
| 442 | self.attributes['class'] = '' |
| 443 | |
| 444 | def add_child(self, key, value): |
| 445 | """Adds a child to the Tag |
| 446 | |
| 447 | To retrieve the child call get_child or access to the Tag.children[key] dictionary. |
| 448 | |
| 449 | Args: |
| 450 | key (str): Unique child's identifier, or iterable of keys |
| 451 | value (Tag, str): can be a Tag, an iterable of Tag or a str. In case of iterable |
| 452 | of Tag is a dict, each item's key is set as 'key' param |
| 453 | """ |
| 454 | if type(value) in (list, tuple, dict): |
| 455 | if type(value) == dict: |
| 456 | for k in value.keys(): |
| 457 | self.add_child(k, value[k]) |
| 458 | return |
| 459 | i = 0 |
| 460 | for child in value: |
| 461 | self.add_child(key[i], child) |
| 462 | i = i + 1 |
| 463 | return |
| 464 | |
| 465 | if hasattr(value, 'attributes'): |
| 466 | value.attributes['data-parent-widget'] = self.identifier |
| 467 | value._parent = self |
| 468 | |
| 469 | if key in self.children: |
| 470 | self._render_children_list.remove(key) |
| 471 | self._render_children_list.append(key) |
| 472 | |
| 473 | self.children[key] = value |
| 474 | |
| 475 | def get_child(self, key): |
| 476 | """Returns the child identified by 'key' |
no test coverage detected