From 4a52a71956a8d46fcb7294ac71734504bb09bcc2 Mon Sep 17 00:00:00 2001 From: S. Solomon Darnell Date: Fri, 28 Mar 2025 21:52:21 -0500 Subject: two version of R2R are here --- .../python3.12/site-packages/docx/oxml/shared.py | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .venv/lib/python3.12/site-packages/docx/oxml/shared.py (limited to '.venv/lib/python3.12/site-packages/docx/oxml/shared.py') diff --git a/.venv/lib/python3.12/site-packages/docx/oxml/shared.py b/.venv/lib/python3.12/site-packages/docx/oxml/shared.py new file mode 100644 index 00000000..8c2ebc9a --- /dev/null +++ b/.venv/lib/python3.12/site-packages/docx/oxml/shared.py @@ -0,0 +1,53 @@ +"""Objects shared by modules in the docx.oxml subpackage.""" + +from __future__ import annotations + +from typing import cast + +from docx.oxml.ns import qn +from docx.oxml.parser import OxmlElement +from docx.oxml.simpletypes import ST_DecimalNumber, ST_OnOff, ST_String +from docx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute, RequiredAttribute + + +class CT_DecimalNumber(BaseOxmlElement): + """Used for ````, ````, ```` and several others, + containing a text representation of a decimal number (e.g. 42) in its ``val`` + attribute.""" + + val: int = RequiredAttribute("w:val", ST_DecimalNumber) # pyright: ignore[reportAssignmentType] + + @classmethod + def new(cls, nsptagname: str, val: int): + """Return a new ``CT_DecimalNumber`` element having tagname `nsptagname` and + ``val`` attribute set to `val`.""" + return OxmlElement(nsptagname, attrs={qn("w:val"): str(val)}) + + +class CT_OnOff(BaseOxmlElement): + """Used for `w:b`, `w:i` elements and others. + + Contains a bool-ish string in its `val` attribute, xsd:boolean plus "on" and + "off". Defaults to `True`, so `` for example means "bold is turned on". + """ + + val: bool = OptionalAttribute( # pyright: ignore[reportAssignmentType] + "w:val", ST_OnOff, default=True + ) + + +class CT_String(BaseOxmlElement): + """Used for `w:pStyle` and `w:tblStyle` elements and others. + + In those cases, it containing a style name in its `val` attribute. + """ + + val: str = RequiredAttribute("w:val", ST_String) # pyright: ignore[reportAssignmentType] + + @classmethod + def new(cls, nsptagname: str, val: str): + """Return a new ``CT_String`` element with tagname `nsptagname` and ``val`` + attribute set to `val`.""" + elm = cast(CT_String, OxmlElement(nsptagname)) + elm.val = val + return elm -- cgit v1.2.3