MCPcopy Index your code
hub / github.com/python-openxml/python-docx / iter_rels

Method iter_rels

src/docx/opc/package.py:46–67  ·  view source on GitHub ↗

Generate exactly one reference to each relationship in the package by performing a depth-first traversal of the rels graph.

(self)

Source from the content-addressed store, hash-verified

44 return self._core_properties_part.core_properties
45
46 def iter_rels(self) -> Iterator[_Relationship]:
47 """Generate exactly one reference to each relationship in the package by
48 performing a depth-first traversal of the rels graph."""
49
50 def walk_rels(
51 source: OpcPackage | Part, visited: list[Part] | None = None
52 ) -> Iterator[_Relationship]:
53 visited = [] if visited is None else visited
54 for rel in source.rels.values():
55 yield rel
56 if rel.is_external:
57 continue
58 part = rel.target_part
59 if part in visited:
60 continue
61 visited.append(part)
62 new_source = part
63 for rel in walk_rels(new_source, visited):
64 yield rel
65
66 for rel in walk_rels(self):
67 yield rel
68
69 def iter_parts(self) -> Iterator[Part]:
70 """Generate exactly one reference to each of the parts in the package by

Callers 1

_gather_image_partsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected