ps-python-docx 1.3.0__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.
Files changed (126) hide show
  1. docx/__init__.py +68 -0
  2. docx/api.py +37 -0
  3. docx/blkcntnr.py +101 -0
  4. docx/comments.py +163 -0
  5. docx/dml/__init__.py +0 -0
  6. docx/dml/color.py +112 -0
  7. docx/document.py +275 -0
  8. docx/drawing/__init__.py +59 -0
  9. docx/enum/__init__.py +0 -0
  10. docx/enum/base.py +150 -0
  11. docx/enum/dml.py +103 -0
  12. docx/enum/section.py +86 -0
  13. docx/enum/shape.py +19 -0
  14. docx/enum/style.py +452 -0
  15. docx/enum/table.py +136 -0
  16. docx/enum/text.py +367 -0
  17. docx/exceptions.py +18 -0
  18. docx/image/__init__.py +23 -0
  19. docx/image/bmp.py +43 -0
  20. docx/image/constants.py +172 -0
  21. docx/image/exceptions.py +13 -0
  22. docx/image/gif.py +38 -0
  23. docx/image/helpers.py +86 -0
  24. docx/image/image.py +234 -0
  25. docx/image/jpeg.py +425 -0
  26. docx/image/png.py +253 -0
  27. docx/image/tiff.py +289 -0
  28. docx/opc/__init__.py +0 -0
  29. docx/opc/constants.py +306 -0
  30. docx/opc/coreprops.py +142 -0
  31. docx/opc/exceptions.py +12 -0
  32. docx/opc/oxml.py +247 -0
  33. docx/opc/package.py +219 -0
  34. docx/opc/packuri.py +109 -0
  35. docx/opc/part.py +247 -0
  36. docx/opc/parts/__init__.py +0 -0
  37. docx/opc/parts/coreprops.py +48 -0
  38. docx/opc/phys_pkg.py +119 -0
  39. docx/opc/pkgreader.py +254 -0
  40. docx/opc/pkgwriter.py +115 -0
  41. docx/opc/rel.py +153 -0
  42. docx/opc/shared.py +31 -0
  43. docx/opc/spec.py +24 -0
  44. docx/oxml/__init__.py +261 -0
  45. docx/oxml/comments.py +124 -0
  46. docx/oxml/coreprops.py +298 -0
  47. docx/oxml/document.py +88 -0
  48. docx/oxml/drawing.py +11 -0
  49. docx/oxml/exceptions.py +10 -0
  50. docx/oxml/ns.py +109 -0
  51. docx/oxml/numbering.py +109 -0
  52. docx/oxml/parser.py +62 -0
  53. docx/oxml/section.py +537 -0
  54. docx/oxml/settings.py +138 -0
  55. docx/oxml/shape.py +299 -0
  56. docx/oxml/shared.py +52 -0
  57. docx/oxml/simpletypes.py +434 -0
  58. docx/oxml/styles.py +341 -0
  59. docx/oxml/table.py +977 -0
  60. docx/oxml/text/__init__.py +0 -0
  61. docx/oxml/text/font.py +333 -0
  62. docx/oxml/text/hyperlink.py +45 -0
  63. docx/oxml/text/pagebreak.py +278 -0
  64. docx/oxml/text/paragraph.py +106 -0
  65. docx/oxml/text/parfmt.py +392 -0
  66. docx/oxml/text/run.py +307 -0
  67. docx/oxml/xmlchemy.py +696 -0
  68. docx/package.py +110 -0
  69. docx/parts/__init__.py +0 -0
  70. docx/parts/comments.py +51 -0
  71. docx/parts/document.py +182 -0
  72. docx/parts/hdrftr.py +53 -0
  73. docx/parts/image.py +80 -0
  74. docx/parts/numbering.py +32 -0
  75. docx/parts/settings.py +50 -0
  76. docx/parts/story.py +95 -0
  77. docx/parts/styles.py +42 -0
  78. docx/parts/theme.py +53 -0
  79. docx/py.typed +0 -0
  80. docx/section.py +479 -0
  81. docx/settings.py +35 -0
  82. docx/shape.py +103 -0
  83. docx/shared.py +382 -0
  84. docx/styles/__init__.py +40 -0
  85. docx/styles/latent.py +198 -0
  86. docx/styles/style.py +264 -0
  87. docx/styles/styles.py +147 -0
  88. docx/table.py +537 -0
  89. docx/templates/default-comments.xml +12 -0
  90. docx/templates/default-docx-template/[Content_Types].xml +17 -0
  91. docx/templates/default-docx-template/_rels/.rels +7 -0
  92. docx/templates/default-docx-template/customXml/_rels/item1.xml.rels +4 -0
  93. docx/templates/default-docx-template/customXml/item1.xml +2 -0
  94. docx/templates/default-docx-template/customXml/itemProps1.xml +6 -0
  95. docx/templates/default-docx-template/docProps/app.xml +36 -0
  96. docx/templates/default-docx-template/docProps/core.xml +13 -0
  97. docx/templates/default-docx-template/docProps/thumbnail.jpeg +0 -0
  98. docx/templates/default-docx-template/word/_rels/document.xml.rels +11 -0
  99. docx/templates/default-docx-template/word/document.xml +11 -0
  100. docx/templates/default-docx-template/word/fontTable.xml +61 -0
  101. docx/templates/default-docx-template/word/numbering.xml +201 -0
  102. docx/templates/default-docx-template/word/settings.xml +53 -0
  103. docx/templates/default-docx-template/word/styles.xml +11844 -0
  104. docx/templates/default-docx-template/word/stylesWithEffects.xml +11800 -0
  105. docx/templates/default-docx-template/word/theme/theme1.xml +318 -0
  106. docx/templates/default-docx-template/word/webSettings.xml +5 -0
  107. docx/templates/default-footer.xml +27 -0
  108. docx/templates/default-header.xml +27 -0
  109. docx/templates/default-settings.xml +26 -0
  110. docx/templates/default-styles.xml +190 -0
  111. docx/templates/default.docx +0 -0
  112. docx/text/__init__.py +0 -0
  113. docx/text/font.py +472 -0
  114. docx/text/hyperlink.py +121 -0
  115. docx/text/pagebreak.py +104 -0
  116. docx/text/paragraph.py +173 -0
  117. docx/text/parfmt.py +286 -0
  118. docx/text/run.py +257 -0
  119. docx/text/tabstops.py +123 -0
  120. docx/theme.py +67 -0
  121. docx/types.py +34 -0
  122. ps_python_docx-1.3.0.dist-info/METADATA +77 -0
  123. ps_python_docx-1.3.0.dist-info/RECORD +126 -0
  124. ps_python_docx-1.3.0.dist-info/WHEEL +5 -0
  125. ps_python_docx-1.3.0.dist-info/licenses/LICENSE +20 -0
  126. ps_python_docx-1.3.0.dist-info/top_level.txt +1 -0
