ps-python-pptx 1.1.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 (117) hide show
  1. pptx/__init__.py +84 -0
  2. pptx/action.py +270 -0
  3. pptx/api.py +49 -0
  4. pptx/chart/__init__.py +0 -0
  5. pptx/chart/axis.py +523 -0
  6. pptx/chart/category.py +200 -0
  7. pptx/chart/chart.py +280 -0
  8. pptx/chart/data.py +864 -0
  9. pptx/chart/datalabel.py +288 -0
  10. pptx/chart/legend.py +79 -0
  11. pptx/chart/marker.py +70 -0
  12. pptx/chart/plot.py +412 -0
  13. pptx/chart/point.py +101 -0
  14. pptx/chart/series.py +258 -0
  15. pptx/chart/xlsx.py +272 -0
  16. pptx/chart/xmlwriter.py +1840 -0
  17. pptx/dml/__init__.py +0 -0
  18. pptx/dml/chtfmt.py +40 -0
  19. pptx/dml/color.py +301 -0
  20. pptx/dml/effect.py +41 -0
  21. pptx/dml/fill.py +468 -0
  22. pptx/dml/line.py +100 -0
  23. pptx/enum/__init__.py +0 -0
  24. pptx/enum/action.py +71 -0
  25. pptx/enum/base.py +175 -0
  26. pptx/enum/chart.py +492 -0
  27. pptx/enum/dml.py +405 -0
  28. pptx/enum/lang.py +685 -0
  29. pptx/enum/shapes.py +1029 -0
  30. pptx/enum/text.py +371 -0
  31. pptx/exc.py +23 -0
  32. pptx/media.py +197 -0
  33. pptx/opc/__init__.py +0 -0
  34. pptx/opc/constants.py +331 -0
  35. pptx/opc/oxml.py +188 -0
  36. pptx/opc/package.py +762 -0
  37. pptx/opc/packuri.py +109 -0
  38. pptx/opc/serialized.py +296 -0
  39. pptx/opc/shared.py +20 -0
  40. pptx/opc/spec.py +44 -0
  41. pptx/oxml/__init__.py +492 -0
  42. pptx/oxml/action.py +53 -0
  43. pptx/oxml/chart/__init__.py +0 -0
  44. pptx/oxml/chart/axis.py +297 -0
  45. pptx/oxml/chart/chart.py +282 -0
  46. pptx/oxml/chart/datalabel.py +252 -0
  47. pptx/oxml/chart/legend.py +72 -0
  48. pptx/oxml/chart/marker.py +61 -0
  49. pptx/oxml/chart/plot.py +345 -0
  50. pptx/oxml/chart/series.py +254 -0
  51. pptx/oxml/chart/shared.py +219 -0
  52. pptx/oxml/coreprops.py +288 -0
  53. pptx/oxml/dml/__init__.py +0 -0
  54. pptx/oxml/dml/color.py +111 -0
  55. pptx/oxml/dml/fill.py +197 -0
  56. pptx/oxml/dml/line.py +12 -0
  57. pptx/oxml/ns.py +129 -0
  58. pptx/oxml/presentation.py +130 -0
  59. pptx/oxml/shapes/__init__.py +19 -0
  60. pptx/oxml/shapes/autoshape.py +455 -0
  61. pptx/oxml/shapes/connector.py +107 -0
  62. pptx/oxml/shapes/graphfrm.py +342 -0
  63. pptx/oxml/shapes/groupshape.py +280 -0
  64. pptx/oxml/shapes/picture.py +270 -0
  65. pptx/oxml/shapes/shared.py +523 -0
  66. pptx/oxml/simpletypes.py +740 -0
  67. pptx/oxml/slide.py +347 -0
  68. pptx/oxml/table.py +588 -0
  69. pptx/oxml/text.py +748 -0
  70. pptx/oxml/theme.py +29 -0
  71. pptx/oxml/xmlchemy.py +717 -0
  72. pptx/package.py +222 -0
  73. pptx/parts/__init__.py +0 -0
  74. pptx/parts/chart.py +95 -0
  75. pptx/parts/coreprops.py +167 -0
  76. pptx/parts/embeddedpackage.py +93 -0
  77. pptx/parts/image.py +275 -0
  78. pptx/parts/media.py +37 -0
  79. pptx/parts/presentation.py +126 -0
  80. pptx/parts/slide.py +297 -0
  81. pptx/parts/theme.py +13 -0
  82. pptx/presentation.py +113 -0
  83. pptx/py.typed +0 -0
  84. pptx/shapes/__init__.py +26 -0
  85. pptx/shapes/autoshape.py +355 -0
  86. pptx/shapes/base.py +293 -0
  87. pptx/shapes/connector.py +297 -0
  88. pptx/shapes/freeform.py +337 -0
  89. pptx/shapes/graphfrm.py +166 -0
  90. pptx/shapes/group.py +69 -0
  91. pptx/shapes/picture.py +203 -0
  92. pptx/shapes/placeholder.py +407 -0
  93. pptx/shapes/shapetree.py +1190 -0
  94. pptx/shared.py +82 -0
  95. pptx/slide.py +577 -0
  96. pptx/spec.py +632 -0
  97. pptx/table.py +520 -0
  98. pptx/templates/default.pptx +0 -0
  99. pptx/templates/docx-icon.emf +0 -0
  100. pptx/templates/generic-icon.emf +0 -0
  101. pptx/templates/notes.xml +23 -0
  102. pptx/templates/notesMaster.xml +352 -0
  103. pptx/templates/pptx-icon.emf +0 -0
  104. pptx/templates/theme.xml +321 -0
  105. pptx/templates/xlsx-icon.emf +0 -0
  106. pptx/text/__init__.py +0 -0
  107. pptx/text/fonts.py +399 -0
  108. pptx/text/layout.py +325 -0
  109. pptx/text/text.py +770 -0
  110. pptx/theme.py +135 -0
  111. pptx/types.py +36 -0
  112. pptx/util.py +284 -0
  113. ps_python_pptx-1.1.0.dist-info/METADATA +75 -0
  114. ps_python_pptx-1.1.0.dist-info/RECORD +117 -0
  115. ps_python_pptx-1.1.0.dist-info/WHEEL +5 -0
  116. ps_python_pptx-1.1.0.dist-info/licenses/LICENSE +20 -0
  117. ps_python_pptx-1.1.0.dist-info/top_level.txt +1 -0
