Return a |PackURI| instance representing partname matching `template`. The returned part-name has the next available numeric suffix to distinguish it from other parts of its type. `template` is a printf (%)-style template string containing a single replacement item, a '%d' t
(self, template: str)
| 107 | return self.part_related_by(RT.OFFICE_DOCUMENT) |
| 108 | |
| 109 | def next_partname(self, template: str) -> PackURI: |
| 110 | """Return a |PackURI| instance representing partname matching `template`. |
| 111 | |
| 112 | The returned part-name has the next available numeric suffix to distinguish it |
| 113 | from other parts of its type. `template` is a printf (%)-style template string |
| 114 | containing a single replacement item, a '%d' to be used to insert the integer |
| 115 | portion of the partname. Example: "/word/header%d.xml" |
| 116 | """ |
| 117 | partnames = {part.partname for part in self.iter_parts()} |
| 118 | for n in range(1, len(partnames) + 2): |
| 119 | candidate_partname = template % n |
| 120 | if candidate_partname not in partnames: |
| 121 | return PackURI(candidate_partname) |
| 122 | |
| 123 | @classmethod |
| 124 | def open(cls, pkg_file: str | IO[bytes]) -> Self: |