docx/text/paragraph.py ADDED
@@ -0,0 +1,173 @@
1
+ """Paragraph-related proxy types."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Iterator, List, cast
6
+
7
+ from docx.enum.style import WD_STYLE_TYPE
8
+ from docx.oxml.text.run import CT_R
9
+ from docx.shared import StoryChild
10
+ from docx.styles.style import ParagraphStyle
11
+ from docx.text.hyperlink import Hyperlink
12
+ from docx.text.pagebreak import RenderedPageBreak
13
+ from docx.text.parfmt import ParagraphFormat
14
+ from docx.text.run import Run
15
+
16
+ if TYPE_CHECKING:
17
+ import docx.types as t
18
+ from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
19
+ from docx.oxml.text.paragraph import CT_P
20
+ from docx.styles.style import CharacterStyle
21
+
22
+
23
+ class Paragraph(StoryChild):
24
+ """Proxy object wrapping a `<w:p>` element."""
25
+
26
+ def __init__(self, p: CT_P, parent: t.ProvidesStoryPart):
27
+ super(Paragraph, self).__init__(parent)
28
+ self._p = self._element = p
29
+
30
+ def add_run(self, text: str | None = None, style: str | CharacterStyle | None = None) -> Run:
31
+ """Append run containing `text` and having character-style `style`.
32
+
33
+ `text` can contain tab (``\\t``) characters, which are converted to the
34
+ appropriate XML form for a tab. `text` can also include newline (``\\n``) or
35
+ carriage return (``\\r``) characters, each of which is converted to a line
36
+ break. When `text` is `None`, the new run is empty.
37
+ """
38
+ r = self._p.add_r()
39
+ run = Run(r, self)
40
+ if text:
41
+ run.text = text
42
+ if style:
43
+ run.style = style
44
+ return run
45
+
46
+ @property
47
+ def alignment(self) -> WD_PARAGRAPH_ALIGNMENT | None:
48
+ """A member of the :ref:`WdParagraphAlignment` enumeration specifying the
49
+ justification setting for this paragraph.
50
+
51
+ A value of |None| indicates the paragraph has no directly-applied alignment
52
+ value and will inherit its alignment value from its style hierarchy. Assigning
53
+ |None| to this property removes any directly-applied alignment value.
54
+ """
55
+ return self._p.alignment
56
+
57
+ @alignment.setter
58
+ def alignment(self, value: WD_PARAGRAPH_ALIGNMENT):
59
+ self._p.alignment = value
60
+
61
+ def clear(self):
62
+ """Return this same paragraph after removing all its content.
63
+
64
+ Paragraph-level formatting, such as style, is preserved.
65
+ """
66
+ self._p.clear_content()
67
+ return self
68
+
69
+ @property
70
+ def contains_page_break(self) -> bool:
71
+ """`True` when one or more rendered page-breaks occur in this paragraph."""
72
+ return bool(self._p.lastRenderedPageBreaks)
73
+
74
+ @property
75
+ def hyperlinks(self) -> List[Hyperlink]:
76
+ """A |Hyperlink| instance for each hyperlink in this paragraph."""
77
+ return [Hyperlink(hyperlink, self) for hyperlink in self._p.hyperlink_lst]
78
+
79
+ def insert_paragraph_before(
80
+ self, text: str | None = None, style: str | ParagraphStyle | None = None
81
+ ) -> Paragraph:
82
+ """Return a newly created paragraph, inserted directly before this paragraph.
83
+
84
+ If `text` is supplied, the new paragraph contains that text in a single run. If
85
+ `style` is provided, that style is assigned to the new paragraph.
86
+ """
87
+ paragraph = self._insert_paragraph_before()
88
+ if text:
89
+ paragraph.add_run(text)
90
+ if style is not None:
91
+ paragraph.style = style
92
+ return paragraph
93
+
94
+ def iter_inner_content(self) -> Iterator[Run | Hyperlink]:
95
+ """Generate the runs and hyperlinks in this paragraph, in the order they appear.
96
+
97
+ The content in a paragraph consists of both runs and hyperlinks. This method
98
+ allows accessing each of those separately, in document order, for when the
99
+ precise position of the hyperlink within the paragraph text is important. Note
100
+ that a hyperlink itself contains runs.
101
+ """
102
+ for r_or_hlink in self._p.inner_content_elements:
103
+ yield (
104
+ Run(r_or_hlink, self)
105
+ if isinstance(r_or_hlink, CT_R)
106
+ else Hyperlink(r_or_hlink, self)
107
+ )
108
+
109
+ @property
110
+ def paragraph_format(self):
111
+ """The |ParagraphFormat| object providing access to the formatting properties
112
+ for this paragraph, such as line spacing and indentation."""
113
+ return ParagraphFormat(self._element)
114
+
115
+ @property
116
+ def rendered_page_breaks(self) -> List[RenderedPageBreak]:
117
+ """All rendered page-breaks in this paragraph.
118
+
119
+ Most often an empty list, sometimes contains one page-break, but can contain
120
+ more than one is rare or contrived cases.
121
+ """
122
+ return [RenderedPageBreak(lrpb, self) for lrpb in self._p.lastRenderedPageBreaks]
123
+
124
+ @property
125
+ def runs(self) -> List[Run]:
126
+ """Sequence of |Run| instances corresponding to the <w:r> elements in this
127
+ paragraph."""
128
+ return [Run(r, self) for r in self._p.r_lst]
129
+
130
+ @property
131
+ def style(self) -> ParagraphStyle | None:
132
+ """Read/Write.
133
+
134
+ |_ParagraphStyle| object representing the style assigned to this paragraph. If
135
+ no explicit style is assigned to this paragraph, its value is the default
136
+ paragraph style for the document. A paragraph style name can be assigned in lieu
137
+ of a paragraph style object. Assigning |None| removes any applied style, making
138
+ its effective value the default paragraph style for the document.
139
+ """
140
+ style_id = self._p.style
141
+ style = self.part.get_style(style_id, WD_STYLE_TYPE.PARAGRAPH)
142
+ return cast(ParagraphStyle, style)
143
+
144
+ @style.setter
145
+ def style(self, style_or_name: str | ParagraphStyle | None):
146
+ style_id = self.part.get_style_id(style_or_name, WD_STYLE_TYPE.PARAGRAPH)
147
+ self._p.style = style_id
148
+
149
+ @property
150
+ def text(self) -> str:
151
+ """The textual content of this paragraph.
152
+
153
+ The text includes the visible-text portion of any hyperlinks in the paragraph.
154
+ Tabs and line breaks in the XML are mapped to ``\\t`` and ``\\n`` characters
155
+ respectively.
156
+
157
+ Assigning text to this property causes all existing paragraph content to be
158
+ replaced with a single run containing the assigned text. A ``\\t`` character in
159
+ the text is mapped to a ``<w:tab/>`` element and each ``\\n`` or ``\\r``
160
+ character is mapped to a line break. Paragraph-level formatting, such as style,
161
+ is preserved. All run-level formatting, such as bold or italic, is removed.
162
+ """
163
+ return self._p.text
164
+
165
+ @text.setter
166
+ def text(self, text: str | None):
167
+ self.clear()
168
+ self.add_run(text)
169
+
170
+ def _insert_paragraph_before(self):
171
+ """Return a newly created paragraph, inserted directly before this paragraph."""
172
+ p = self._p.add_p_before()
173
+ return Paragraph(p, self._parent)
docx/text/parfmt.py ADDED
@@ -0,0 +1,286 @@
1
+ """Paragraph-related proxy types."""
2
+
3
+ from docx.enum.text import WD_LINE_SPACING
4
+ from docx.shared import ElementProxy, Emu, Length, Pt, Twips, lazyproperty
5
+ from docx.text.tabstops import TabStops
6
+
7
+
8
+ class ParagraphFormat(ElementProxy):
9
+ """Provides access to paragraph formatting such as justification, indentation, line
10
+ spacing, space before and after, and widow/orphan control."""
11
+
12
+ @property
13
+ def alignment(self):
14
+ """A member of the :ref:`WdParagraphAlignment` enumeration specifying the
15
+ justification setting for this paragraph.
16
+
17
+ A value of |None| indicates paragraph alignment is inherited from the style
18
+ hierarchy.
19
+ """
20
+ pPr = self._element.pPr
21
+ if pPr is None:
22
+ return None
23
+ return pPr.jc_val
24
+
25
+ @alignment.setter
26
+ def alignment(self, value):
27
+ pPr = self._element.get_or_add_pPr()
28
+ pPr.jc_val = value
29
+
30
+ @property
31
+ def first_line_indent(self):
32
+ """|Length| value specifying the relative difference in indentation for the
33
+ first line of the paragraph.
34
+
35
+ A positive value causes the first line to be indented. A negative value produces
36
+ a hanging indent. |None| indicates first line indentation is inherited from the
37
+ style hierarchy.
38
+ """
39
+ pPr = self._element.pPr
40
+ if pPr is None:
41
+ return None
42
+ return pPr.first_line_indent
43
+
44
+ @first_line_indent.setter
45
+ def first_line_indent(self, value):
46
+ pPr = self._element.get_or_add_pPr()
47
+ pPr.first_line_indent = value
48
+
49
+ @property
50
+ def keep_together(self):
51
+ """|True| if the paragraph should be kept "in one piece" and not broken across a
52
+ page boundary when the document is rendered.
53
+
54
+ |None| indicates its effective value is inherited from the style hierarchy.
55
+ """
56
+ pPr = self._element.pPr
57
+ if pPr is None:
58
+ return None
59
+ return pPr.keepLines_val
60
+
61
+ @keep_together.setter
62
+ def keep_together(self, value):
63
+ self._element.get_or_add_pPr().keepLines_val = value
64
+
65
+ @property
66
+ def keep_with_next(self):
67
+ """|True| if the paragraph should be kept on the same page as the subsequent
68
+ paragraph when the document is rendered.
69
+
70
+ For example, this property could be used to keep a section heading on the same
71
+ page as its first paragraph. |None| indicates its effective value is inherited
72
+ from the style hierarchy.
73
+ """
74
+ pPr = self._element.pPr
75
+ if pPr is None:
76
+ return None
77
+ return pPr.keepNext_val
78
+
79
+ @keep_with_next.setter
80
+ def keep_with_next(self, value):
81
+ self._element.get_or_add_pPr().keepNext_val = value
82
+
83
+ @property
84
+ def left_indent(self):
85
+ """|Length| value specifying the space between the left margin and the left side
86
+ of the paragraph.
87
+
88
+ |None| indicates the left indent value is inherited from the style hierarchy.
89
+ Use an |Inches| value object as a convenient way to apply indentation in units
90
+ of inches.
91
+ """
92
+ pPr = self._element.pPr
93
+ if pPr is None:
94
+ return None
95
+ return pPr.ind_left
96
+
97
+ @left_indent.setter
98
+ def left_indent(self, value):
99
+ pPr = self._element.get_or_add_pPr()
100
+ pPr.ind_left = value
101
+
102
+ @property
103
+ def line_spacing(self):
104
+ """|float| or |Length| value specifying the space between baselines in
105
+ successive lines of the paragraph.
106
+
107
+ A value of |None| indicates line spacing is inherited from the style hierarchy.
108
+ A float value, e.g. ``2.0`` or ``1.75``, indicates spacing is applied in
109
+ multiples of line heights. A |Length| value such as ``Pt(12)`` indicates spacing
110
+ is a fixed height. The |Pt| value class is a convenient way to apply line
111
+ spacing in units of points. Assigning |None| resets line spacing to inherit from
112
+ the style hierarchy.
113
+ """
114
+ pPr = self._element.pPr
115
+ if pPr is None:
116
+ return None
117
+ return self._line_spacing(pPr.spacing_line, pPr.spacing_lineRule)
118
+
119
+ @line_spacing.setter
120
+ def line_spacing(self, value):
121
+ pPr = self._element.get_or_add_pPr()
122
+ if value is None:
123
+ pPr.spacing_line = None
124
+ pPr.spacing_lineRule = None
125
+ elif isinstance(value, Length):
126
+ pPr.spacing_line = value
127
+ if pPr.spacing_lineRule != WD_LINE_SPACING.AT_LEAST:
128
+ pPr.spacing_lineRule = WD_LINE_SPACING.EXACTLY
129
+ else:
130
+ pPr.spacing_line = Emu(value * Twips(240))
131
+ pPr.spacing_lineRule = WD_LINE_SPACING.MULTIPLE
132
+
133
+ @property
134
+ def line_spacing_rule(self):
135
+ """A member of the :ref:`WdLineSpacing` enumeration indicating how the value of
136
+ :attr:`line_spacing` should be interpreted.
137
+
138
+ Assigning any of the :ref:`WdLineSpacing` members :attr:`SINGLE`,
139
+ :attr:`DOUBLE`, or :attr:`ONE_POINT_FIVE` will cause the value of
140
+ :attr:`line_spacing` to be updated to produce the corresponding line spacing.
141
+ """
142
+ pPr = self._element.pPr
143
+ if pPr is None:
144
+ return None
145
+ return self._line_spacing_rule(pPr.spacing_line, pPr.spacing_lineRule)
146
+
147
+ @line_spacing_rule.setter
148
+ def line_spacing_rule(self, value):
149
+ pPr = self._element.get_or_add_pPr()
150
+ if value == WD_LINE_SPACING.SINGLE:
151
+ pPr.spacing_line = Twips(240)
152
+ pPr.spacing_lineRule = WD_LINE_SPACING.MULTIPLE
153
+ elif value == WD_LINE_SPACING.ONE_POINT_FIVE:
154
+ pPr.spacing_line = Twips(360)
155
+ pPr.spacing_lineRule = WD_LINE_SPACING.MULTIPLE
156
+ elif value == WD_LINE_SPACING.DOUBLE:
157
+ pPr.spacing_line = Twips(480)
158
+ pPr.spacing_lineRule = WD_LINE_SPACING.MULTIPLE
159
+ else:
160
+ pPr.spacing_lineRule = value
161
+
162
+ @property
163
+ def page_break_before(self):
164
+ """|True| if the paragraph should appear at the top of the page following the
165
+ prior paragraph.
166
+
167
+ |None| indicates its effective value is inherited from the style hierarchy.
168
+ """
169
+ pPr = self._element.pPr
170
+ if pPr is None:
171
+ return None
172
+ return pPr.pageBreakBefore_val
173
+
174
+ @page_break_before.setter
175
+ def page_break_before(self, value):
176
+ self._element.get_or_add_pPr().pageBreakBefore_val = value
177
+
178
+ @property
179
+ def right_indent(self):
180
+ """|Length| value specifying the space between the right margin and the right
181
+ side of the paragraph.
182
+
183
+ |None| indicates the right indent value is inherited from the style hierarchy.
184
+ Use a |Cm| value object as a convenient way to apply indentation in units of
185
+ centimeters.
186
+ """
187
+ pPr = self._element.pPr
188
+ if pPr is None:
189
+ return None
190
+ return pPr.ind_right
191
+
192
+ @right_indent.setter
193
+ def right_indent(self, value):
194
+ pPr = self._element.get_or_add_pPr()
195
+ pPr.ind_right = value
196
+
197
+ @property
198
+ def space_after(self):
199
+ """|Length| value specifying the spacing to appear between this paragraph and
200
+ the subsequent paragraph.
201
+
202
+ |None| indicates this value is inherited from the style hierarchy. |Length|
203
+ objects provide convenience properties, such as :attr:`~.Length.pt` and
204
+ :attr:`~.Length.inches`, that allow easy conversion to various length units.
205
+ """
206
+ pPr = self._element.pPr
207
+ if pPr is None:
208
+ return None
209
+ return pPr.spacing_after
210
+
211
+ @space_after.setter
212
+ def space_after(self, value):
213
+ self._element.get_or_add_pPr().spacing_after = value
214
+
215
+ @property
216
+ def space_before(self):
217
+ """|Length| value specifying the spacing to appear between this paragraph and
218
+ the prior paragraph.
219
+
220
+ |None| indicates this value is inherited from the style hierarchy. |Length|
221
+ objects provide convenience properties, such as :attr:`~.Length.pt` and
222
+ :attr:`~.Length.cm`, that allow easy conversion to various length units.
223
+ """
224
+ pPr = self._element.pPr
225
+ if pPr is None:
226
+ return None
227
+ return pPr.spacing_before
228
+
229
+ @space_before.setter
230
+ def space_before(self, value):
231
+ self._element.get_or_add_pPr().spacing_before = value
232
+
233
+ @lazyproperty
234
+ def tab_stops(self):
235
+ """|TabStops| object providing access to the tab stops defined for this
236
+ paragraph format."""
237
+ pPr = self._element.get_or_add_pPr()
238
+ return TabStops(pPr)
239
+
240
+ @property
241
+ def widow_control(self):
242
+ """|True| if the first and last lines in the paragraph remain on the same page
243
+ as the rest of the paragraph when Word repaginates the document.
244
+
245
+ |None| indicates its effective value is inherited from the style hierarchy.
246
+ """
247
+ pPr = self._element.pPr
248
+ if pPr is None:
249
+ return None
250
+ return pPr.widowControl_val
251
+
252
+ @widow_control.setter
253
+ def widow_control(self, value):
254
+ self._element.get_or_add_pPr().widowControl_val = value
255
+
256
+ @staticmethod
257
+ def _line_spacing(spacing_line, spacing_lineRule):
258
+ """Return the line spacing value calculated from the combination of
259
+ `spacing_line` and `spacing_lineRule`.
260
+
261
+ Returns a |float| number of lines when `spacing_lineRule` is
262
+ ``WD_LINE_SPACING.MULTIPLE``, otherwise a |Length| object of absolute line
263
+ height is returned. Returns |None| when `spacing_line` is |None|.
264
+ """
265
+ if spacing_line is None:
266
+ return None
267
+ if spacing_lineRule == WD_LINE_SPACING.MULTIPLE:
268
+ return spacing_line / Pt(12)
269
+ return spacing_line
270
+
271
+ @staticmethod
272
+ def _line_spacing_rule(line, lineRule):
273
+ """Return the line spacing rule value calculated from the combination of `line`
274
+ and `lineRule`.
275
+
276
+ Returns special members of the :ref:`WdLineSpacing` enumeration when line
277
+ spacing is single, double, or 1.5 lines.
278
+ """
279
+ if lineRule == WD_LINE_SPACING.MULTIPLE:
280
+ if line == Twips(240):
281
+ return WD_LINE_SPACING.SINGLE
282
+ if line == Twips(360):
283
+ return WD_LINE_SPACING.ONE_POINT_FIVE
284
+ if line == Twips(480):
285
+ return WD_LINE_SPACING.DOUBLE
286
+ return lineRule