forked from scanny/python-pptx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
132 lines (113 loc) · 3.82 KB
/
api.py
File metadata and controls
132 lines (113 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# encoding: utf-8
"""
Directly exposed API classes, Presentation for now. Provides some syntactic
sugar for interacting with the pptx.presentation.Package graph and also
provides some insulation so not so many classes in the other modules need to
be named as internal (leading underscore).
"""
from __future__ import absolute_import, print_function, unicode_literals
from warnings import warn
from pptx.package import Package
class Presentation(object):
"""
Return a |Presentation| instance loaded from *file_*, where *file_* can
be either a path to a ``.pptx`` file (a string) or a file-like object.
If *file_* is missing or ``None``, load the built-in default presentation
template.
"""
def __init__(self, pkg_file=None):
super(Presentation, self).__init__()
self._package = Package.open(pkg_file)
self._presentation = self._package.presentation
@property
def core_properties(self):
"""
Instance of |CoreProperties| holding the read/write Dublin Core
document properties for this presentation.
"""
return self._package.core_properties
@property
def slide_layouts(self):
"""
Sequence of |SlideLayout| instances belonging to the first
|SlideMaster| of this presentation.
"""
return self._presentation.slide_masters[0].slide_layouts
@property
def slidelayouts(self):
"""
Deprecated. Use ``.slide_layouts`` property instead.
"""
msg = (
'Presentation.slidelayouts property is deprecated. Use .slide_la'
'youts instead.'
)
warn(msg, UserWarning, stacklevel=2)
return self.slide_layouts
@property
def slide_master(self):
"""
First |SlideMaster| object belonging to this presentation. Typically,
presentations have only a single slide master. This property provides
simpler access in that common case.
"""
return self._presentation.slide_masters[0]
@property
def slidemaster(self):
"""
Deprecated. Use ``.slide_master`` property instead.
"""
msg = (
'Presentation.slidemaster property is deprecated. Use .slide_m'
'aster instead.'
)
warn(msg, UserWarning, stacklevel=2)
return self.slide_masters
@property
def slide_masters(self):
"""
List of |SlideMaster| objects belonging to this presentation.
"""
return self._presentation.slide_masters
@property
def slidemasters(self):
"""
Deprecated. Use ``.slide_masters`` property instead.
"""
msg = (
'Presentation.slidemasters property is deprecated. Use .slide_'
'masters instead.'
)
warn(msg, UserWarning, stacklevel=2)
return self.slide_masters
@property
def slide_height(self):
"""
Height of slides in this presentation, in English Metric Units (EMU)
"""
return self._presentation.slide_height
@slide_height.setter
def slide_height(self, height):
self._presentation.slide_height = height
@property
def slide_width(self):
"""
Width of slides in this presentation, in English Metric Units (EMU)
"""
return self._presentation.slide_width
@slide_width.setter
def slide_width(self, width):
self._presentation.slide_width = width
@property
def slides(self):
"""
|SlideCollection| object containing the slides in this
presentation.
"""
return self._presentation.slides
def save(self, file):
"""
Save this presentation to *file*, where *file* can be either a path to
a file (a string) or a file-like object.
"""
return self._package.save(file)