diff options
author | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
---|---|---|
committer | S. Solomon Darnell | 2025-03-28 21:52:21 -0500 |
commit | 4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch) | |
tree | ee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/docx/__init__.py | |
parent | cc961e04ba734dd72309fb548a2f97d67d578813 (diff) | |
download | gn-ai-master.tar.gz |
Diffstat (limited to '.venv/lib/python3.12/site-packages/docx/__init__.py')
-rw-r--r-- | .venv/lib/python3.12/site-packages/docx/__init__.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/docx/__init__.py b/.venv/lib/python3.12/site-packages/docx/__init__.py new file mode 100644 index 00000000..20522102 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/docx/__init__.py @@ -0,0 +1,62 @@ +"""Initialize `docx` package. + +Export the `Document` constructor function and establish the mapping of part-type to +the part-classe that implements that type. +""" + +from __future__ import annotations + +from typing import TYPE_CHECKING, Type + +from docx.api import Document + +if TYPE_CHECKING: + from docx.opc.part import Part + +__version__ = "1.1.2" + + +__all__ = ["Document"] + + +# -- register custom Part classes with opc package reader -- + +from docx.opc.constants import CONTENT_TYPE as CT +from docx.opc.constants import RELATIONSHIP_TYPE as RT +from docx.opc.part import PartFactory +from docx.opc.parts.coreprops import CorePropertiesPart +from docx.parts.document import DocumentPart +from docx.parts.hdrftr import FooterPart, HeaderPart +from docx.parts.image import ImagePart +from docx.parts.numbering import NumberingPart +from docx.parts.settings import SettingsPart +from docx.parts.styles import StylesPart + + +def part_class_selector(content_type: str, reltype: str) -> Type[Part] | None: + if reltype == RT.IMAGE: + return ImagePart + return None + + +PartFactory.part_class_selector = part_class_selector +PartFactory.part_type_for[CT.OPC_CORE_PROPERTIES] = CorePropertiesPart +PartFactory.part_type_for[CT.WML_DOCUMENT_MAIN] = DocumentPart +PartFactory.part_type_for[CT.WML_FOOTER] = FooterPart +PartFactory.part_type_for[CT.WML_HEADER] = HeaderPart +PartFactory.part_type_for[CT.WML_NUMBERING] = NumberingPart +PartFactory.part_type_for[CT.WML_SETTINGS] = SettingsPart +PartFactory.part_type_for[CT.WML_STYLES] = StylesPart + +del ( + CT, + CorePropertiesPart, + DocumentPart, + FooterPart, + HeaderPart, + NumberingPart, + PartFactory, + SettingsPart, + StylesPart, + part_class_selector, +) |