python-docx-oss 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docx/__init__.py +1 -1
- docx/oxml/xmlchemy.py +22 -1
- {python_docx_oss-0.3.0.dist-info → python_docx_oss-0.3.1.dist-info}/METADATA +1 -1
- {python_docx_oss-0.3.0.dist-info → python_docx_oss-0.3.1.dist-info}/RECORD +7 -7
- {python_docx_oss-0.3.0.dist-info → python_docx_oss-0.3.1.dist-info}/WHEEL +0 -0
- {python_docx_oss-0.3.0.dist-info → python_docx_oss-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {python_docx_oss-0.3.0.dist-info → python_docx_oss-0.3.1.dist-info}/top_level.txt +0 -0
docx/__init__.py
CHANGED
docx/oxml/xmlchemy.py
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
7
|
import re
|
|
8
|
-
from typing import TYPE_CHECKING, Any, Callable, Sequence, Type, TypeVar
|
|
8
|
+
from typing import TYPE_CHECKING, Any, Callable, Iterator, Sequence, Type, TypeVar
|
|
9
9
|
|
|
10
10
|
from lxml import etree
|
|
11
11
|
from lxml.etree import ElementBase, _Element # pyright: ignore[reportPrivateUsage]
|
|
@@ -653,6 +653,11 @@ class ZeroOrOneChoice(_BaseChildElement):
|
|
|
653
653
|
return "_remove_%s" % self._prop_name
|
|
654
654
|
|
|
655
655
|
|
|
656
|
+
# -- raw lxml text/tail accessors, used to bypass `.text` property overrides --
|
|
657
|
+
_raw_text = _Element.text.__get__
|
|
658
|
+
_raw_tail = _Element.tail.__get__
|
|
659
|
+
|
|
660
|
+
|
|
656
661
|
# -- lxml typing isn't quite right here, just ignore this error on _Element --
|
|
657
662
|
class BaseOxmlElement(etree.ElementBase, metaclass=MetaOxmlElement):
|
|
658
663
|
"""Effective base class for all custom element classes.
|
|
@@ -683,6 +688,22 @@ class BaseOxmlElement(etree.ElementBase, metaclass=MetaOxmlElement):
|
|
|
683
688
|
self.append(elm)
|
|
684
689
|
return elm
|
|
685
690
|
|
|
691
|
+
def itertext(self, tag: Any | None = None, *tags: Any, with_tail: bool = True) -> Iterator[str]:
|
|
692
|
+
"""Iterate over text content of this element and its descendants.
|
|
693
|
+
|
|
694
|
+
Bypasses the overridden `.text` properties on custom oxml element classes (such as
|
|
695
|
+
`CT_P`, `CT_R`, `CT_Hyperlink`), which would otherwise duplicate text, so standard
|
|
696
|
+
lxml `itertext()` semantics are preserved.
|
|
697
|
+
"""
|
|
698
|
+
for node in self.iter(tag, *tags):
|
|
699
|
+
text = _raw_text(node)
|
|
700
|
+
if text:
|
|
701
|
+
yield text
|
|
702
|
+
if with_tail and node is not self:
|
|
703
|
+
tail = _raw_tail(node)
|
|
704
|
+
if tail:
|
|
705
|
+
yield tail
|
|
706
|
+
|
|
686
707
|
def remove_all(self, *tagnames: str) -> None:
|
|
687
708
|
"""Remove child elements with tagname (e.g. "a:p") in `tagnames`."""
|
|
688
709
|
for tagname in tagnames:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
docx/__init__.py,sha256=
|
|
1
|
+
docx/__init__.py,sha256=AL2CZNiK_a766gdK59Vvj4oV-6swa9kKNaap3FfZKco,2102
|
|
2
2
|
docx/api.py,sha256=jIojXW4IRDEXQqaqvmOZbzBvNeyRXv9ntHByxd-Kb0M,1518
|
|
3
3
|
docx/blkcntnr.py,sha256=_xe7Uz3RBCz4TPKXpIzRxtGg-1YPb3gAG9YvsSUyoLU,3525
|
|
4
4
|
docx/comments.py,sha256=MmaP7U9mZOUFsRhaZNIbXatqOOA8-pOC6UlqWAuTHsc,6385
|
|
@@ -70,7 +70,7 @@ docx/oxml/shared.py,sha256=iAqDOcy-DnOm5GGsSZXLSemNejSqCjlzhB86lPEtDYM,1857
|
|
|
70
70
|
docx/oxml/simpletypes.py,sha256=2pD4vgEZThJpCB4M-L8hP7uTIXglndlZRdNruvDZwm0,13019
|
|
71
71
|
docx/oxml/styles.py,sha256=1U24kcC9hhzMPzNcg19RVCUJl1_qWauXCJIHG_Kp0Io,10643
|
|
72
72
|
docx/oxml/table.py,sha256=qS46a_Ts3KzNygUNeUxaTIVNDJZbbWNJqMseo3ZVaRA,33610
|
|
73
|
-
docx/oxml/xmlchemy.py,sha256=
|
|
73
|
+
docx/oxml/xmlchemy.py,sha256=5cahsGwUamMOWLo2CzdVZb6mrlFWgZbDGpxXef4NZ4g,27042
|
|
74
74
|
docx/oxml/dml/CT_ExtensionList.py,sha256=drQvDl9Zo10H1JMtHdI8AUxlX0U0NFPKwIyHAlUhDTk,1216
|
|
75
75
|
docx/oxml/text/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
76
76
|
docx/oxml/text/font.py,sha256=s5MJwoei24s1xdhtsI1P02wqI6mLpvkLTCXr73EWNWI,11900
|
|
@@ -128,8 +128,8 @@ docx/text/paragraph.py,sha256=N3F62_JRQZYaumuoaJXKCDnRSw2DIiOwzyMPV2Jd7GI,6828
|
|
|
128
128
|
docx/text/parfmt.py,sha256=70M75HFo7ydpqmIdZjkV711muyrsBGdr4WZscF3YVJY,10339
|
|
129
129
|
docx/text/run.py,sha256=tsW8dXOE4VnqEM7cJz_uU2Vq3qgdnrMGzyDq9x5jvE4,10800
|
|
130
130
|
docx/text/tabstops.py,sha256=bJN98GWW22f4Sqg0dQbyUcnuOn65fHsNZuCGswI03_c,3896
|
|
131
|
-
python_docx_oss-0.3.
|
|
132
|
-
python_docx_oss-0.3.
|
|
133
|
-
python_docx_oss-0.3.
|
|
134
|
-
python_docx_oss-0.3.
|
|
135
|
-
python_docx_oss-0.3.
|
|
131
|
+
python_docx_oss-0.3.1.dist-info/licenses/LICENSE,sha256=lf2yZv-riPwFeah3IMDeG0zqI6fXcV9T9YOToeG54NM,1164
|
|
132
|
+
python_docx_oss-0.3.1.dist-info/METADATA,sha256=dSJ6OR23JAVG4Y1y-ABz0aWEhB2zuIZG-YpWzhuNoK8,7900
|
|
133
|
+
python_docx_oss-0.3.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
134
|
+
python_docx_oss-0.3.1.dist-info/top_level.txt,sha256=zkbrD3gmyqHpD_XhHe7lCbr2M5vT229nJ4UFqF5VjIs,5
|
|
135
|
+
python_docx_oss-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|