python-docx-oss 0.4.0__py3-none-any.whl → 0.5.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 CHANGED
@@ -9,16 +9,25 @@ from __future__ import annotations
9
9
  from typing import TYPE_CHECKING, Type
10
10
 
11
11
  from docx.api import Document
12
- from docx.inspection import FingerprintPolicy, fingerprint, inspect
12
+ from docx.inspection import FingerprintItem, FingerprintPolicy, fingerprint, inspect, serialize_xml
13
13
  from docx.transforms import normalize, repair
14
14
 
15
15
  if TYPE_CHECKING:
16
16
  from docx.opc.part import Part
17
17
 
18
- __version__ = "0.4.0"
18
+ __version__ = "0.5.1"
19
19
 
20
20
 
21
- __all__ = ["Document", "FingerprintPolicy", "fingerprint", "inspect", "normalize", "repair"]
21
+ __all__ = [
22
+ "Document",
23
+ "FingerprintItem",
24
+ "FingerprintPolicy",
25
+ "fingerprint",
26
+ "inspect",
27
+ "normalize",
28
+ "repair",
29
+ "serialize_xml",
30
+ ]
22
31
 
23
32
 
24
33
  # -- register custom Part classes with opc package reader --
docx/enum/table.py CHANGED
@@ -1,5 +1,7 @@
1
1
  """Enumerations related to tables in WordprocessingML files."""
2
2
 
3
+ from __future__ import annotations
4
+
3
5
  from docx.enum.base import BaseEnum, BaseXmlEnum
4
6
 
5
7
 
@@ -106,6 +108,14 @@ class WD_TABLE_ALIGNMENT(BaseXmlEnum):
106
108
  RIGHT = (2, "right", "Right-aligned.")
107
109
  """Right-aligned."""
108
110
 
111
+ @classmethod
112
+ def from_xml(cls, xml_value: str | None) -> WD_TABLE_ALIGNMENT:
113
+ if xml_value == "start":
114
+ return cls.LEFT
115
+ if xml_value == "end":
116
+ return cls.RIGHT
117
+ return super().from_xml(xml_value)
118
+
109
119
 
110
120
  class WD_TABLE_DIRECTION(BaseEnum):
111
121
  """Specifies the direction in which an application orders cells in the specified
docx/enum/text.py CHANGED
@@ -63,6 +63,14 @@ class WD_PARAGRAPH_ALIGNMENT(BaseXmlEnum):
63
63
  )
64
64
  """Justified according to Thai formatting layout."""
65
65
 
66
+ @classmethod
67
+ def from_xml(cls, xml_value: str | None) -> WD_PARAGRAPH_ALIGNMENT:
68
+ if xml_value == "start":
69
+ return cls.LEFT
70
+ if xml_value == "end":
71
+ return cls.RIGHT
72
+ return super().from_xml(xml_value)
73
+
66
74
 
67
75
  WD_ALIGN_PARAGRAPH = WD_PARAGRAPH_ALIGNMENT
68
76
 
@@ -1,9 +1,14 @@
1
1
  """Read-only package inspection and configurable content fingerprints."""
2
2
 
3
- from docx.inspection.fingerprint import FingerprintPolicy, fingerprint
3
+ from docx.inspection.features import ScanEvent
4
+ from docx.inspection.fingerprint import (
5
+ FingerprintItem,
6
+ FingerprintPolicy,
7
+ fingerprint,
8
+ serialize_xml,
9
+ )
4
10
  from docx.inspection.reader import inspect
5
11
  from docx.inspection.result import (
6
- Features,
7
12
  Finding,
8
13
  PackageInspection,
9
14
  PackageInventory,
@@ -12,13 +17,15 @@ from docx.inspection.result import (
12
17
  )
13
18
 
14
19
  __all__ = [
15
- "Features",
20
+ "ScanEvent",
16
21
  "Finding",
22
+ "FingerprintItem",
17
23
  "FingerprintPolicy",
18
24
  "PackageInspection",
19
25
  "PackageInventory",
20
26
  "PartInventory",
21
27
  "RelationshipInventory",
22
28
  "fingerprint",
29
+ "serialize_xml",
23
30
  "inspect",
24
31
  ]