| 1604 | self._decls[key] = decl |
| 1605 | |
| 1606 | def _extend(self, decls): |
| 1607 | decls = iter(decls) |
| 1608 | # Check only the first item. |
| 1609 | for decl in decls: |
| 1610 | if isinstance(decl, Declaration): |
| 1611 | self._add_decl(decl) |
| 1612 | # Add the rest without checking. |
| 1613 | for decl in decls: |
| 1614 | self._add_decl(decl) |
| 1615 | elif isinstance(decl, HighlevelParsedItem): |
| 1616 | raise NotImplementedError(decl) |
| 1617 | else: |
| 1618 | try: |
| 1619 | key, decl = decl |
| 1620 | except ValueError: |
| 1621 | raise NotImplementedError(decl) |
| 1622 | if not isinstance(decl, Declaration): |
| 1623 | raise NotImplementedError(decl) |
| 1624 | self._add_decl(decl, key) |
| 1625 | # Add the rest without checking. |
| 1626 | for key, decl in decls: |
| 1627 | self._add_decl(decl, key) |
| 1628 | # The iterator will be exhausted at this point. |