MCPcopy Create free account
hub / github.com/scanny/python-pptx / iter_valid_rels

Method iter_valid_rels

src/pptx/opc/package.py:555–566  ·  view source on GitHub ↗

Filter out broken relationships such as those pointing to NULL.

()

Source from the content-addressed store, hash-verified

553 """Replace any relationships in this collection with those from `xml_rels`."""
554
555 def iter_valid_rels():
556 """Filter out broken relationships such as those pointing to NULL."""
557 for rel_elm in xml_rels.relationship_lst:
558 # --- Occasionally a PowerPoint plugin or other client will "remove"
559 # --- a relationship simply by "voiding" its Target value, like making
560 # --- it "/ppt/slides/NULL". Skip any relationships linking to a
561 # --- partname that is not present in the package.
562 if rel_elm.targetMode == RTM.INTERNAL:
563 partname = PackURI.from_rel_ref(base_uri, rel_elm.target_ref)
564 if partname not in parts:
565 continue
566 yield _Relationship.from_xml(base_uri, rel_elm, parts)
567
568 self._rels.clear()
569 self._rels.update((rel.rId, rel) for rel in iter_valid_rels())

Callers

nothing calls this directly

Calls 2

from_rel_refMethod · 0.80
from_xmlMethod · 0.45

Tested by

no test coverage detected