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

Method open

src/docx/opc/package.py:124–129  ·  view source on GitHub ↗

Return an |OpcPackage| instance loaded with the contents of `pkg_file`.

(cls, pkg_file: str | IO[bytes])

Source from the content-addressed store, hash-verified

122
123 @classmethod
124 def open(cls, pkg_file: str | IO[bytes]) -> Self:
125 """Return an |OpcPackage| instance loaded with the contents of `pkg_file`."""
126 pkg_reader = PackageReader.from_file(pkg_file)
127 package = cls()
128 Unmarshaller.unmarshal(pkg_reader, package, PartFactory)
129 return package
130
131 def part_related_by(self, reltype: str) -> Part:
132 """Return part to which this package has a relationship of `reltype`.

Calls 2

unmarshalMethod · 0.80
from_fileMethod · 0.45