pptx/enum/text.py ADDED
@@ -0,0 +1,371 @@
1
+ """Enumerations used by text and related objects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from enum import Enum, auto
6
+
7
+ from pptx.enum.base import BaseEnum, BaseXmlEnum
8
+
9
+
10
+ class MSO_AUTO_SIZE(BaseEnum):
11
+ """Determines the type of automatic sizing allowed.
12
+
13
+ The following names can be used to specify the automatic sizing behavior used to fit a shape's
14
+ text within the shape bounding box, for example::
15
+
16
+ from pptx.enum.text import MSO_AUTO_SIZE
17
+
18
+ shape.text_frame.auto_size = MSO_AUTO_SIZE.TEXT_TO_FIT_SHAPE
19
+
20
+ The word-wrap setting of the text frame interacts with the auto-size setting to determine the
21
+ specific auto-sizing behavior.
22
+
23
+ Note that `TextFrame.auto_size` can also be set to |None|, which removes the auto size setting
24
+ altogether. This causes the setting to be inherited, either from the layout placeholder, in the
25
+ case of a placeholder shape, or from the theme.
26
+
27
+ MS API Name: `MsoAutoSize`
28
+
29
+ http://msdn.microsoft.com/en-us/library/office/ff865367(v=office.15).aspx
30
+ """
31
+
32
+ NONE = (
33
+ 0,
34
+ "No automatic sizing of the shape or text will be done.\n\nText can freely extend beyond"
35
+ " the horizontal and vertical edges of the shape bounding box.",
36
+ )
37
+ """No automatic sizing of the shape or text will be done.
38
+
39
+ Text can freely extend beyond the horizontal and vertical edges of the shape bounding box.
40
+ """
41
+
42
+ SHAPE_TO_FIT_TEXT = (
43
+ 1,
44
+ "The shape height and possibly width are adjusted to fit the text.\n\nNote this setting"
45
+ " interacts with the TextFrame.word_wrap property setting. If word wrap is turned on,"
46
+ " only the height of the shape will be adjusted; soft line breaks will be used to fit the"
47
+ " text horizontally.",
48
+ )
49
+ """The shape height and possibly width are adjusted to fit the text.
50
+
51
+ Note this setting interacts with the TextFrame.word_wrap property setting. If word wrap is
52
+ turned on, only the height of the shape will be adjusted; soft line breaks will be used to fit
53
+ the text horizontally.
54
+ """
55
+
56
+ TEXT_TO_FIT_SHAPE = (
57
+ 2,
58
+ "The font size is reduced as necessary to fit the text within the shape.",
59
+ )
60
+ """The font size is reduced as necessary to fit the text within the shape."""
61
+
62
+ MIXED = (-2, "Return value only; indicates a combination of automatic sizing schemes are used.")
63
+ """Return value only; indicates a combination of automatic sizing schemes are used."""
64
+
65
+
66
+ class MSO_TEXT_UNDERLINE_TYPE(BaseXmlEnum):
67
+ """
68
+ Indicates the type of underline for text. Used with
69
+ :attr:`.Font.underline` to specify the style of text underlining.
70
+
71
+ Alias: ``MSO_UNDERLINE``
72
+
73
+ Example::
74
+
75
+ from pptx.enum.text import MSO_UNDERLINE
76
+
77
+ run.font.underline = MSO_UNDERLINE.DOUBLE_LINE
78
+
79
+ MS API Name: `MsoTextUnderlineType`
80
+
81
+ http://msdn.microsoft.com/en-us/library/aa432699.aspx
82
+ """
83
+
84
+ NONE = (0, "none", "Specifies no underline.")
85
+ """Specifies no underline."""
86
+
87
+ DASH_HEAVY_LINE = (8, "dashHeavy", "Specifies a dash underline.")
88
+ """Specifies a dash underline."""
89
+
90
+ DASH_LINE = (7, "dash", "Specifies a dash line underline.")
91
+ """Specifies a dash line underline."""
92
+
93
+ DASH_LONG_HEAVY_LINE = (10, "dashLongHeavy", "Specifies a long heavy line underline.")
94
+ """Specifies a long heavy line underline."""
95
+
96
+ DASH_LONG_LINE = (9, "dashLong", "Specifies a dashed long line underline.")
97
+ """Specifies a dashed long line underline."""
98
+
99
+ DOT_DASH_HEAVY_LINE = (12, "dotDashHeavy", "Specifies a dot dash heavy line underline.")
100
+ """Specifies a dot dash heavy line underline."""
101
+
102
+ DOT_DASH_LINE = (11, "dotDash", "Specifies a dot dash line underline.")
103
+ """Specifies a dot dash line underline."""
104
+
105
+ DOT_DOT_DASH_HEAVY_LINE = (
106
+ 14,
107
+ "dotDotDashHeavy",
108
+ "Specifies a dot dot dash heavy line underline.",
109
+ )
110
+ """Specifies a dot dot dash heavy line underline."""
111
+
112
+ DOT_DOT_DASH_LINE = (13, "dotDotDash", "Specifies a dot dot dash line underline.")
113
+ """Specifies a dot dot dash line underline."""
114
+
115
+ DOTTED_HEAVY_LINE = (6, "dottedHeavy", "Specifies a dotted heavy line underline.")
116
+ """Specifies a dotted heavy line underline."""
117
+
118
+ DOTTED_LINE = (5, "dotted", "Specifies a dotted line underline.")
119
+ """Specifies a dotted line underline."""
120
+
121
+ DOUBLE_LINE = (3, "dbl", "Specifies a double line underline.")
122
+ """Specifies a double line underline."""
123
+
124
+ HEAVY_LINE = (4, "heavy", "Specifies a heavy line underline.")
125
+ """Specifies a heavy line underline."""
126
+
127
+ SINGLE_LINE = (2, "sng", "Specifies a single line underline.")
128
+ """Specifies a single line underline."""
129
+
130
+ WAVY_DOUBLE_LINE = (17, "wavyDbl", "Specifies a wavy double line underline.")
131
+ """Specifies a wavy double line underline."""
132
+
133
+ WAVY_HEAVY_LINE = (16, "wavyHeavy", "Specifies a wavy heavy line underline.")
134
+ """Specifies a wavy heavy line underline."""
135
+
136
+ WAVY_LINE = (15, "wavy", "Specifies a wavy line underline.")
137
+ """Specifies a wavy line underline."""
138
+
139
+ WORDS = (1, "words", "Specifies underlining words.")
140
+ """Specifies underlining words."""
141
+
142
+ MIXED = (-2, "", "Specifies a mix of underline types (read-only).")
143
+ """Specifies a mix of underline types (read-only)."""
144
+
145
+
146
+ MSO_UNDERLINE = MSO_TEXT_UNDERLINE_TYPE
147
+
148
+
149
+ class MSO_VERTICAL_ANCHOR(BaseXmlEnum):
150
+ """Specifies the vertical alignment of text in a text frame.
151
+
152
+ Used with the `.vertical_anchor` property of the |TextFrame| object. Note that the
153
+ `vertical_anchor` property can also have the value None, indicating there is no directly
154
+ specified vertical anchor setting and its effective value is inherited from its placeholder if
155
+ it has one or from the theme. |None| may also be assigned to remove an explicitly specified
156
+ vertical anchor setting.
157
+
158
+ MS API Name: `MsoVerticalAnchor`
159
+
160
+ http://msdn.microsoft.com/en-us/library/office/ff865255.aspx
161
+ """
162
+
163
+ TOP = (1, "t", "Aligns text to top of text frame")
164
+ """Aligns text to top of text frame"""
165
+
166
+ MIDDLE = (3, "ctr", "Centers text vertically")
167
+ """Centers text vertically"""
168
+
169
+ BOTTOM = (4, "b", "Aligns text to bottom of text frame")
170
+ """Aligns text to bottom of text frame"""
171
+
172
+ MIXED = (-2, "", "Return value only; indicates a combination of the other states.")
173
+ """Return value only; indicates a combination of the other states."""
174
+
175
+
176
+ MSO_ANCHOR = MSO_VERTICAL_ANCHOR
177
+
178
+
179
+ class PP_PARAGRAPH_ALIGNMENT(BaseXmlEnum):
180
+ """Specifies the horizontal alignment for one or more paragraphs.
181
+
182
+ Alias: `PP_ALIGN`
183
+
184
+ Example::
185
+
186
+ from pptx.enum.text import PP_ALIGN
187
+
188
+ shape.paragraphs[0].alignment = PP_ALIGN.CENTER
189
+
190
+ MS API Name: `PpParagraphAlignment`
191
+
192
+ http://msdn.microsoft.com/en-us/library/office/ff745375(v=office.15).aspx
193
+ """
194
+
195
+ CENTER = (2, "ctr", "Center align")
196
+ """Center align"""
197
+
198
+ DISTRIBUTE = (
199
+ 5,
200
+ "dist",
201
+ "Evenly distributes e.g. Japanese characters from left to right within a line",
202
+ )
203
+ """Evenly distributes e.g. Japanese characters from left to right within a line"""
204
+
205
+ JUSTIFY = (
206
+ 4,
207
+ "just",
208
+ "Justified, i.e. each line both begins and ends at the margin.\n\nSpacing between words"
209
+ " is adjusted such that the line exactly fills the width of the paragraph.",
210
+ )
211
+ """Justified, i.e. each line both begins and ends at the margin.
212
+
213
+ Spacing between words is adjusted such that the line exactly fills the width of the paragraph.
214
+ """
215
+
216
+ JUSTIFY_LOW = (7, "justLow", "Justify using a small amount of space between words.")
217
+ """Justify using a small amount of space between words."""
218
+
219
+ LEFT = (1, "l", "Left aligned")
220
+ """Left aligned"""
221
+
222
+ RIGHT = (3, "r", "Right aligned")
223
+ """Right aligned"""
224
+
225
+ THAI_DISTRIBUTE = (6, "thaiDist", "Thai distributed")
226
+ """Thai distributed"""
227
+
228
+ MIXED = (-2, "", "Multiple alignments are present in a set of paragraphs (read-only).")
229
+ """Multiple alignments are present in a set of paragraphs (read-only)."""
230
+
231
+
232
+ PP_ALIGN = PP_PARAGRAPH_ALIGNMENT
233
+
234
+
235
+ class MSO_TEXT_STRIKE_TYPE(BaseXmlEnum):
236
+ """Strikethrough styles for Font.strike."""
237
+
238
+ NONE = (0, "noStrike", "Explicitly disable strikethrough.")
239
+ SINGLE = (1, "sngStrike", "Single strikethrough.")
240
+ DOUBLE = (2, "dblStrike", "Double strikethrough.")
241
+
242
+
243
+ class BulletStyleType(Enum):
244
+ """Types of bullet styles."""
245
+
246
+ NO_BULLET = auto()
247
+ CUSTOM = auto()
248
+ NUMBERED = auto()
249
+ DEFAULT = auto()
250
+
251
+
252
+ class MSO_NUMBERED_BULLET_STYLE(BaseXmlEnum):
253
+ """Specifies the style of numbered bullets.
254
+
255
+ Example::
256
+
257
+ from pptx.enum.text import MSO_NUMBERED_BULLET_STYLE
258
+
259
+ shape.paragraphs[0].bullet = MSO_NUMBERED_BULLET_STYLE.BULLET_ALPHA_UC_PERIOD
260
+
261
+ MS API Name: `MsoNumberedBulletStyle`
262
+
263
+ https://learn.microsoft.com/sv-se/office/vba/api/office.msonumberedbulletstyle
264
+ """
265
+
266
+ ALPHA_LC_PAREN_BOTH = (
267
+ 8,
268
+ "alphaLCParenBoth",
269
+ "Lowercase alphabetical bullet with opening and closing parentheses.",
270
+ )
271
+ ALPHA_LC_PAREN_RIGHT = (
272
+ 9,
273
+ "alphaLCParenRight",
274
+ "Lowercase alphabetical bullet with closing parenthesis.",
275
+ )
276
+ ALPHA_LC_PERIOD = (0, "alphaLCPeriod", "Lowercase alphabetical bullet with period.|")
277
+ ALPHA_UC_PAREN_BOTH = (
278
+ 10,
279
+ "alphaUCParenBoth",
280
+ "Uppercase alphabetical bullet with opening and closing parentheses.",
281
+ )
282
+ ALPHA_UC_PAREN_RIGHT = (
283
+ 11,
284
+ "alphaUCParenRight",
285
+ "Uppercase alphabetical bullet with closing parenthesis.",
286
+ )
287
+ ALPHA_UC_PERIOD = (1, "alphaUCPeriod", "Uppercase alphabetical bullet with period.")
288
+ ARABIC_ABJAD_DASH = (24, "arabicAbjadDash", "Arabic Abjad bullet with a dash.")
289
+ ARABIC_ALPHA_DASH = (23, "arabicAlphaDash", "Arabic alphabetical bullet with a dash.")
290
+ ARABIC_DB_PERIOD = (29, "arabicDBPeriod", "Arabic DB bullet with period.")
291
+ ARABIC_DB_PLAIN = (28, "arabicDBPlain", "Plain Arabic DB bullet.")
292
+ ARABIC_PAREN_BOTH = (
293
+ 12,
294
+ "arabicParenBoth",
295
+ "Arabic bullet with opening and closing parentheses.",
296
+ )
297
+ ARABIC_PAREN_RIGHT = (2, "arabicParenRight", "Arabic bullet with closing parenthesis.")
298
+ ARABIC_PERIOD = (3, "arabicPeriod", "Arabic bullet with period.")
299
+ ARABIC_PLAIN = (13, "arabicPlain", "Plain Arabic bullet.")
300
+ CIRCLE_NUM_DB_PLAIN = (18, "circleNumDBPlain", "Circled number bullet.")
301
+ CIRCLE_NUM_WD_BLACK_PLAIN = (20, "circleNumWDBlackPlain", "Circled number WD black bullet.")
302
+ CIRCLE_NUM_WD_WHITE_PLAIN = (19, "circleNumWDWhitePlain", "Circled number WD white bullet.")
303
+ HEBREW_ALPHA_DASH = (25, "hebrewAlphaDash", "Hebrew alphabetical bullet with dash.")
304
+ HINDI_ALPHA1_PERIOD = (40, "hindiAlpha1Period", "Hindi alphabetical bullet 1 with period.")
305
+ HINDI_ALPHA_PERIOD = (36, "hindiAlphaPeriod", "Hindi alphabetical bullet with period.")
306
+ HINDI_NUM_PAREN_RIGHT = (
307
+ 39,
308
+ "hindiNumParenRight",
309
+ "Hindi numbered bullet with closing parenthesis.",
310
+ )
311
+ HINDI_NUM_PERIOD = (37, "hindiNumPeriod", "Hindi numbered bullet with period.")
312
+ KANJI_KOREAN_PERIOD = (27, "kanjiKoreanPeriod", "Korean Kanji bullet with period.")
313
+ KANJI_KOREAN_PLAIN = (26, "kanjiKoreanPlain", "Korean Kanji bullet.")
314
+ KANJI_SIMP_CHIN_DB_PERIOD = (
315
+ 38,
316
+ "kanjiSimpChinDBPeriod",
317
+ "Simplified Chinese Kanji bulllet with period.",
318
+ )
319
+ ROMAN_LC_PAREN_BOTH = (
320
+ 4,
321
+ "romanLCParenBoth",
322
+ "Lowercase roman bullet with opening and closing parentheses.",
323
+ )
324
+ ROMAN_LC_PAREN_RIGHT = (
325
+ 5,
326
+ "romanLCParenRight",
327
+ "Lowercase roman bullet with closing parenthesis.",
328
+ )
329
+ ROMAN_LC_PERIOD = (6, "romanLCPeriod", "Lowercase roman bullet with period.")
330
+ ROMAN_UC_PAREN_BOTH = (
331
+ 14,
332
+ "romanUCParenBoth",
333
+ "Uppercase roman bullet with opening and closing parentheses.",
334
+ )
335
+ ROMAN_UC_PAREN_RIGHT = (
336
+ 15,
337
+ "romanUCParenRight",
338
+ "Uppercase roman bullet with closing parenthesis.",
339
+ )
340
+ ROMAN_UC_PERIOD = (7, "romanUCPeriod", "Uppercase roman bullet with period.")
341
+ SIMP_CHIN_PERIOD = (17, "simpChinPeriod", "Simplified Chinese bulllet with period.")
342
+ SIMP_CHIN_PLAIN = (16, "simpChinPlain", "Simplified Chinese bullet.")
343
+ STYLE_MIXED = (
344
+ -2,
345
+ "styleMixed",
346
+ "Return value only; indicates a combination of the other states. ",
347
+ )
348
+ THAI_ALPHA_PAREN_BOTH = (
349
+ 32,
350
+ "thaiAlphaParenBoth",
351
+ "Thai alphabetical bullet with opening and closing parentheses.",
352
+ )
353
+ THAI_ALPHA_PAREN_RIGHT = (
354
+ 31,
355
+ "thaiAlphaParenRight",
356
+ "Thai alphabetical bullet with closing parenthesis.",
357
+ )
358
+ THAI_ALPHA_PERIOD = (30, "thaiAlphaPeriod", "Thai alphabetical bullet with period.")
359
+ THAI_NUM_PAREN_BOTH = (
360
+ 35,
361
+ "thaiNumParenBoth",
362
+ "Thai numerical bullet with opening and closing parentheses.",
363
+ )
364
+ THAI_NUM_PAREN_RIGHT = (
365
+ 34,
366
+ "thaiNumParenRight",
367
+ "Thai numerical bullet with closing parenthesis.",
368
+ )
369
+ THAI_NUM_PERIOD = (33, "thaiNumPeriod", "Thai numerical bullet with period.")
370
+ TRAD_CHIN_PERIOD = (22, "tradChinPeriod", "Traditional Chinese bulllet with period.")
371
+ TRAD_CHIN_PLAIN = (21, "tradChinPlain", "Traditional Chinese bulllet.")
pptx/exc.py ADDED
@@ -0,0 +1,23 @@
1
+ """Exceptions used with python-pptx.
2
+
3
+ The base exception class is PythonPptxError.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+
9
+ class PythonPptxError(Exception):
10
+ """Generic error class."""
11
+
12
+
13
+ class PackageNotFoundError(PythonPptxError):
14
+ """
15
+ Raised when a package cannot be found at the specified path.
16
+ """
17
+
18
+
19
+ class InvalidXmlError(PythonPptxError):
20
+ """
21
+ Raised when a value is encountered in the XML that is not valid according
22
+ to the schema.
23
+ """
pptx/media.py ADDED
@@ -0,0 +1,197 @@
1
+ """Objects related to images, audio, and video."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ import hashlib
7
+ import os
8
+ from typing import IO
9
+
10
+ from pptx.opc.constants import CONTENT_TYPE as CT
11
+ from pptx.util import lazyproperty
12
+
13
+
14
+ class Video(object):
15
+ """Immutable value object representing a video such as MP4."""
16
+
17
+ def __init__(self, blob: bytes, mime_type: str | None, filename: str | None):
18
+ super(Video, self).__init__()
19
+ self._blob = blob
20
+ self._mime_type = mime_type
21
+ self._filename = filename
22
+
23
+ @classmethod
24
+ def from_blob(cls, blob: bytes, mime_type: str | None, filename: str | None = None):
25
+ """Return a new |Video| object loaded from image binary in *blob*."""
26
+ return cls(blob, mime_type, filename)
27
+
28
+ @classmethod
29
+ def from_path_or_file_like(cls, movie_file: str | IO[bytes], mime_type: str | None) -> Video:
30
+ """Return a new |Video| object containing video in *movie_file*.
31
+
32
+ *movie_file* can be either a path (string) or a file-like
33
+ (e.g. StringIO) object.
34
+ """
35
+ if isinstance(movie_file, str):
36
+ # treat movie_file as a path
37
+ with open(movie_file, "rb") as f:
38
+ blob = f.read()
39
+ filename = os.path.basename(movie_file)
40
+ else:
41
+ # assume movie_file is a file-like object
42
+ blob = movie_file.read()
43
+ filename = None
44
+
45
+ return cls.from_blob(blob, mime_type, filename)
46
+
47
+ @property
48
+ def blob(self):
49
+ """The bytestream of the media "file"."""
50
+ return self._blob
51
+
52
+ @property
53
+ def content_type(self):
54
+ """MIME-type of this media, e.g. `'video/mp4'`."""
55
+ return self._mime_type
56
+
57
+ @property
58
+ def ext(self):
59
+ """Return the file extension for this video, e.g. 'mp4'.
60
+
61
+ The extension is that from the actual filename if known. Otherwise
62
+ it is the lowercase canonical extension for the video's MIME type.
63
+ 'vid' is used if the MIME type is 'video/unknown'.
64
+ """
65
+ if self._filename:
66
+ return os.path.splitext(self._filename)[1].lstrip(".")
67
+ return {
68
+ CT.ASF: "asf",
69
+ CT.AVI: "avi",
70
+ CT.MOV: "mov",
71
+ CT.MP4: "mp4",
72
+ CT.MPG: "mpg",
73
+ CT.MS_VIDEO: "avi",
74
+ CT.SWF: "swf",
75
+ CT.WMV: "wmv",
76
+ CT.X_MS_VIDEO: "avi",
77
+ }.get(self._mime_type, "vid")
78
+
79
+ @property
80
+ def filename(self) -> str:
81
+ """Return a filename.ext string appropriate to this video.
82
+
83
+ The base filename from the original path is used if this image was
84
+ loaded from the filesystem. If no filename is available, such as when
85
+ the video object is created from an in-memory stream, the string
86
+ 'movie.{ext}' is used where 'ext' is suitable to the video format,
87
+ such as 'mp4'.
88
+ """
89
+ if self._filename is not None:
90
+ return self._filename
91
+ return "movie.%s" % self.ext
92
+
93
+ @lazyproperty
94
+ def sha1(self):
95
+ """The SHA1 hash digest for the binary "file" of this video.
96
+
97
+ Example: `'1be010ea47803b00e140b852765cdf84f491da47'`
98
+ """
99
+ return hashlib.sha1(self._blob).hexdigest()
100
+
101
+
102
+ SPEAKER_IMAGE_BYTES = base64.b64decode(
103
+ "iVBORw0KGgoAAAANSUhEUgAAAHgAAAA3CAYAAADHao5rAAAACXBIWXMAAAsTAAALEwEAmpw"
104
+ "YAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUh"
105
+ "UIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74"
106
+ "Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz"
107
+ "/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEB"
108
+ "GAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVo"
109
+ "pFAFgwABRm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parRbK5TJmZmZw+/ZtfPLJJ1fPnDnzy506PQO76Nh"
192
+ "stVpNFIvFDGNMSKfTxVQqVX66tHnp0qXvjI2NfZ8Q8s3e3l709/ejq6sL0WgUoVAIruuiVq"
193
+ "thaWkJ09PTWFpaunL69Olfj4yMXNnJ/fJcXT7L5/ODY2Njb928efPLoii+3t5IkGUZnufBN"
194
+ "E2sra1dHR4e/vidd9753cDAQH6nP/Nzebtwdna2//bt269MTk4eKpVKXZ7nSbquW7lcbvrE"
195
+ "iRPjBw8enNwtz/rcXx9ljAlPypJ0Nz4fvx+8y+GCuWAOF8zhgjlcMIcL5nDBHC6YC+ZwwRw"
196
+ "umLMN+O8AX65uqCMleo4AAAAASUVORK5CYII="
197
+ )
pptx/opc/__init__.py ADDED
File without changes