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

Method iter_parts

src/docx/opc/package.py:69–87  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

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
71 performing a depth-first traversal of the rels graph."""
72
73 def walk_parts(source, visited=[]):
74 for rel in source.rels.values():
75 if rel.is_external:
76 continue
77 part = rel.target_part
78 if part in visited:
79 continue
80 visited.append(part)
81 yield part
82 new_source = part
83 for part in walk_parts(new_source, visited):
84 yield part
85
86 for part in walk_parts(self):
87 yield part
88
89 def load_rel(self, reltype: str, target: Part | str, rId: str, is_external: bool = False):
90 """Return newly added |_Relationship| instance of `reltype` between this part

Callers 3

next_partnameMethod · 0.95
partsMethod · 0.95

Calls

no outgoing calls