python-pptx2 2.13.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 (175) hide show
  1. pptx2/__init__.py +152 -0
  2. pptx2/_color.py +75 -0
  3. pptx2/_slide_importer.py +597 -0
  4. pptx2/_svg.py +155 -0
  5. pptx2/_template_applier.py +292 -0
  6. pptx2/_textstyle.py +187 -0
  7. pptx2/accessibility.py +365 -0
  8. pptx2/action.py +270 -0
  9. pptx2/animation.py +2237 -0
  10. pptx2/api.py +49 -0
  11. pptx2/audit.py +258 -0
  12. pptx2/chart/__init__.py +0 -0
  13. pptx2/chart/analytics.py +381 -0
  14. pptx2/chart/axis.py +543 -0
  15. pptx2/chart/category.py +200 -0
  16. pptx2/chart/chart.py +670 -0
  17. pptx2/chart/data.py +864 -0
  18. pptx2/chart/datalabel.py +406 -0
  19. pptx2/chart/legend.py +86 -0
  20. pptx2/chart/marker.py +70 -0
  21. pptx2/chart/palettes.py +129 -0
  22. pptx2/chart/plot.py +462 -0
  23. pptx2/chart/point.py +101 -0
  24. pptx2/chart/quick_layouts.py +325 -0
  25. pptx2/chart/series.py +334 -0
  26. pptx2/chart/xlsx.py +272 -0
  27. pptx2/chart/xmlwriter.py +1845 -0
  28. pptx2/compose/__init__.py +28 -0
  29. pptx2/compose/from_spec.py +1094 -0
  30. pptx2/design/__init__.py +8 -0
  31. pptx2/design/components.py +607 -0
  32. pptx2/design/figures.py +389 -0
  33. pptx2/design/layout.py +370 -0
  34. pptx2/design/recipes.py +1967 -0
  35. pptx2/design/style.py +209 -0
  36. pptx2/design/tokens.py +915 -0
  37. pptx2/diagrams.py +754 -0
  38. pptx2/dml/__init__.py +0 -0
  39. pptx2/dml/chtfmt.py +40 -0
  40. pptx2/dml/color.py +496 -0
  41. pptx2/dml/effect.py +909 -0
  42. pptx2/dml/fill.py +691 -0
  43. pptx2/dml/line.py +287 -0
  44. pptx2/dml/picture.py +212 -0
  45. pptx2/dml/three_d.py +381 -0
  46. pptx2/enum/__init__.py +0 -0
  47. pptx2/enum/action.py +71 -0
  48. pptx2/enum/animation.py +31 -0
  49. pptx2/enum/base.py +218 -0
  50. pptx2/enum/chart.py +574 -0
  51. pptx2/enum/dml.py +740 -0
  52. pptx2/enum/lang.py +685 -0
  53. pptx2/enum/presentation.py +133 -0
  54. pptx2/enum/shapes.py +1029 -0
  55. pptx2/enum/text.py +230 -0
  56. pptx2/exc.py +42 -0
  57. pptx2/formats.py +139 -0
  58. pptx2/geometry.py +420 -0
  59. pptx2/inherit.py +109 -0
  60. pptx2/lint.py +2256 -0
  61. pptx2/math.py +177 -0
  62. pptx2/media.py +197 -0
  63. pptx2/opc/__init__.py +0 -0
  64. pptx2/opc/constants.py +332 -0
  65. pptx2/opc/oxml.py +188 -0
  66. pptx2/opc/package.py +762 -0
  67. pptx2/opc/packuri.py +109 -0
  68. pptx2/opc/serialized.py +296 -0
  69. pptx2/opc/shared.py +20 -0
  70. pptx2/opc/spec.py +45 -0
  71. pptx2/oxml/__init__.py +555 -0
  72. pptx2/oxml/action.py +53 -0
  73. pptx2/oxml/chart/__init__.py +0 -0
  74. pptx2/oxml/chart/axis.py +337 -0
  75. pptx2/oxml/chart/chart.py +481 -0
  76. pptx2/oxml/chart/datalabel.py +253 -0
  77. pptx2/oxml/chart/legend.py +72 -0
  78. pptx2/oxml/chart/marker.py +61 -0
  79. pptx2/oxml/chart/plot.py +365 -0
  80. pptx2/oxml/chart/series.py +425 -0
  81. pptx2/oxml/chart/shared.py +220 -0
  82. pptx2/oxml/coreprops.py +288 -0
  83. pptx2/oxml/dml/__init__.py +0 -0
  84. pptx2/oxml/dml/color.py +135 -0
  85. pptx2/oxml/dml/effect.py +213 -0
  86. pptx2/oxml/dml/fill.py +316 -0
  87. pptx2/oxml/dml/line.py +12 -0
  88. pptx2/oxml/dml/three_d.py +110 -0
  89. pptx2/oxml/ns.py +135 -0
  90. pptx2/oxml/presentation.py +313 -0
  91. pptx2/oxml/shapes/__init__.py +19 -0
  92. pptx2/oxml/shapes/autoshape.py +467 -0
  93. pptx2/oxml/shapes/connector.py +107 -0
  94. pptx2/oxml/shapes/graphfrm.py +347 -0
  95. pptx2/oxml/shapes/groupshape.py +329 -0
  96. pptx2/oxml/shapes/picture.py +270 -0
  97. pptx2/oxml/shapes/shared.py +577 -0
  98. pptx2/oxml/simpletypes.py +1027 -0
  99. pptx2/oxml/slide.py +563 -0
  100. pptx2/oxml/table.py +650 -0
  101. pptx2/oxml/text.py +815 -0
  102. pptx2/oxml/theme.py +36 -0
  103. pptx2/oxml/xmlchemy.py +717 -0
  104. pptx2/package.py +222 -0
  105. pptx2/parts/__init__.py +0 -0
  106. pptx2/parts/chart.py +95 -0
  107. pptx2/parts/coreprops.py +167 -0
  108. pptx2/parts/diagram.py +37 -0
  109. pptx2/parts/embeddedpackage.py +93 -0
  110. pptx2/parts/image.py +275 -0
  111. pptx2/parts/media.py +37 -0
  112. pptx2/parts/presentation.py +136 -0
  113. pptx2/parts/slide.py +371 -0
  114. pptx2/presentation.py +408 -0
  115. pptx2/py.typed +0 -0
  116. pptx2/render.py +586 -0
  117. pptx2/section.py +272 -0
  118. pptx2/shapes/__init__.py +26 -0
  119. pptx2/shapes/autoshape.py +442 -0
  120. pptx2/shapes/base.py +1078 -0
  121. pptx2/shapes/connector.py +297 -0
  122. pptx2/shapes/freeform.py +337 -0
  123. pptx2/shapes/graphfrm.py +316 -0
  124. pptx2/shapes/group.py +264 -0
  125. pptx2/shapes/picture.py +422 -0
  126. pptx2/shapes/placeholder.py +468 -0
  127. pptx2/shapes/shapetree.py +2027 -0
  128. pptx2/shared.py +82 -0
  129. pptx2/skill/SKILL.md +450 -0
  130. pptx2/skill/__init__.py +78 -0
  131. pptx2/skill/__main__.py +64 -0
  132. pptx2/skill/references/animations.md +189 -0
  133. pptx2/skill/references/basics.md +421 -0
  134. pptx2/skill/references/charts.md +254 -0
  135. pptx2/skill/references/compose.md +234 -0
  136. pptx2/skill/references/design.md +366 -0
  137. pptx2/skill/references/effects.md +249 -0
  138. pptx2/skill/references/end-to-end-deck.md +231 -0
  139. pptx2/skill/references/geometry-and-arrows.md +334 -0
  140. pptx2/skill/references/lint.md +275 -0
  141. pptx2/skill/references/math.md +86 -0
  142. pptx2/skill/references/picture-effects.md +129 -0
  143. pptx2/skill/references/render.md +151 -0
  144. pptx2/skill/references/smart-art.md +75 -0
  145. pptx2/skill/references/space-aware-authoring.md +249 -0
  146. pptx2/skill/references/tables.md +244 -0
  147. pptx2/skill/references/theme.md +127 -0
  148. pptx2/skill/references/three-d.md +109 -0
  149. pptx2/skill/references/transitions.md +100 -0
  150. pptx2/slide.py +1244 -0
  151. pptx2/smart_art.py +220 -0
  152. pptx2/spec.py +633 -0
  153. pptx2/table.py +1181 -0
  154. pptx2/table_styles.py +184 -0
  155. pptx2/templates/default.pptx +0 -0
  156. pptx2/templates/docx-icon.emf +0 -0
  157. pptx2/templates/generic-icon.emf +0 -0
  158. pptx2/templates/notes.xml +23 -0
  159. pptx2/templates/notesMaster.xml +352 -0
  160. pptx2/templates/pptx-icon.emf +0 -0
  161. pptx2/templates/theme.xml +321 -0
  162. pptx2/templates/xlsx-icon.emf +0 -0
  163. pptx2/text/__init__.py +0 -0
  164. pptx2/text/fonts.py +482 -0
  165. pptx2/text/layout.py +374 -0
  166. pptx2/text/text.py +1272 -0
  167. pptx2/theme.py +721 -0
  168. pptx2/types.py +36 -0
  169. pptx2/util.py +263 -0
  170. python_pptx2-2.13.0.dist-info/METADATA +351 -0
  171. python_pptx2-2.13.0.dist-info/RECORD +175 -0
  172. python_pptx2-2.13.0.dist-info/WHEEL +5 -0
  173. python_pptx2-2.13.0.dist-info/entry_points.txt +3 -0
  174. python_pptx2-2.13.0.dist-info/licenses/LICENSE +22 -0
  175. python_pptx2-2.13.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,365 @@
