MCPcopy Create free account
hub / github.com/scanny/python-pptx / _Fill

Class _Fill

src/pptx/dml/fill.py:164–212  ·  view source on GitHub ↗

Object factory for fill object of class matching fill element, such as _SolidFill for `` ``; also serves as the base class for all fill classes

Source from the content-addressed store, hash-verified

162
163
164class _Fill(object):
165 """
166 Object factory for fill object of class matching fill element, such as
167 _SolidFill for ``<a:solidFill>``; also serves as the base class for all
168 fill classes
169 """
170
171 def __new__(cls, xFill):
172 if xFill is None:
173 fill_cls = _NoneFill
174 elif isinstance(xFill, CT_BlipFillProperties):
175 fill_cls = _BlipFill
176 elif isinstance(xFill, CT_GradientFillProperties):
177 fill_cls = _GradFill
178 elif isinstance(xFill, CT_GroupFillProperties):
179 fill_cls = _GrpFill
180 elif isinstance(xFill, CT_NoFillProperties):
181 fill_cls = _NoFill
182 elif isinstance(xFill, CT_PatternFillProperties):
183 fill_cls = _PattFill
184 elif isinstance(xFill, CT_SolidColorFillProperties):
185 fill_cls = _SolidFill
186 else:
187 fill_cls = _Fill
188 return super(_Fill, cls).__new__(fill_cls)
189
190 @property
191 def back_color(self):
192 """Raise TypeError for types that do not override this property."""
193 tmpl = "fill type %s has no background color, call .patterned() first"
194 raise TypeError(tmpl % self.__class__.__name__)
195
196 @property
197 def fore_color(self):
198 """Raise TypeError for types that do not override this property."""
199 tmpl = "fill type %s has no foreground color, call .solid() or .pattern" "ed() first"
200 raise TypeError(tmpl % self.__class__.__name__)
201
202 @property
203 def pattern(self):
204 """Raise TypeError for fills that do not override this property."""
205 tmpl = "fill type %s has no pattern, call .patterned() first"
206 raise TypeError(tmpl % self.__class__.__name__)
207
208 @property
209 def type(self) -> MSO_FILL_TYPE: # pragma: no cover
210 raise NotImplementedError(
211 f".type property must be implemented on {self.__class__.__name__}"
212 )
213
214
215class _BlipFill(_Fill):

Callers 4

back_raise_fixtureMethod · 0.90
fore_raise_fixtureMethod · 0.90
pattern_raise_fixtureMethod · 0.90
from_fill_parentMethod · 0.85

Calls

no outgoing calls

Tested by 3

back_raise_fixtureMethod · 0.72
fore_raise_fixtureMethod · 0.72
pattern_raise_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…