code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def add_cxnSp(
self,
id_: int,
name: str,
type_member: MSO_CONNECTOR_TYPE,
x: int,
y: int,
cx: int,
cy: int,
flipH: bool,
flipV: bool,
) -> CT_Connector:
"""Return new `p:cxnSp` appended to the group/shapetree with the specified... | Return new `p:cxnSp` appended to the group/shapetree with the specified attribues. | add_cxnSp | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_freeform_sp(self, x: int, y: int, cx: int, cy: int) -> CT_Shape:
"""Append a new freeform `p:sp` with specified position and size."""
shape_id = self._next_shape_id
name = "Freeform %d" % (shape_id - 1,)
sp = CT_Shape.new_freeform_sp(shape_id, name, x, y, cx, cy)
self.ins... | Append a new freeform `p:sp` with specified position and size. | add_freeform_sp | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_grpSp(self) -> CT_GroupShape:
"""Return `p:grpSp` element newly appended to this shape tree.
The element contains no sub-shapes, is positioned at (0, 0), and has
width and height of zero.
"""
shape_id = self._next_shape_id
name = "Group %d" % (shape_id - 1,)
... | Return `p:grpSp` element newly appended to this shape tree.
The element contains no sub-shapes, is positioned at (0, 0), and has
width and height of zero.
| add_grpSp | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_pic(
self, id_: int, name: str, desc: str, rId: str, x: int, y: int, cx: int, cy: int
) -> CT_Picture:
"""Append a `p:pic` shape to the group/shapetree having properties as specified in call."""
pic = CT_Picture.new_pic(id_, name, desc, rId, x, y, cx, cy)
self.insert_element_... | Append a `p:pic` shape to the group/shapetree having properties as specified in call. | add_pic | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_placeholder(
self, id_: int, name: str, ph_type: PP_PLACEHOLDER, orient: str, sz: str, idx: int
) -> CT_Shape:
"""Append a newly-created placeholder `p:sp` shape having the specified properties."""
sp = CT_Shape.new_placeholder_sp(id_, name, ph_type, orient, sz, idx)
self.ins... | Append a newly-created placeholder `p:sp` shape having the specified properties. | add_placeholder | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_table(
self, id_: int, name: str, rows: int, cols: int, x: int, y: int, cx: int, cy: int
) -> CT_GraphicalObjectFrame:
"""Append a `p:graphicFrame` shape containing a table as specified in call."""
graphicFrame = CT_GraphicalObjectFrame.new_table_graphicFrame(
id_, name, ... | Append a `p:graphicFrame` shape containing a table as specified in call. | add_table | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def add_textbox(self, id_: int, name: str, x: int, y: int, cx: int, cy: int) -> CT_Shape:
"""Append a newly-created textbox `p:sp` shape having the specified position and size."""
sp = CT_Shape.new_textbox_sp(id_, name, x, y, cx, cy)
self.insert_element_before(sp, "p:extLst")
return sp | Append a newly-created textbox `p:sp` shape having the specified position and size. | add_textbox | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def iter_ph_elms(self):
"""Generate each placeholder shape child element in document order."""
for e in self.iter_shape_elms():
if e.has_ph_elm:
yield e | Generate each placeholder shape child element in document order. | iter_ph_elms | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def iter_shape_elms(self) -> Iterator[ShapeElement]:
"""Generate each child of this `p:spTree` element that corresponds to a shape.
Items appear in XML document order.
"""
for elm in self.iterchildren():
if elm.tag in self._shape_tags:
yield elm | Generate each child of this `p:spTree` element that corresponds to a shape.
Items appear in XML document order.
| iter_shape_elms | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def max_shape_id(self) -> int:
"""Maximum int value assigned as @id in this slide.
This is generally a shape-id, but ids can be assigned to other
objects so we just check all @id values anywhere in the document
(XML id-values have document scope).
In practice, its minimum value... | Maximum int value assigned as @id in this slide.
This is generally a shape-id, but ids can be assigned to other
objects so we just check all @id values anywhere in the document
(XML id-values have document scope).
In practice, its minimum value is 1 because the spTree element itself
... | max_shape_id | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def new_grpSp(cls, id_: int, name: str) -> CT_GroupShape:
"""Return new "loose" `p:grpSp` element having `id_` and `name`."""
xml = (
"<p:grpSp %s>\n"
" <p:nvGrpSpPr>\n"
' <p:cNvPr id="%%d" name="%%s"/>\n'
" <p:cNvGrpSpPr/>\n"
" <p:nv... | Return new "loose" `p:grpSp` element having `id_` and `name`. | new_grpSp | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def recalculate_extents(self) -> None:
"""Adjust x, y, cx, and cy to incorporate all contained shapes.
This would typically be called when a contained shape is added,
removed, or its position or size updated.
This method is recursive "upwards" since a change in a group shape
ca... | Adjust x, y, cx, and cy to incorporate all contained shapes.
This would typically be called when a contained shape is added,
removed, or its position or size updated.
This method is recursive "upwards" since a change in a group shape
can change the position and size of its containing g... | recalculate_extents | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def _child_extents(self) -> tuple[int, int, int, int]:
"""(x, y, cx, cy) tuple representing net position and size.
The values are formed as a composite of the contained child shapes.
"""
child_shape_elms = list(self.iter_shape_elms())
if not child_shape_elms:
return... | (x, y, cx, cy) tuple representing net position and size.
The values are formed as a composite of the contained child shapes.
| _child_extents | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def _next_shape_id(self) -> int:
"""Return unique shape id suitable for use with a new shape element.
The returned id is the next available positive integer drawing object
id in shape tree, starting from 1 and making use of any gaps in
numbering. In practice, the minimum id is 2 because... | Return unique shape id suitable for use with a new shape element.
The returned id is the next available positive integer drawing object
id in shape tree, starting from 1 and making use of any gaps in
numbering. In practice, the minimum id is 2 because the spTree
element itself is always... | _next_shape_id | python | scanny/python-pptx | src/pptx/oxml/shapes/groupshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/groupshape.py | MIT |
def blip_rId(self) -> str | None:
"""Value of `p:blipFill/a:blip/@r:embed`.
Returns |None| if not present.
"""
blip = self.blipFill.blip
if blip is not None and blip.rEmbed is not None:
return blip.rEmbed
return None | Value of `p:blipFill/a:blip/@r:embed`.
Returns |None| if not present.
| blip_rId | python | scanny/python-pptx | src/pptx/oxml/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/picture.py | MIT |
def new_video_pic(
cls,
shape_id: int,
shape_name: str,
video_rId: str,
media_rId: str,
poster_frame_rId: str,
x: Length,
y: Length,
cx: Length,
cy: Length,
) -> CT_Picture:
"""Return a new `p:pic` populated with the specified v... | Return a new `p:pic` populated with the specified video. | new_video_pic | python | scanny/python-pptx | src/pptx/oxml/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/picture.py | MIT |
def _fill_cropping(self, image_size, view_size):
"""
Return a (left, top, right, bottom) 4-tuple containing the cropping
values required to display an image of *image_size* in *view_size*
when stretched proportionately. Each value is a percentage expressed
as a fraction of 1.0, e... |
Return a (left, top, right, bottom) 4-tuple containing the cropping
values required to display an image of *image_size* in *view_size*
when stretched proportionately. Each value is a percentage expressed
as a fraction of 1.0, e.g. 0.425 represents 42.5%. *image_size* and
*view_s... | _fill_cropping | python | scanny/python-pptx | src/pptx/oxml/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/picture.py | MIT |
def _srcRect_x(self, attr_name):
"""
Value of `p:blipFill/a:srcRect/@{attr_name}` or 0.0 if not present.
"""
srcRect = self.blipFill.srcRect
if srcRect is None:
return 0.0
return getattr(srcRect, attr_name) |
Value of `p:blipFill/a:srcRect/@{attr_name}` or 0.0 if not present.
| _srcRect_x | python | scanny/python-pptx | src/pptx/oxml/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/picture.py | MIT |
def ph(self) -> CT_Placeholder | None:
"""The `p:ph` descendant element if there is one, None otherwise."""
ph_elms = self.xpath("./*[1]/p:nvPr/p:ph")
if len(ph_elms) == 0:
return None
return ph_elms[0] | The `p:ph` descendant element if there is one, None otherwise. | ph | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def ph_idx(self) -> int:
"""Integer value of placeholder idx attribute.
Raises |ValueError| if shape is not a placeholder.
"""
ph = self.ph
if ph is None:
raise ValueError("not a placeholder shape")
return ph.idx | Integer value of placeholder idx attribute.
Raises |ValueError| if shape is not a placeholder.
| ph_idx | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def ph_orient(self) -> str:
"""Placeholder orientation, e.g. 'vert'.
Raises |ValueError| if shape is not a placeholder.
"""
ph = self.ph
if ph is None:
raise ValueError("not a placeholder shape")
return ph.orient | Placeholder orientation, e.g. 'vert'.
Raises |ValueError| if shape is not a placeholder.
| ph_orient | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def ph_sz(self) -> str:
"""Placeholder size, e.g. ST_PlaceholderSize.HALF.
Raises `ValueError` if shape is not a placeholder.
"""
ph = self.ph
if ph is None:
raise ValueError("not a placeholder shape")
return ph.sz | Placeholder size, e.g. ST_PlaceholderSize.HALF.
Raises `ValueError` if shape is not a placeholder.
| ph_sz | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def ph_type(self):
"""Placeholder type, e.g. ST_PlaceholderType.TITLE ('title').
Raises `ValueError` if shape is not a placeholder.
"""
ph = self.ph
if ph is None:
raise ValueError("not a placeholder shape")
return ph.type | Placeholder type, e.g. ST_PlaceholderType.TITLE ('title').
Raises `ValueError` if shape is not a placeholder.
| ph_type | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def rot(self) -> float:
"""Float representing degrees this shape is rotated clockwise."""
xfrm = self.xfrm
if xfrm is None or xfrm.rot is None:
return 0.0
return xfrm.rot | Float representing degrees this shape is rotated clockwise. | rot | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def prstDash_val(self):
"""Return value of `val` attribute of `a:prstDash` child.
Return |None| if not present.
"""
prstDash = self.prstDash
if prstDash is None:
return None
return prstDash.val | Return value of `val` attribute of `a:prstDash` child.
Return |None| if not present.
| prstDash_val | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def cx(self):
"""
Shape width as an instance of Emu, or None if not present.
"""
cx_str_lst = self.xpath("./a:xfrm/a:ext/@cx")
if not cx_str_lst:
return None
return Emu(cx_str_lst[0]) |
Shape width as an instance of Emu, or None if not present.
| cx | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def cy(self):
"""
Shape height as an instance of Emu, or None if not present.
"""
cy_str_lst = self.xpath("./a:xfrm/a:ext/@cy")
if not cy_str_lst:
return None
return Emu(cy_str_lst[0]) |
Shape height as an instance of Emu, or None if not present.
| cy | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def x(self) -> Length | None:
"""Distance between the left edge of the slide and left edge of the shape.
0 if not present.
"""
x_str_lst = self.xpath("./a:xfrm/a:off/@x")
if not x_str_lst:
return None
return Emu(x_str_lst[0]) | Distance between the left edge of the slide and left edge of the shape.
0 if not present.
| x | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def y(self):
"""
The offset of the top of the shape from the top of the slide, as an
instance of Emu. None if not present.
"""
y_str_lst = self.xpath("./a:xfrm/a:off/@y")
if not y_str_lst:
return None
return Emu(y_str_lst[0]) |
The offset of the top of the shape from the top of the slide, as an
instance of Emu. None if not present.
| y | python | scanny/python-pptx | src/pptx/oxml/shapes/shared.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/shared.py | MIT |
def new(cls, chart_type: XL_CHART_TYPE, chart_data: ChartData, package: Package):
"""Return new |ChartPart| instance added to `package`.
Returned chart-part contains a chart of `chart_type` depicting `chart_data`.
"""
chart_part = cls.load(
package.next_partname(cls.partname... | Return new |ChartPart| instance added to `package`.
Returned chart-part contains a chart of `chart_type` depicting `chart_data`.
| new | python | scanny/python-pptx | src/pptx/parts/chart.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/chart.py | MIT |
def update_from_xlsx_blob(self, xlsx_blob):
"""
Replace the Excel spreadsheet in the related |EmbeddedXlsxPart| with
the Excel binary in *xlsx_blob*, adding a new |EmbeddedXlsxPart| if
there isn't one.
"""
xlsx_part = self.xlsx_part
if xlsx_part is None:
... |
Replace the Excel spreadsheet in the related |EmbeddedXlsxPart| with
the Excel binary in *xlsx_blob*, adding a new |EmbeddedXlsxPart| if
there isn't one.
| update_from_xlsx_blob | python | scanny/python-pptx | src/pptx/parts/chart.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/chart.py | MIT |
def xlsx_part(self):
"""Optional |EmbeddedXlsxPart| object containing data for this chart.
This related part has its rId at `c:chartSpace/c:externalData/@rId`. This value
is |None| if there is no `<c:externalData>` element.
"""
xlsx_part_rId = self._chartSpace.xlsx_part_rId
... | Optional |EmbeddedXlsxPart| object containing data for this chart.
This related part has its rId at `c:chartSpace/c:externalData/@rId`. This value
is |None| if there is no `<c:externalData>` element.
| xlsx_part | python | scanny/python-pptx | src/pptx/parts/chart.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/chart.py | MIT |
def xlsx_part(self, xlsx_part):
"""
Set the related |EmbeddedXlsxPart| to *xlsx_part*. Assume one does
not already exist.
"""
rId = self._chart_part.relate_to(xlsx_part, RT.PACKAGE)
externalData = self._chartSpace.get_or_add_externalData()
externalData.rId = rId |
Set the related |EmbeddedXlsxPart| to *xlsx_part*. Assume one does
not already exist.
| xlsx_part | python | scanny/python-pptx | src/pptx/parts/chart.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/chart.py | MIT |
def default(cls, package: Package):
"""Return default new |CorePropertiesPart| instance suitable as starting point.
This provides a base for adding core-properties to a package that doesn't yet
have any.
"""
core_props = cls._new(package)
core_props.title = "PowerPoint P... | Return default new |CorePropertiesPart| instance suitable as starting point.
This provides a base for adding core-properties to a package that doesn't yet
have any.
| default | python | scanny/python-pptx | src/pptx/parts/coreprops.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/coreprops.py | MIT |
def factory(cls, prog_id: PROG_ID | str, object_blob: bytes, package: Package):
"""Return a new |EmbeddedPackagePart| subclass instance added to *package*.
The subclass is determined by `prog_id` which corresponds to the "application"
used to open the "file-type" of `object_blob`. The returned ... | Return a new |EmbeddedPackagePart| subclass instance added to *package*.
The subclass is determined by `prog_id` which corresponds to the "application"
used to open the "file-type" of `object_blob`. The returned part contains the
bytes of `object_blob` and has the content-type also determined b... | factory | python | scanny/python-pptx | src/pptx/parts/embeddedpackage.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/embeddedpackage.py | MIT |
def new(cls, blob: bytes, package: Package):
"""Return new |EmbeddedPackagePart| subclass object.
The returned part object contains `blob` and is added to `package`.
"""
return cls(
package.next_partname(cls.partname_template),
cls.content_type,
packa... | Return new |EmbeddedPackagePart| subclass object.
The returned part object contains `blob` and is added to `package`.
| new | python | scanny/python-pptx | src/pptx/parts/embeddedpackage.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/embeddedpackage.py | MIT |
def new(cls, package: Package, image: Image) -> ImagePart:
"""Return new |ImagePart| instance containing `image`.
`image` is an |Image| object.
"""
return cls(
package.next_image_partname(image.ext),
image.content_type,
package,
image.blob... | Return new |ImagePart| instance containing `image`.
`image` is an |Image| object.
| new | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def desc(self) -> str:
"""The filename associated with this image.
Either the filename of the original image or a generic name of the form `image.ext` where
`ext` is appropriate to the image file format, e.g. `'jpg'`. An image created using a path
will have that filename; one created wi... | The filename associated with this image.
Either the filename of the original image or a generic name of the form `image.ext` where
`ext` is appropriate to the image file format, e.g. `'jpg'`. An image created using a path
will have that filename; one created with a file-like object will have a ... | desc | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def scale(self, scaled_cx: int | None, scaled_cy: int | None) -> tuple[int, int]:
"""Return scaled image dimensions in EMU based on the combination of parameters supplied.
If `scaled_cx` and `scaled_cy` are both |None|, the native image size is returned. If
neither `scaled_cx` nor `scaled_cy` i... | Return scaled image dimensions in EMU based on the combination of parameters supplied.
If `scaled_cx` and `scaled_cy` are both |None|, the native image size is returned. If
neither `scaled_cx` nor `scaled_cy` is |None|, their values are returned unchanged. If a
value is provided for either `sca... | scale | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def _native_size(self) -> tuple[Length, Length]:
"""A (width, height) 2-tuple representing the native dimensions of the image in EMU.
Calculated based on the image DPI value, if present, assuming 72 dpi as a default.
"""
EMU_PER_INCH = 914400
horz_dpi, vert_dpi = self._dpi
... | A (width, height) 2-tuple representing the native dimensions of the image in EMU.
Calculated based on the image DPI value, if present, assuming 72 dpi as a default.
| _native_size | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def from_file(cls, image_file: str | IO[bytes]) -> Image:
"""Return a new |Image| object loaded from `image_file`.
`image_file` can be either a path (str) or a file-like object.
"""
if isinstance(image_file, str):
# treat image_file as a path
with open(image_file... | Return a new |Image| object loaded from `image_file`.
`image_file` can be either a path (str) or a file-like object.
| from_file | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def dpi(self) -> tuple[int, int]:
"""A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch resolution of this image.
A default value of (72, 72) is used if the dpi is not specified in the image file.
"""
def int_dpi(dpi: Any):
"""Return an integer dots-per-inch value ... | A (horz_dpi, vert_dpi) 2-tuple specifying the dots-per-inch resolution of this image.
A default value of (72, 72) is used if the dpi is not specified in the image file.
| dpi | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def int_dpi(dpi: Any):
"""Return an integer dots-per-inch value corresponding to `dpi`.
If `dpi` is |None|, a non-numeric type, less than 1 or greater than 2048, 72 is
returned.
"""
try:
int_dpi = int(round(float(dpi)))
if int_... | Return an integer dots-per-inch value corresponding to `dpi`.
If `dpi` is |None|, a non-numeric type, less than 1 or greater than 2048, 72 is
returned.
| int_dpi | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def normalize_pil_dpi(pil_dpi: tuple[int, int] | None):
"""Return a (horz_dpi, vert_dpi) 2-tuple corresponding to `pil_dpi`.
The value for the 'dpi' key in the `info` dict of a PIL image. If the 'dpi' key is not
present or contains an invalid value, `(72, 72)` is returned.
... | Return a (horz_dpi, vert_dpi) 2-tuple corresponding to `pil_dpi`.
The value for the 'dpi' key in the `info` dict of a PIL image. If the 'dpi' key is not
present or contains an invalid value, `(72, 72)` is returned.
| normalize_pil_dpi | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def ext(self) -> str:
"""Canonical file extension for this image e.g. `'png'`.
The returned extension is all lowercase and is the canonical extension for the content type
of this image, regardless of what extension may have been used in its filename, if any.
"""
ext_map = {
... | Canonical file extension for this image e.g. `'png'`.
The returned extension is all lowercase and is the canonical extension for the content type
of this image, regardless of what extension may have been used in its filename, if any.
| ext | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def _pil_props(self) -> tuple[str | None, tuple[int, int], tuple[int, int] | None]:
"""tuple of image properties extracted from this image using Pillow."""
stream = io.BytesIO(self._blob)
pil_image = PIL_Image.open(stream) # pyright: ignore[reportUnknownMemberType]
format = pil_image.fo... | tuple of image properties extracted from this image using Pillow. | _pil_props | python | scanny/python-pptx | src/pptx/parts/image.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/image.py | MIT |
def new(cls, package, media):
"""Return new |MediaPart| instance containing `media`.
`media` must be a |Media| object.
"""
return cls(
package.next_media_partname(media.ext),
media.content_type,
package,
media.blob,
) | Return new |MediaPart| instance containing `media`.
`media` must be a |Media| object.
| new | python | scanny/python-pptx | src/pptx/parts/media.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/media.py | MIT |
def add_slide(self, slide_layout: SlideLayout):
"""Return (rId, slide) pair of a newly created blank slide.
New slide inherits appearance from `slide_layout`.
"""
partname = self._next_slide_partname
slide_layout_part = slide_layout.part
slide_part = SlidePart.new(partna... | Return (rId, slide) pair of a newly created blank slide.
New slide inherits appearance from `slide_layout`.
| add_slide | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def get_slide(self, slide_id: int) -> Slide | None:
"""Return optional related |Slide| object identified by `slide_id`.
Returns |None| if no slide with `slide_id` is related to this presentation.
"""
for sldId in self._element.sldIdLst:
if sldId.id == slide_id:
... | Return optional related |Slide| object identified by `slide_id`.
Returns |None| if no slide with `slide_id` is related to this presentation.
| get_slide | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def notes_master_part(self) -> NotesMasterPart:
"""Return the |NotesMasterPart| object for this presentation.
If the presentation does not have a notes master, one is created from a default template.
The same single instance is returned on each call.
"""
try:
return ... | Return the |NotesMasterPart| object for this presentation.
If the presentation does not have a notes master, one is created from a default template.
The same single instance is returned on each call.
| notes_master_part | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def rename_slide_parts(self, rIds: Iterable[str]):
"""Assign incrementing partnames to the slide parts identified by `rIds`.
Partnames are like `/ppt/slides/slide9.xml` and are assigned in the order their id appears
in the `rIds` sequence. The name portion is always `slide`. The number part for... | Assign incrementing partnames to the slide parts identified by `rIds`.
Partnames are like `/ppt/slides/slide9.xml` and are assigned in the order their id appears
in the `rIds` sequence. The name portion is always `slide`. The number part forms a
continuous sequence starting at 1 (e.g. 1, 2, ...... | rename_slide_parts | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def slide_id(self, slide_part):
"""Return the slide-id associated with `slide_part`."""
for sldId in self._element.sldIdLst:
if self.related_part(sldId.rId) is slide_part:
return sldId.id
raise ValueError("matching slide_part not found") | Return the slide-id associated with `slide_part`. | slide_id | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def _next_slide_partname(self):
"""Return |PackURI| instance containing next available slide partname."""
sldIdLst = self._element.get_or_add_sldIdLst()
partname_str = "/ppt/slides/slide%d.xml" % (len(sldIdLst) + 1)
return PackURI(partname_str) | Return |PackURI| instance containing next available slide partname. | _next_slide_partname | python | scanny/python-pptx | src/pptx/parts/presentation.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/presentation.py | MIT |
def get_or_add_image_part(self, image_file: str | IO[bytes]):
"""Return `(image_part, rId)` pair corresponding to `image_file`.
The returned |ImagePart| object contains the image in `image_file` and is
related to this slide with the key `rId`. If either the image part or
relationship al... | Return `(image_part, rId)` pair corresponding to `image_file`.
The returned |ImagePart| object contains the image in `image_file` and is
related to this slide with the key `rId`. If either the image part or
relationship already exists, they are reused, otherwise they are newly created.
| get_or_add_image_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def create_default(cls, package):
"""
Create and return a default notes master part, including creating the
new theme it requires.
"""
notes_master_part = cls._new(package)
theme_part = cls._new_theme_part(package)
notes_master_part.relate_to(theme_part, RT.THEME)... |
Create and return a default notes master part, including creating the
new theme it requires.
| create_default | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def _new(cls, package):
"""
Create and return a standalone, default notes master part based on
the built-in template (without any related parts, such as theme).
"""
return NotesMasterPart(
PackURI("/ppt/notesMasters/notesMaster1.xml"),
CT.PML_NOTES_MASTER,... |
Create and return a standalone, default notes master part based on
the built-in template (without any related parts, such as theme).
| _new | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def _new_theme_part(cls, package):
"""Return new default theme-part suitable for use with a notes master."""
return XmlPart(
package.next_partname("/ppt/theme/theme%d.xml"),
CT.OFC_THEME,
package,
CT_OfficeStyleSheet.new_default(),
) | Return new default theme-part suitable for use with a notes master. | _new_theme_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def new(cls, package, slide_part):
"""Return new |NotesSlidePart| for the slide in `slide_part`.
The new notes-slide part is based on the (singleton) notes master and related to
both the notes-master part and `slide_part`. If no notes-master is present,
one is created based on the defau... | Return new |NotesSlidePart| for the slide in `slide_part`.
The new notes-slide part is based on the (singleton) notes master and related to
both the notes-master part and `slide_part`. If no notes-master is present,
one is created based on the default template.
| new | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def _add_notes_slide_part(cls, package, slide_part, notes_master_part):
"""Create and return a new notes-slide part.
The return part is fully related, but has no shape content (i.e. placeholders
not cloned).
"""
notes_slide_part = NotesSlidePart(
package.next_partnam... | Create and return a new notes-slide part.
The return part is fully related, but has no shape content (i.e. placeholders
not cloned).
| _add_notes_slide_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def new(cls, partname, package, slide_layout_part):
"""Return newly-created blank slide part.
The new slide-part has `partname` and a relationship to `slide_layout_part`.
"""
slide_part = cls(partname, CT.PML_SLIDE, package, CT_Slide.new())
slide_part.relate_to(slide_layout_part... | Return newly-created blank slide part.
The new slide-part has `partname` and a relationship to `slide_layout_part`.
| new | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def add_embedded_ole_object_part(
self, prog_id: PROG_ID | str, ole_object_file: str | IO[bytes]
):
"""Return rId of newly-added OLE-object part formed from `ole_object_file`."""
relationship_type = RT.PACKAGE if isinstance(prog_id, PROG_ID) else RT.OLE_OBJECT
return self.relate_to(
... | Return rId of newly-added OLE-object part formed from `ole_object_file`. | add_embedded_ole_object_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def get_or_add_video_media_part(self, video: Video) -> tuple[str, str]:
"""Return rIds for media and video relationships to media part.
A new |MediaPart| object is created if it does not already exist
(such as would occur if the same video appeared more than once in
a presentation). Tw... | Return rIds for media and video relationships to media part.
A new |MediaPart| object is created if it does not already exist
(such as would occur if the same video appeared more than once in
a presentation). Two relationships to the media part are created,
one each with MEDIA and VIDE... | get_or_add_video_media_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def has_notes_slide(self):
"""
Return True if this slide has a notes slide, False otherwise. A notes
slide is created by the :attr:`notes_slide` property when one doesn't
exist; use this property to test for a notes slide without the
possible side-effect of creating one.
... |
Return True if this slide has a notes slide, False otherwise. A notes
slide is created by the :attr:`notes_slide` property when one doesn't
exist; use this property to test for a notes slide without the
possible side-effect of creating one.
| has_notes_slide | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def notes_slide(self) -> NotesSlide:
"""The |NotesSlide| instance associated with this slide.
If the slide does not have a notes slide, a new one is created. The same single instance
is returned on each call.
"""
try:
notes_slide_part = self.part_related_by(RT.NOTES_... | The |NotesSlide| instance associated with this slide.
If the slide does not have a notes slide, a new one is created. The same single instance
is returned on each call.
| notes_slide | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def _add_notes_slide_part(self):
"""
Return a newly created |NotesSlidePart| object related to this slide
part. Caller is responsible for ensuring this slide doesn't already
have a notes slide part.
"""
notes_slide_part = NotesSlidePart.new(self.package, self)
sel... |
Return a newly created |NotesSlidePart| object related to this slide
part. Caller is responsible for ensuring this slide doesn't already
have a notes slide part.
| _add_notes_slide_part | python | scanny/python-pptx | src/pptx/parts/slide.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/parts/slide.py | MIT |
def _initialized_adjustments(self, prstGeom: CT_PresetGeometry2D | None) -> list[Adjustment]:
"""Return an initialized list of adjustment values based on the contents of `prstGeom`."""
if prstGeom is None:
return []
davs = AutoShapeType.default_adjustment_values(prstGeom.prst)
... | Return an initialized list of adjustment values based on the contents of `prstGeom`. | _initialized_adjustments | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def _update_adjustments_with_actuals(
adjustments: Iterable[Adjustment], guides: Iterable[CT_GeomGuide]
):
"""Update |Adjustment| instances in `adjustments` with actual values held in `guides`.
`guides` is a list of `a:gd` elements. Guides with a name that does not match an adjustment
... | Update |Adjustment| instances in `adjustments` with actual values held in `guides`.
`guides` is a list of `a:gd` elements. Guides with a name that does not match an adjustment
object are skipped.
| _update_adjustments_with_actuals | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def __new__(cls, autoshape_type_id: MSO_AUTO_SHAPE_TYPE) -> AutoShapeType:
"""Only create new instance on first call for content_type.
After that, use cached instance.
"""
# -- if there's not a matching instance in the cache, create one --
if autoshape_type_id not in cls._instan... | Only create new instance on first call for content_type.
After that, use cached instance.
| __new__ | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def __init__(self, autoshape_type_id: MSO_AUTO_SHAPE_TYPE):
"""Initialize attributes from constant values in `pptx.spec`."""
# -- skip loading if this instance is from the cache --
if hasattr(self, "_loaded"):
return
# -- raise on bad autoshape_type_id --
if autoshape... | Initialize attributes from constant values in `pptx.spec`. | __init__ | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def auto_shape_type(self):
"""Enumeration value identifying the type of this auto shape.
Like `MSO_SHAPE.ROUNDED_RECTANGLE`. Raises |ValueError| if this shape is not an auto shape.
"""
if not self._sp.is_autoshape:
raise ValueError("shape is not an auto shape")
retur... | Enumeration value identifying the type of this auto shape.
Like `MSO_SHAPE.ROUNDED_RECTANGLE`. Raises |ValueError| if this shape is not an auto shape.
| auto_shape_type | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def shape_type(self) -> MSO_SHAPE_TYPE:
"""Unique integer identifying the type of this shape, like `MSO_SHAPE_TYPE.TEXT_BOX`."""
if self.is_placeholder:
return MSO_SHAPE_TYPE.PLACEHOLDER
if self._sp.has_custom_geometry:
return MSO_SHAPE_TYPE.FREEFORM
if self._sp.i... | Unique integer identifying the type of this shape, like `MSO_SHAPE_TYPE.TEXT_BOX`. | shape_type | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def text_frame(self):
"""|TextFrame| instance for this shape.
Contains the text of the shape and provides access to text formatting properties.
"""
txBody = self._sp.get_or_add_txBody()
return TextFrame(txBody, self) | |TextFrame| instance for this shape.
Contains the text of the shape and provides access to text formatting properties.
| text_frame | python | scanny/python-pptx | src/pptx/shapes/autoshape.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/autoshape.py | MIT |
def __eq__(self, other: object) -> bool:
"""|True| if this shape object proxies the same element as *other*.
Equality for proxy objects is defined as referring to the same XML element, whether or not
they are the same proxy object instance.
"""
if not isinstance(other, BaseShape... | |True| if this shape object proxies the same element as *other*.
Equality for proxy objects is defined as referring to the same XML element, whether or not
they are the same proxy object instance.
| __eq__ | python | scanny/python-pptx | src/pptx/shapes/base.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/base.py | MIT |
def click_action(self) -> ActionSetting:
"""|ActionSetting| instance providing access to click behaviors.
Click behaviors are hyperlink-like behaviors including jumping to a hyperlink (web page)
or to another slide in the presentation. The click action is that defined on the overall
sha... | |ActionSetting| instance providing access to click behaviors.
Click behaviors are hyperlink-like behaviors including jumping to a hyperlink (web page)
or to another slide in the presentation. The click action is that defined on the overall
shape, not a run of text within the shape. An |ActionSe... | click_action | python | scanny/python-pptx | src/pptx/shapes/base.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/base.py | MIT |
def has_chart(self) -> bool:
"""|True| if this shape is a graphic frame containing a chart object.
|False| otherwise. When |True|, the chart object can be accessed using the ``.chart``
property.
"""
# This implementation is unconditionally False, the True version is
# on... | |True| if this shape is a graphic frame containing a chart object.
|False| otherwise. When |True|, the chart object can be accessed using the ``.chart``
property.
| has_chart | python | scanny/python-pptx | src/pptx/shapes/base.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/base.py | MIT |
def has_table(self) -> bool:
"""|True| if this shape is a graphic frame containing a table object.
|False| otherwise. When |True|, the table object can be accessed using the ``.table``
property.
"""
# This implementation is unconditionally False, the True version is
# on... | |True| if this shape is a graphic frame containing a table object.
|False| otherwise. When |True|, the table object can be accessed using the ``.table``
property.
| has_table | python | scanny/python-pptx | src/pptx/shapes/base.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/base.py | MIT |
def placeholder_format(self) -> _PlaceholderFormat:
"""Provides access to placeholder-specific properties such as placeholder type.
Raises |ValueError| on access if the shape is not a placeholder.
"""
ph = self._element.ph
if ph is None:
raise ValueError("shape is no... | Provides access to placeholder-specific properties such as placeholder type.
Raises |ValueError| on access if the shape is not a placeholder.
| placeholder_format | python | scanny/python-pptx | src/pptx/shapes/base.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/base.py | MIT |
def begin_x(self):
"""
Return the X-position of the begin point of this connector, in
English Metric Units (as a |Length| object).
"""
cxnSp = self._element
x, cx, flipH = cxnSp.x, cxnSp.cx, cxnSp.flipH
begin_x = x + cx if flipH else x
return Emu(begin_x) |
Return the X-position of the begin point of this connector, in
English Metric Units (as a |Length| object).
| begin_x | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def begin_y(self):
"""
Return the Y-position of the begin point of this connector, in
English Metric Units (as a |Length| object).
"""
cxnSp = self._element
y, cy, flipV = cxnSp.y, cxnSp.cy, cxnSp.flipV
begin_y = y + cy if flipV else y
return Emu(begin_y) |
Return the Y-position of the begin point of this connector, in
English Metric Units (as a |Length| object).
| begin_y | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def end_x(self):
"""
Return the X-position of the end point of this connector, in English
Metric Units (as a |Length| object).
"""
cxnSp = self._element
x, cx, flipH = cxnSp.x, cxnSp.cx, cxnSp.flipH
end_x = x if flipH else x + cx
return Emu(end_x) |
Return the X-position of the end point of this connector, in English
Metric Units (as a |Length| object).
| end_x | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def end_y(self):
"""
Return the Y-position of the end point of this connector, in English
Metric Units (as a |Length| object).
"""
cxnSp = self._element
y, cy, flipV = cxnSp.y, cxnSp.cy, cxnSp.flipV
end_y = y if flipV else y + cy
return Emu(end_y) |
Return the Y-position of the end point of this connector, in English
Metric Units (as a |Length| object).
| end_y | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def _connect_begin_to(self, shape, cxn_pt_idx):
"""
Add or update a stCxn element for this connector that connects its
begin point to the connection point of *shape* specified by
*cxn_pt_idx*.
"""
cNvCxnSpPr = self._element.nvCxnSpPr.cNvCxnSpPr
stCxn = cNvCxnSpPr.... |
Add or update a stCxn element for this connector that connects its
begin point to the connection point of *shape* specified by
*cxn_pt_idx*.
| _connect_begin_to | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def _connect_end_to(self, shape, cxn_pt_idx):
"""
Add or update an endCxn element for this connector that connects its
end point to the connection point of *shape* specified by
*cxn_pt_idx*.
"""
cNvCxnSpPr = self._element.nvCxnSpPr.cNvCxnSpPr
endCxn = cNvCxnSpPr.g... |
Add or update an endCxn element for this connector that connects its
end point to the connection point of *shape* specified by
*cxn_pt_idx*.
| _connect_end_to | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def _move_begin_to_cxn(self, shape, cxn_pt_idx):
"""
Move the begin point of this connector to coordinates of the
connection point of *shape* specified by *cxn_pt_idx*.
"""
x, y, cx, cy = shape.left, shape.top, shape.width, shape.height
self.begin_x, self.begin_y = {
... |
Move the begin point of this connector to coordinates of the
connection point of *shape* specified by *cxn_pt_idx*.
| _move_begin_to_cxn | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def _move_end_to_cxn(self, shape, cxn_pt_idx):
"""
Move the end point of this connector to the coordinates of the
connection point of *shape* specified by *cxn_pt_idx*.
"""
x, y, cx, cy = shape.left, shape.top, shape.width, shape.height
self.end_x, self.end_y = {
... |
Move the end point of this connector to the coordinates of the
connection point of *shape* specified by *cxn_pt_idx*.
| _move_end_to_cxn | python | scanny/python-pptx | src/pptx/shapes/connector.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/connector.py | MIT |
def new(
cls,
shapes: _BaseGroupShapes,
start_x: float,
start_y: float,
x_scale: float,
y_scale: float,
):
"""Return a new |FreeformBuilder| object.
The initial pen location is specified (in local coordinates) by
(`start_x`, `start_y`).
... | Return a new |FreeformBuilder| object.
The initial pen location is specified (in local coordinates) by
(`start_x`, `start_y`).
| new | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def add_line_segments(self, vertices: Iterable[tuple[float, float]], close: bool = True):
"""Add a straight line segment to each point in `vertices`.
`vertices` must be an iterable of (x, y) pairs (2-tuples). Each x and y value is rounded
to the nearest integer before use. The optional `close` ... | Add a straight line segment to each point in `vertices`.
`vertices` must be an iterable of (x, y) pairs (2-tuples). Each x and y value is rounded
to the nearest integer before use. The optional `close` parameter determines whether the
resulting contour is `closed` or left `open`.
Retur... | add_line_segments | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def convert_to_shape(self, origin_x: Length = Emu(0), origin_y: Length = Emu(0)):
"""Return new freeform shape positioned relative to specified offset.
`origin_x` and `origin_y` locate the origin of the local coordinate system in slide
coordinates (EMU), perhaps most conveniently by use of a |L... | Return new freeform shape positioned relative to specified offset.
`origin_x` and `origin_y` locate the origin of the local coordinate system in slide
coordinates (EMU), perhaps most conveniently by use of a |Length| object.
Note that this method may be called more than once to add multiple sh... | convert_to_shape | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def shape_offset_x(self) -> Length:
"""Return x distance of shape origin from local coordinate origin.
The returned integer represents the leftmost extent of the freeform shape, in local
coordinates. Note that the bounding box of the shape need not start at the local origin.
"""
... | Return x distance of shape origin from local coordinate origin.
The returned integer represents the leftmost extent of the freeform shape, in local
coordinates. Note that the bounding box of the shape need not start at the local origin.
| shape_offset_x | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def shape_offset_y(self) -> Length:
"""Return y distance of shape origin from local coordinate origin.
The returned integer represents the topmost extent of the freeform shape, in local
coordinates. Note that the bounding box of the shape need not start at the local origin.
"""
... | Return y distance of shape origin from local coordinate origin.
The returned integer represents the topmost extent of the freeform shape, in local
coordinates. Note that the bounding box of the shape need not start at the local origin.
| shape_offset_y | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def _add_freeform_sp(self, origin_x: Length, origin_y: Length):
"""Add a freeform `p:sp` element having no drawing elements.
`origin_x` and `origin_y` are specified in slide coordinates, and represent the location
of the local coordinates origin on the slide.
"""
spTree = self._... | Add a freeform `p:sp` element having no drawing elements.
`origin_x` and `origin_y` are specified in slide coordinates, and represent the location
of the local coordinates origin on the slide.
| _add_freeform_sp | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def _dx(self) -> Length:
"""Return width of this shape's path in local units."""
min_x = max_x = self._start_x
for drawing_operation in self:
if isinstance(drawing_operation, _Close):
continue
min_x = min(min_x, drawing_operation.x)
max_x = max... | Return width of this shape's path in local units. | _dx | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def _dy(self) -> Length:
"""Return integer height of this shape's path in local units."""
min_y = max_y = self._start_y
for drawing_operation in self:
if isinstance(drawing_operation, _Close):
continue
min_y = min(min_y, drawing_operation.y)
ma... | Return integer height of this shape's path in local units. | _dy | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def _start_path(self, sp: CT_Shape) -> CT_Path2D:
"""Return a newly created `a:path` element added to `sp`.
The returned `a:path` element has an `a:moveTo` element representing the shape starting
point as its only child.
"""
path = sp.add_path(w=self._dx, h=self._dy)
pat... | Return a newly created `a:path` element added to `sp`.
The returned `a:path` element has an `a:moveTo` element representing the shape starting
point as its only child.
| _start_path | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def apply_operation_to(self, path: CT_Path2D) -> CT_Path2DLineTo:
"""Add `a:lnTo` element to `path` for this line segment.
Returns the `a:lnTo` element newly added to the path.
"""
return path.add_lnTo(
Emu(self._x - self._freeform_builder.shape_offset_x),
Emu(se... | Add `a:lnTo` element to `path` for this line segment.
Returns the `a:lnTo` element newly added to the path.
| apply_operation_to | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def apply_operation_to(self, path: CT_Path2D) -> CT_Path2DMoveTo:
"""Add `a:moveTo` element to `path` for this line segment."""
return path.add_moveTo(
Emu(self._x - self._freeform_builder.shape_offset_x),
Emu(self._y - self._freeform_builder.shape_offset_y),
) | Add `a:moveTo` element to `path` for this line segment. | apply_operation_to | python | scanny/python-pptx | src/pptx/shapes/freeform.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/freeform.py | MIT |
def chart(self) -> Chart:
"""The |Chart| object containing the chart in this graphic frame.
Raises |ValueError| if this graphic frame does not contain a chart.
"""
if not self.has_chart:
raise ValueError("shape does not contain a chart")
return self.chart_part.chart | The |Chart| object containing the chart in this graphic frame.
Raises |ValueError| if this graphic frame does not contain a chart.
| chart | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
def chart_part(self) -> ChartPart:
"""The |ChartPart| object containing the chart in this graphic frame."""
chart_rId = self._graphicFrame.chart_rId
if chart_rId is None:
raise ValueError("this graphic frame does not contain a chart")
return cast("ChartPart", self.part.relate... | The |ChartPart| object containing the chart in this graphic frame. | chart_part | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
def ole_format(self) -> _OleFormat:
"""_OleFormat object for this graphic-frame shape.
Raises `ValueError` on a GraphicFrame instance that does not contain an OLE object.
An shape that contains an OLE object will have `.shape_type` of either
`EMBEDDED_OLE_OBJECT` or `LINKED_OLE_OBJECT`... | _OleFormat object for this graphic-frame shape.
Raises `ValueError` on a GraphicFrame instance that does not contain an OLE object.
An shape that contains an OLE object will have `.shape_type` of either
`EMBEDDED_OLE_OBJECT` or `LINKED_OLE_OBJECT`.
| ole_format | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
def shape_type(self) -> MSO_SHAPE_TYPE:
"""Optional member of `MSO_SHAPE_TYPE` identifying the type of this shape.
Possible values are `MSO_SHAPE_TYPE.CHART`, `MSO_SHAPE_TYPE.TABLE`,
`MSO_SHAPE_TYPE.EMBEDDED_OLE_OBJECT`, `MSO_SHAPE_TYPE.LINKED_OLE_OBJECT`.
This value is `None` when non... | Optional member of `MSO_SHAPE_TYPE` identifying the type of this shape.
Possible values are `MSO_SHAPE_TYPE.CHART`, `MSO_SHAPE_TYPE.TABLE`,
`MSO_SHAPE_TYPE.EMBEDDED_OLE_OBJECT`, `MSO_SHAPE_TYPE.LINKED_OLE_OBJECT`.
This value is `None` when none of these four types apply, for example when the s... | shape_type | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.