1
+ """Plot-related oxml objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pptx2.oxml.chart.datalabel import CT_DLbls
6
+ from pptx2.oxml.simpletypes import (
7
+ ST_BarDir,
8
+ ST_BubbleScale,
9
+ ST_GapAmount,
10
+ ST_Grouping,
11
+ ST_HoleSize,
12
+ ST_Overlap,
13
+ )
14
+ from pptx2.oxml.xmlchemy import (
15
+ BaseOxmlElement,
16
+ OneAndOnlyOne,
17
+ OptionalAttribute,
18
+ ZeroOrMore,
19
+ ZeroOrOne,
20
+ )
21
+
22
+
23
+ class BaseChartElement(BaseOxmlElement):
24
+ """
25
+ Base class for barChart, lineChart, and other plot elements.
26
+ """
27
+
28
+ @property
29
+ def cat(self):
30
+ """
31
+ Return the `c:cat` element of the first series in this xChart, or
32
+ |None| if not present.
33
+ """
34
+ cats = self.xpath("./c:ser[1]/c:cat")
35
+ return cats[0] if cats else None
36
+
37
+ @property
38
+ def cat_pt_count(self):
39
+ """
40
+ Return the value of the `c:ptCount` descendent of this xChart
41
+ element. Its parent can be one of three element types. This value
42
+ represents the true number of (leaf) categories, although they might
43
+ not all have a corresponding `c:pt` sibling; a category with no label
44
+ does not get a `c:pt` element. Returns 0 if there is no `c:ptCount`
45
+ descendent.
46
+ """
47
+ cat_ptCounts = self.xpath("./c:ser//c:cat//c:ptCount")
48
+ if not cat_ptCounts:
49
+ return 0
50
+ return cat_ptCounts[0].val
51
+
52
+ @property
53
+ def cat_pts(self):
54
+ """
55
+ Return a sequence representing the `c:pt` elements under the `c:cat`
56
+ element of the first series in this xChart element. A category having
57
+ no value will have no corresponding `c:pt` element; |None| will
58
+ appear in that position in such cases. Items appear in `idx` order.
59
+ Only those in the first ``<c:lvl>`` element are included in the case
60
+ of multi-level categories.
61
+ """
62
+ cat_pts = self.xpath("./c:ser[1]/c:cat//c:lvl[1]/c:pt")
63
+ if not cat_pts:
64
+ cat_pts = self.xpath("./c:ser[1]/c:cat//c:pt")
65
+
66
+ cat_pt_dict = dict((pt.idx, pt) for pt in cat_pts)
67
+
68
+ return [cat_pt_dict.get(idx, None) for idx in range(self.cat_pt_count)]
69
+
70
+ @property
71
+ def grouping_val(self):
72
+ """
73
+ Return the value of the ``./c:grouping{val=?}`` attribute, taking
74
+ defaults into account when items are not present.
75
+ """
76
+ grouping = self.grouping
77
+ if grouping is None:
78
+ return ST_Grouping.STANDARD
79
+ val = grouping.val
80
+ if val is None:
81
+ return ST_Grouping.STANDARD
82
+ return val
83
+
84
+ def iter_sers(self):
85
+ """
86
+ Generate each ``<c:ser>`` child element in this xChart in
87
+ c:order/@val sequence (not document or c:idx order).
88
+ """
89
+
90
+ def ser_order(ser):
91
+ return ser.order.val
92
+
93
+ return (ser for ser in sorted(self.xpath("./c:ser"), key=ser_order))
94
+
95
+ @property
96
+ def sers(self):
97
+ """
98
+ Sequence of ``<c:ser>`` child elements in this xChart in c:order/@val
99
+ sequence (not document or c:idx order).
100
+ """
101
+ return tuple(self.iter_sers())
102
+
103
+ def _new_dLbls(self):
104
+ return CT_DLbls.new_dLbls()
105
+
106
+
107
+ class CT_Area3DChart(BaseChartElement):
108
+ """
109
+ ``<c:area3DChart>`` element.
110
+ """
111
+
112
+ grouping = ZeroOrOne(
113
+ "c:grouping",
114
+ successors=(
115
+ "c:varyColors",
116
+ "c:ser",
117
+ "c:dLbls",
118
+ "c:dropLines",
119
+ "c:gapDepth",
120
+ "c:axId",
121
+ ),
122
+ )
123
+
124
+
125
+ class CT_AreaChart(BaseChartElement):
126
+ """
127
+ ``<c:areaChart>`` element.
128
+ """
129
+
130
+ _tag_seq = (
131
+ "c:grouping",
132
+ "c:varyColors",
133
+ "c:ser",
134
+ "c:dLbls",
135
+ "c:dropLines",
136
+ "c:axId",
137
+ "c:extLst",
138
+ )
139
+ grouping = ZeroOrOne("c:grouping", successors=_tag_seq[1:])
140
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
141
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
142
+ dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[4:])
143
+ del _tag_seq
144
+
145
+
146
+ class CT_BarChart(BaseChartElement):
147
+ """
148
+ ``<c:barChart>`` element.
149
+ """
150
+
151
+ _tag_seq = (
152
+ "c:barDir",
153
+ "c:grouping",
154
+ "c:varyColors",
155
+ "c:ser",
156
+ "c:dLbls",
157
+ "c:gapWidth",
158
+ "c:overlap",
159
+ "c:serLines",
160
+ "c:axId",
161
+ "c:extLst",
162
+ )
163
+ barDir = OneAndOnlyOne("c:barDir")
164
+ grouping = ZeroOrOne("c:grouping", successors=_tag_seq[2:])
165
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[3:])
166
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[4:])
167
+ dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[5:])
168
+ gapWidth = ZeroOrOne("c:gapWidth", successors=_tag_seq[6:])
169
+ overlap = ZeroOrOne("c:overlap", successors=_tag_seq[7:])
170
+ del _tag_seq
171
+
172
+ @property
173
+ def grouping_val(self):
174
+ """
175
+ Return the value of the ``./c:grouping{val=?}`` attribute, taking
176
+ defaults into account when items are not present.
177
+ """
178
+ grouping = self.grouping
179
+ if grouping is None:
180
+ return ST_Grouping.CLUSTERED
181
+ val = grouping.val
182
+ if val is None:
183
+ return ST_Grouping.CLUSTERED
184
+ return val
185
+
186
+
187
+ class CT_BarDir(BaseOxmlElement):
188
+ """
189
+ ``<c:barDir>`` child of a barChart element, specifying the orientation of
190
+ the bars, 'bar' if they are horizontal and 'col' if they are vertical.
191
+ """
192
+
193
+ val = OptionalAttribute("val", ST_BarDir, default=ST_BarDir.COL)
194
+
195
+
196
+ class CT_BubbleChart(BaseChartElement):
197
+ """
198
+ ``<c:bubbleChart>`` custom element class
199
+ """
200
+
201
+ _tag_seq = (
202
+ "c:varyColors",
203
+ "c:ser",
204
+ "c:dLbls",
205
+ "c:axId",
206
+ "c:bubble3D",
207
+ "c:bubbleScale",
208
+ "c:showNegBubbles",
209
+ "c:sizeRepresents",
210
+ "c:axId",
211
+ "c:extLst",
212
+ )
213
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
214
+ dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
215
+ bubble3D = ZeroOrOne("c:bubble3D", successors=_tag_seq[5:])
216
+ bubbleScale = ZeroOrOne("c:bubbleScale", successors=_tag_seq[6:])
217
+ del _tag_seq
218
+
219
+
220
+ class CT_BubbleScale(BaseChartElement):
221
+ """
222
+ ``<c:bubbleScale>`` custom element class
223
+ """
224
+
225
+ val = OptionalAttribute("val", ST_BubbleScale, default=100)
226
+
227
+
228
+ class CT_DoughnutChart(BaseChartElement):
229
+ """
230
+ ``<c:doughnutChart>`` element.
231
+ """
232
+
233
+ _tag_seq = (
234
+ "c:varyColors",
235
+ "c:ser",
236
+ "c:dLbls",
237
+ "c:firstSliceAng",
238
+ "c:holeSize",
239
+ "c:extLst",
240
+ )
241
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[1:])
242
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
243
+ dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
244
+ holeSize = ZeroOrOne("c:holeSize", successors=_tag_seq[5:])
245
+ del _tag_seq
246
+
247
+
248
+ class CT_GapAmount(BaseOxmlElement):
249
+ """
250
+ ``<c:gapWidth>`` child of ``<c:barChart>`` element, also used for other
251
+ purposes like error bars.
252
+ """
253
+
254
+ val = OptionalAttribute("val", ST_GapAmount, default=150)
255
+
256
+
257
+ class CT_HoleSize(BaseOxmlElement):
258
+ """
259
+ ``<c:holeSize>`` child of a ``<c:doughnutChart>`` element, specifying the
260
+ size of the doughnut hole as an integer percentage of the chart radius.
261
+ """
262
+
263
+ val = OptionalAttribute("val", ST_HoleSize, default=10)
264
+
265
+
266
+ class CT_Grouping(BaseOxmlElement):
267
+ """
268
+ ``<c:grouping>`` child of an xChart element, specifying a value like
269
+ 'clustered' or 'stacked'. Also used for variants with the same tag name
270
+ like CT_BarGrouping.
271
+ """
272
+
273
+ val = OptionalAttribute("val", ST_Grouping)
274
+
275
+
276
+ class CT_LineChart(BaseChartElement):
277
+ """
278
+ ``<c:lineChart>`` custom element class
279
+ """
280
+
281
+ _tag_seq = (
282
+ "c:grouping",
283
+ "c:varyColors",
284
+ "c:ser",
285
+ "c:dLbls",
286
+ "c:dropLines",
287
+ "c:hiLowLines",
288
+ "c:upDownBars",
289
+ "c:marker",
290
+ "c:smooth",
291
+ "c:axId",
292
+ "c:extLst",
293
+ )
294
+ grouping = ZeroOrOne("c:grouping", successors=(_tag_seq[1:]))
295
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
296
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
297
+ dLbls = ZeroOrOne("c:dLbls", successors=(_tag_seq[4:]))
298
+ del _tag_seq
299
+
300
+
301
+ class CT_Overlap(BaseOxmlElement):
302
+ """
303
+ ``<c:overlap>`` element specifying bar overlap as an integer percentage
304
+ of bar width, in range -100 to 100.
305
+ """
306
+
307
+ val = OptionalAttribute("val", ST_Overlap, default=0)
308
+
309
+
310
+ class CT_PieChart(BaseChartElement):
311
+ """
312
+ ``<c:pieChart>`` custom element class
313
+ """
314
+
315
+ _tag_seq = ("c:varyColors", "c:ser", "c:dLbls", "c:firstSliceAng", "c:extLst")
316
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[1:])
317
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[2:])
318
+ dLbls = ZeroOrOne("c:dLbls", successors=_tag_seq[3:])
319
+ del _tag_seq
320
+
321
+
322
+ class CT_RadarChart(BaseChartElement):
323
+ """
324
+ ``<c:radarChart>`` custom element class
325
+ """
326
+
327
+ _tag_seq = (
328
+ "c:radarStyle",
329
+ "c:varyColors",
330
+ "c:ser",
331
+ "c:dLbls",
332
+ "c:axId",
333
+ "c:extLst",
334
+ )
335
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
336
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
337
+ dLbls = ZeroOrOne("c:dLbls", successors=(_tag_seq[4:]))
338
+ del _tag_seq
339
+
340
+
341
+ class CT_ScatterChart(BaseChartElement):
342
+ """
343
+ ``<c:scatterChart>`` custom element class
344
+ """
345
+
346
+ _tag_seq = (
347
+ "c:scatterStyle",
348
+ "c:varyColors",
349
+ "c:ser",
350
+ "c:dLbls",
351
+ "c:axId",
352
+ "c:extLst",
353
+ )
354
+ varyColors = ZeroOrOne("c:varyColors", successors=_tag_seq[2:])
355
+ ser = ZeroOrMore("c:ser", successors=_tag_seq[3:])
356
+ dLbls = ZeroOrOne("c:dLbls", successors=(_tag_seq[4:]))
357
+ del _tag_seq
358
+
359
+
360
+ # -- element-class registrations for elements introduced in this module that
361
+ # -- are not registered from `pptx2.oxml.__init__`. The import is local to
362
+ # -- avoid a circular import at package-initialization time.
363
+ from pptx2.oxml import register_element_cls # noqa: E402
364
+
365
+ register_element_cls("c:holeSize", CT_HoleSize)