about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/docx/parts/styles.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/docx/parts/styles.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/docx/parts/styles.py')
-rw-r--r--.venv/lib/python3.12/site-packages/docx/parts/styles.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/docx/parts/styles.py b/.venv/lib/python3.12/site-packages/docx/parts/styles.py
new file mode 100644
index 00000000..dffa762e
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/docx/parts/styles.py
@@ -0,0 +1,44 @@
+"""Provides StylesPart and related objects."""
+
+from __future__ import annotations
+
+import os
+from typing import TYPE_CHECKING
+
+from docx.opc.constants import CONTENT_TYPE as CT
+from docx.opc.packuri import PackURI
+from docx.opc.part import XmlPart
+from docx.oxml.parser import parse_xml
+from docx.styles.styles import Styles
+
+if TYPE_CHECKING:
+    from docx.opc.package import OpcPackage
+
+
+class StylesPart(XmlPart):
+    """Proxy for the styles.xml part containing style definitions for a document or
+    glossary."""
+
+    @classmethod
+    def default(cls, package: OpcPackage) -> StylesPart:
+        """Return a newly created styles part, containing a default set of elements."""
+        partname = PackURI("/word/styles.xml")
+        content_type = CT.WML_STYLES
+        element = parse_xml(cls._default_styles_xml())
+        return cls(partname, content_type, element, package)
+
+    @property
+    def styles(self):
+        """The |_Styles| instance containing the styles (<w:style> element proxies) for
+        this styles part."""
+        return Styles(self.element)
+
+    @classmethod
+    def _default_styles_xml(cls):
+        """Return a bytestream containing XML for a default styles part."""
+        path = os.path.join(
+            os.path.split(__file__)[0], "..", "templates", "default-styles.xml"
+        )
+        with open(path, "rb") as f:
+            xml_bytes = f.read()
+        return xml_bytes