The attribute list is a transient interface to the underlying dictionaries. Mutations here will change the underlying element's dictionary. Ordering is imposed artificially and does not reflect the order of attributes as found in an input document.
| 481 | |
| 482 | |
| 483 | class NamedNodeMap(object): |
| 484 | """The attribute list is a transient interface to the underlying |
| 485 | dictionaries. Mutations here will change the underlying element's |
| 486 | dictionary. |
| 487 | |
| 488 | Ordering is imposed artificially and does not reflect the order of |
| 489 | attributes as found in an input document. |
| 490 | """ |
| 491 | |
| 492 | __slots__ = ('_attrs', '_attrsNS', '_ownerElement') |
| 493 | |
| 494 | def __init__(self, attrs, attrsNS, ownerElement): |
| 495 | self._attrs = attrs |
| 496 | self._attrsNS = attrsNS |
| 497 | self._ownerElement = ownerElement |
| 498 | |
| 499 | def _get_length(self): |
| 500 | return len(self._attrs) |
| 501 | |
| 502 | def item(self, index): |
| 503 | try: |
| 504 | return self[list(self._attrs.keys())[index]] |
| 505 | except IndexError: |
| 506 | return None |
| 507 | |
| 508 | def items(self): |
| 509 | L = [] |
| 510 | for node in self._attrs.values(): |
| 511 | L.append((node.nodeName, node.value)) |
| 512 | return L |
| 513 | |
| 514 | def itemsNS(self): |
| 515 | L = [] |
| 516 | for node in self._attrs.values(): |
| 517 | L.append(((node.namespaceURI, node.localName), node.value)) |
| 518 | return L |
| 519 | |
| 520 | def __contains__(self, key): |
| 521 | if isinstance(key, str): |
| 522 | return key in self._attrs |
| 523 | else: |
| 524 | return key in self._attrsNS |
| 525 | |
| 526 | def keys(self): |
| 527 | return self._attrs.keys() |
| 528 | |
| 529 | def keysNS(self): |
| 530 | return self._attrsNS.keys() |
| 531 | |
| 532 | def values(self): |
| 533 | return self._attrs.values() |
| 534 | |
| 535 | def get(self, name, value=None): |
| 536 | return self._attrs.get(name, value) |
| 537 | |
| 538 | __len__ = _get_length |
| 539 | |
| 540 | def _cmp(self, other): |
no outgoing calls
no test coverage detected
searching dependent graphs…