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

Method append_ps_from

src/pptx/oxml/table.py:219–242  ·  view source on GitHub ↗

Append `a:p` elements taken from `spanned_tc`. Any non-empty paragraph elements in `spanned_tc` are removed and appended to the text-frame of this cell. If `spanned_tc` is left with no content after this process, a single empty `a:p` element is added to ensure the cell is co

(self, spanned_tc: CT_TableCell)

Source from the content-addressed store, hash-verified

217 tcPr.anchor = anchor_enum_idx
218
219 def append_ps_from(self, spanned_tc: CT_TableCell):
220 """Append `a:p` elements taken from `spanned_tc`.
221
222 Any non-empty paragraph elements in `spanned_tc` are removed and appended to the
223 text-frame of this cell. If `spanned_tc` is left with no content after this process, a
224 single empty `a:p` element is added to ensure the cell is compliant with the spec.
225 """
226 source_txBody = spanned_tc.get_or_add_txBody()
227 target_txBody = self.get_or_add_txBody()
228
229 # ---if source is empty, there's nothing to do---
230 if source_txBody.is_empty:
231 return
232
233 # ---a single empty paragraph in target is overwritten---
234 if target_txBody.is_empty:
235 target_txBody.clear_content()
236
237 for p in source_txBody.p_lst:
238 target_txBody.append(p)
239
240 # ---neither source nor target can be left without ps---
241 source_txBody.unclear_content()
242 target_txBody.unclear_content()
243
244 @property
245 def col_idx(self) -> int:

Callers 1

Calls 3

clear_contentMethod · 0.80
unclear_contentMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected