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 table(self) -> Table:
"""The |Table| object contained in this graphic frame.
Raises |ValueError| if this graphic frame does not contain a table.
"""
if not self.has_table:
raise ValueError("shape does not contain a table")
tbl = self._graphicFrame.graphic.graphic... | The |Table| object contained in this graphic frame.
Raises |ValueError| if this graphic frame does not contain a table.
| table | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
def blob(self) -> bytes | None:
"""Optional bytes of OLE object, suitable for loading or saving as a file.
This value is `None` if the embedded object does not represent a "file".
"""
blob_rId = self._graphicData.blob_rId
if blob_rId is None:
return None
retu... | Optional bytes of OLE object, suitable for loading or saving as a file.
This value is `None` if the embedded object does not represent a "file".
| blob | python | scanny/python-pptx | src/pptx/shapes/graphfrm.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/graphfrm.py | MIT |
def shapes(self) -> GroupShapes:
"""|GroupShapes| object for this group.
The |GroupShapes| object provides access to the group's member shapes and provides methods
for adding new ones.
"""
from pptx.shapes.shapetree import GroupShapes
return GroupShapes(self._element, s... | |GroupShapes| object for this group.
The |GroupShapes| object provides access to the group's member shapes and provides methods
for adding new ones.
| shapes | python | scanny/python-pptx | src/pptx/shapes/group.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/group.py | MIT |
def poster_frame(self):
"""Return |Image| object containing poster frame for this movie.
Returns |None| if this movie has no poster frame (uncommon).
"""
slide_part, rId = self.part, self._pic.blip_rId
if rId is None:
return None
return slide_part.get_image(r... | Return |Image| object containing poster frame for this movie.
Returns |None| if this movie has no poster frame (uncommon).
| poster_frame | python | scanny/python-pptx | src/pptx/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/picture.py | MIT |
def auto_shape_type(self) -> MSO_SHAPE | None:
"""Member of MSO_SHAPE indicating masking shape.
A picture can be masked by any of the so-called "auto-shapes" available in PowerPoint,
such as an ellipse or triangle. When a picture is masked by a shape, the shape assumes the
same dimensio... | Member of MSO_SHAPE indicating masking shape.
A picture can be masked by any of the so-called "auto-shapes" available in PowerPoint,
such as an ellipse or triangle. When a picture is masked by a shape, the shape assumes the
same dimensions as the picture and the portion of the picture outside t... | auto_shape_type | python | scanny/python-pptx | src/pptx/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/picture.py | MIT |
def image(self):
"""The |Image| object for this picture.
Provides access to the properties and bytes of the image in this picture shape.
"""
slide_part, rId = self.part, self._pic.blip_rId
if rId is None:
raise ValueError("no embedded image")
return slide_par... | The |Image| object for this picture.
Provides access to the properties and bytes of the image in this picture shape.
| image | python | scanny/python-pptx | src/pptx/shapes/picture.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/picture.py | MIT |
def _effective_value(self, attr_name):
"""
The effective value of *attr_name* on this placeholder shape; its
directly-applied value if it has one, otherwise the value on the
layout placeholder it inherits from.
"""
directly_applied_value = getattr(super(_InheritsDimension... |
The effective value of *attr_name* on this placeholder shape; its
directly-applied value if it has one, otherwise the value on the
layout placeholder it inherits from.
| _effective_value | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _inherited_value(self, attr_name):
"""
Return the attribute value, e.g. 'width' of the base placeholder this
placeholder inherits from.
"""
base_placeholder = self._base_placeholder
if base_placeholder is None:
return None
inherited_value = getattr... |
Return the attribute value, e.g. 'width' of the base placeholder this
placeholder inherits from.
| _inherited_value | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _replace_placeholder_with(self, element):
"""
Substitute *element* for this placeholder element in the shapetree.
This placeholder's `._element` attribute is set to |None| and its
original element is free for garbage collection. Any attribute access
(including a method call) ... |
Substitute *element* for this placeholder element in the shapetree.
This placeholder's `._element` attribute is set to |None| and its
original element is free for garbage collection. Any attribute access
(including a method call) on this placeholder after this call raises
|Attri... | _replace_placeholder_with | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _base_placeholder(self):
"""
Return the master placeholder this layout placeholder inherits from.
"""
base_ph_type = {
PP_PLACEHOLDER.BODY: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.CHART: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.BITMAP: PP_PLACEHOLDER.BODY,
... |
Return the master placeholder this layout placeholder inherits from.
| _base_placeholder | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _base_placeholder(self):
"""
Return the notes master placeholder this notes slide placeholder
inherits from, or |None| if no placeholder of the matching type is
present.
"""
notes_master = self.part.notes_master
ph_type = self.element.ph_type
return no... |
Return the notes master placeholder this notes slide placeholder
inherits from, or |None| if no placeholder of the matching type is
present.
| _base_placeholder | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def insert_chart(self, chart_type, chart_data):
"""
Return a |PlaceholderGraphicFrame| object containing a new chart of
*chart_type* depicting *chart_data* and having the same position and
size as this placeholder. *chart_type* is one of the
:ref:`XlChartType` enumeration values.... |
Return a |PlaceholderGraphicFrame| object containing a new chart of
*chart_type* depicting *chart_data* and having the same position and
size as this placeholder. *chart_type* is one of the
:ref:`XlChartType` enumeration values. *chart_data* is a |ChartData|
object populated wit... | insert_chart | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _new_chart_graphicFrame(self, rId, x, y, cx, cy):
"""
Return a newly created `p:graphicFrame` element having the specified
position and size and containing the chart identified by *rId*.
"""
id_, name = self.shape_id, self.name
return CT_GraphicalObjectFrame.new_chart... |
Return a newly created `p:graphicFrame` element having the specified
position and size and containing the chart identified by *rId*.
| _new_chart_graphicFrame | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def insert_picture(self, image_file):
"""Return a |PlaceholderPicture| object depicting the image in `image_file`.
`image_file` may be either a path (string) or a file-like object. The image is
cropped to fill the entire space of the placeholder. A |PlaceholderPicture|
object has all th... | Return a |PlaceholderPicture| object depicting the image in `image_file`.
`image_file` may be either a path (string) or a file-like object. The image is
cropped to fill the entire space of the placeholder. A |PlaceholderPicture|
object has all the properties and methods of a |Picture| shape exc... | insert_picture | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _new_placeholder_pic(self, image_file):
"""
Return a new `p:pic` element depicting the image in *image_file*,
suitable for use as a placeholder. In particular this means not
having an `a:xfrm` element, allowing its extents to be inherited from
its layout placeholder.
... |
Return a new `p:pic` element depicting the image in *image_file*,
suitable for use as a placeholder. In particular this means not
having an `a:xfrm` element, allowing its extents to be inherited from
its layout placeholder.
| _new_placeholder_pic | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _get_or_add_image(self, image_file):
"""
Return an (rId, description, image_size) 3-tuple identifying the
related image part containing *image_file* and describing the image.
"""
image_part, rId = self.part.get_or_add_image_part(image_file)
desc, image_size = image_pa... |
Return an (rId, description, image_size) 3-tuple identifying the
related image part containing *image_file* and describing the image.
| _get_or_add_image | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def insert_table(self, rows, cols):
"""Return |PlaceholderGraphicFrame| object containing a `rows` by `cols` table.
The position and width of the table are those of the placeholder and its height
is proportional to the number of rows. A |PlaceholderGraphicFrame| object has
all the prope... | Return |PlaceholderGraphicFrame| object containing a `rows` by `cols` table.
The position and width of the table are those of the placeholder and its height
is proportional to the number of rows. A |PlaceholderGraphicFrame| object has
all the properties and methods of a |GraphicFrame| shape exc... | insert_table | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def _new_placeholder_table(self, rows, cols):
"""
Return a newly added `p:graphicFrame` element containing an empty
table with *rows* rows and *cols* columns, positioned at the location
of this placeholder and having its same width. The table's height is
determined by the number ... |
Return a newly added `p:graphicFrame` element containing an empty
table with *rows* rows and *cols* columns, positioned at the location
of this placeholder and having its same width. The table's height is
determined by the number of rows.
| _new_placeholder_table | python | scanny/python-pptx | src/pptx/shapes/placeholder.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/placeholder.py | MIT |
def __getitem__(self, idx: int) -> BaseShape:
"""Return shape at `idx` in sequence, e.g. `shapes[2]`."""
shape_elms = list(self._iter_member_elms())
try:
shape_elm = shape_elms[idx]
except IndexError:
raise IndexError("shape index out of range")
return sel... | Return shape at `idx` in sequence, e.g. `shapes[2]`. | __getitem__ | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def clone_placeholder(self, placeholder: LayoutPlaceholder) -> None:
"""Add a new placeholder shape based on `placeholder`."""
sp = placeholder.element
ph_type, orient, sz, idx = (sp.ph_type, sp.ph_orient, sp.ph_sz, sp.ph_idx)
id_ = self._next_shape_id
name = self._next_ph_name(p... | Add a new placeholder shape based on `placeholder`. | clone_placeholder | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def ph_basename(self, ph_type: PP_PLACEHOLDER) -> str:
"""Return the base name for a placeholder of `ph_type` in this shape collection.
There is some variance between slide types, for example a notes slide uses a different
name for the body placeholder, so this method can be overriden by subcla... | Return the base name for a placeholder of `ph_type` in this shape collection.
There is some variance between slide types, for example a notes slide uses a different
name for the body placeholder, so this method can be overriden by subclasses.
| ph_basename | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _iter_member_elms(self) -> Iterator[ShapeElement]:
"""Generate each child of the `p:spTree` element that corresponds to a shape.
Items appear in XML document order.
"""
for shape_elm in self._spTree.iter_shape_elms():
if self._is_member_elm(shape_elm):
yi... | Generate each child of the `p:spTree` element that corresponds to a shape.
Items appear in XML document order.
| _iter_member_elms | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _next_ph_name(self, ph_type: PP_PLACEHOLDER, id: int, orient: str) -> str:
"""Next unique placeholder name for placeholder shape of type `ph_type`.
Usually will be standard placeholder root name suffixed with id-1, e.g.
_next_ph_name(ST_PlaceholderType.TBL, 4, 'horz') ==> 'Table Placeholder... | Next unique placeholder name for placeholder shape of type `ph_type`.
Usually will be standard placeholder root name suffixed with id-1, e.g.
_next_ph_name(ST_PlaceholderType.TBL, 4, 'horz') ==> 'Table Placeholder 3'. The number is
incremented as necessary to make the name unique within the col... | _next_ph_name | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _next_shape_id(self) -> int:
"""Return a unique shape id suitable for use with a new shape.
The returned id is 1 greater than the maximum shape id used so far. In practice, the
minimum id is 2 because the spTree element is always assigned id="1".
"""
# ---presence of cached-... | Return a unique shape id suitable for use with a new shape.
The returned id is 1 greater than the maximum shape id used so far. In practice, the
minimum id is 2 because the spTree element is always assigned id="1".
| _next_shape_id | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_chart(
self,
chart_type: XL_CHART_TYPE,
x: Length,
y: Length,
cx: Length,
cy: Length,
chart_data: ChartData,
) -> Chart:
"""Add a new chart of `chart_type` to the slide.
The chart is positioned at (`x`, `y`), has size (`cx`, `cy`), and... | Add a new chart of `chart_type` to the slide.
The chart is positioned at (`x`, `y`), has size (`cx`, `cy`), and depicts `chart_data`.
`chart_type` is one of the :ref:`XlChartType` enumeration values. `chart_data` is a
|ChartData| object populated with the categories and series values for the ch... | add_chart | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_connector(
self,
connector_type: MSO_CONNECTOR_TYPE,
begin_x: Length,
begin_y: Length,
end_x: Length,
end_y: Length,
) -> Connector:
"""Add a newly created connector shape to the end of this shape tree.
`connector_type` is a member of the :ref... | Add a newly created connector shape to the end of this shape tree.
`connector_type` is a member of the :ref:`MsoConnectorType` enumeration and the end-point
values are specified as EMU values. The returned connector is of type `connector_type` and
has begin and end points as specified.
| add_connector | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_group_shape(self, shapes: Iterable[BaseShape] = ()) -> GroupShape:
"""Return a |GroupShape| object newly appended to this shape tree.
The group shape is empty and must be populated with shapes using methods on its shape
tree, available on its `.shapes` property. The position and extents... | Return a |GroupShape| object newly appended to this shape tree.
The group shape is empty and must be populated with shapes using methods on its shape
tree, available on its `.shapes` property. The position and extents of the group shape are
determined by the shapes it contains; its position and... | add_group_shape | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_picture(
self,
image_file: str | IO[bytes],
left: Length,
top: Length,
width: Length | None = None,
height: Length | None = None,
) -> Picture:
"""Add picture shape displaying image in `image_file`.
`image_file` can be either a path to a file ... | Add picture shape displaying image in `image_file`.
`image_file` can be either a path to a file (a string) or a file-like object. The picture
is positioned with its top-left corner at (`top`, `left`). If `width` and `height` are
both |None|, the native size of the image is used. If only one of ... | add_picture | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_shape(
self, autoshape_type_id: MSO_SHAPE, left: Length, top: Length, width: Length, height: Length
) -> Shape:
"""Return new |Shape| object appended to this shape tree.
`autoshape_type_id` is a member of :ref:`MsoAutoShapeType` e.g. `MSO_SHAPE.RECTANGLE`
specifying the type... | Return new |Shape| object appended to this shape tree.
`autoshape_type_id` is a member of :ref:`MsoAutoShapeType` e.g. `MSO_SHAPE.RECTANGLE`
specifying the type of shape to be added. The remaining arguments specify the new shape's
position and size.
| add_shape | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_textbox(self, left: Length, top: Length, width: Length, height: Length) -> Shape:
"""Return newly added text box shape appended to this shape tree.
The text box is of the specified size, located at the specified position on the slide.
"""
sp = self._add_textbox_sp(left, top, wid... | Return newly added text box shape appended to this shape tree.
The text box is of the specified size, located at the specified position on the slide.
| add_textbox | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def build_freeform(
self, start_x: float = 0, start_y: float = 0, scale: tuple[float, float] | float = 1.0
) -> FreeformBuilder:
"""Return |FreeformBuilder| object to specify a freeform shape.
The optional `start_x` and `start_y` arguments specify the starting pen position in local
... | Return |FreeformBuilder| object to specify a freeform shape.
The optional `start_x` and `start_y` arguments specify the starting pen position in local
coordinates. They will be rounded to the nearest integer before use and each default to
zero.
The optional `scale` argument specifies t... | build_freeform | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_chart_graphicFrame(
self, rId: str, x: Length, y: Length, cx: Length, cy: Length
) -> CT_GraphicalObjectFrame:
"""Return new `p:graphicFrame` element appended to this shape tree.
The `p:graphicFrame` element has the specified position and size and refers to the chart
part i... | Return new `p:graphicFrame` element appended to this shape tree.
The `p:graphicFrame` element has the specified position and size and refers to the chart
part identified by `rId`.
| _add_chart_graphicFrame | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_cxnSp(
self,
connector_type: MSO_CONNECTOR_TYPE,
begin_x: Length,
begin_y: Length,
end_x: Length,
end_y: Length,
) -> CT_Connector:
"""Return a newly-added `p:cxnSp` element as specified.
The `p:cxnSp` element is for a connector of `connector... | Return a newly-added `p:cxnSp` element as specified.
The `p:cxnSp` element is for a connector of `connector_type` beginning at (`begin_x`,
`begin_y`) and extending to (`end_x`, `end_y`).
| _add_cxnSp | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_pic_from_image_part(
self,
image_part: ImagePart,
rId: str,
x: Length,
y: Length,
cx: Length | None,
cy: Length | None,
) -> CT_Picture:
"""Return a newly appended `p:pic` element as specified.
The `p:pic` element displays the image i... | Return a newly appended `p:pic` element as specified.
The `p:pic` element displays the image in `image_part` with size and position specified by
`x`, `y`, `cx`, and `cy`. The element is appended to the shape tree, causing it to be
displayed first in z-order on the slide.
| _add_pic_from_image_part | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_sp(
self, autoshape_type: AutoShapeType, x: Length, y: Length, cx: Length, cy: Length
) -> CT_Shape:
"""Return newly-added `p:sp` element as specified.
`p:sp` element is of `autoshape_type` at position (`x`, `y`) and of size (`cx`, `cy`).
"""
id_ = self._next_shape_... | Return newly-added `p:sp` element as specified.
`p:sp` element is of `autoshape_type` at position (`x`, `y`) and of size (`cx`, `cy`).
| _add_sp | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_textbox_sp(self, x: Length, y: Length, cx: Length, cy: Length) -> CT_Shape:
"""Return newly-appended textbox `p:sp` element.
Element has position (`x`, `y`) and size (`cx`, `cy`).
"""
id_ = self._next_shape_id
name = "TextBox %d" % (id_ - 1)
sp = self._spTree.ad... | Return newly-appended textbox `p:sp` element.
Element has position (`x`, `y`) and size (`cx`, `cy`).
| _add_textbox_sp | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _recalculate_extents(self) -> None:
"""Adjust position and size to incorporate all contained shapes.
This would typically be called when a contained shape is added, removed, or its position
or size updated.
"""
# ---default behavior is to do nothing, GroupShapes overrides to... | Adjust position and size to incorporate all contained shapes.
This would typically be called when a contained shape is added, removed, or its position
or size updated.
| _recalculate_extents | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def add_table(
self, rows: int, cols: int, left: Length, top: Length, width: Length, height: Length
) -> GraphicFrame:
"""Add a |GraphicFrame| object containing a table.
The table has the specified number of `rows` and `cols` and the specified position and
size. `width` is evenly di... | Add a |GraphicFrame| object containing a table.
The table has the specified number of `rows` and `cols` and the specified position and
size. `width` is evenly distributed between the columns of the new table. Likewise,
`height` is evenly distributed between the rows. Note that the `.table` prop... | add_table | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def title(self) -> Shape | None:
"""The title placeholder shape on the slide.
|None| if the slide has no title placeholder.
"""
for elm in self._spTree.iter_ph_elms():
if elm.ph_idx == 0:
return cast(Shape, self._shape_factory(elm))
return None | The title placeholder shape on the slide.
|None| if the slide has no title placeholder.
| title | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_graphicFrame_containing_table(
self, rows: int, cols: int, x: Length, y: Length, cx: Length, cy: Length
) -> CT_GraphicalObjectFrame:
"""Return a newly added `p:graphicFrame` element containing a table as specified."""
_id = self._next_shape_id
name = "Table %d" % (_id - 1)
... | Return a newly added `p:graphicFrame` element containing a table as specified. | _add_graphicFrame_containing_table | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _add_video_timing(self, pic: CT_Picture) -> None:
"""Add a `p:video` element under `p:sld/p:timing`.
The element will refer to the specified `pic` element by its shape id, and cause the video
play controls to appear for that video.
"""
sld = self._spTree.xpath("/p:sld")[0]
... | Add a `p:video` element under `p:sld/p:timing`.
The element will refer to the specified `pic` element by its shape id, and cause the video
play controls to appear for that video.
| _add_video_timing | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def ph_basename(self, ph_type: PP_PLACEHOLDER) -> str:
"""Return the base name for a placeholder of `ph_type` in this shape collection.
A notes slide uses a different name for the body placeholder and has some unique
placeholder types, so this method overrides the default in the base class.
... | Return the base name for a placeholder of `ph_type` in this shape collection.
A notes slide uses a different name for the body placeholder and has some unique
placeholder types, so this method overrides the default in the base class.
| ph_basename | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def get(self, idx: int, default: LayoutPlaceholder | None = None) -> LayoutPlaceholder | None:
"""The first placeholder shape with matching `idx` value, or `default` if not found."""
for placeholder in self:
if placeholder.element.ph_idx == idx:
return placeholder
ret... | The first placeholder shape with matching `idx` value, or `default` if not found. | get | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def get(self, ph_type: PP_PLACEHOLDER, default: MasterPlaceholder | None = None):
"""Return the first placeholder shape with type `ph_type` (e.g. 'body').
Returns `default` if no such placeholder shape is present in the collection.
"""
for placeholder in self:
if placeholder... | Return the first placeholder shape with type `ph_type` (e.g. 'body').
Returns `default` if no such placeholder shape is present in the collection.
| get | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _shape_factory( # pyright: ignore[reportIncompatibleMethodOverride]
self, placeholder_elm: CT_Shape
) -> MasterPlaceholder:
"""Return an instance of the appropriate shape proxy class for `shape_elm`."""
return cast(MasterPlaceholder, _MasterShapeFactory(placeholder_elm, self)) | Return an instance of the appropriate shape proxy class for `shape_elm`. | _shape_factory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _shape_factory( # pyright: ignore[reportIncompatibleMethodOverride]
self, placeholder_elm: CT_Shape
) -> NotesSlidePlaceholder:
"""Return an instance of the appropriate placeholder proxy class for `placeholder_elm`."""
return cast(NotesSlidePlaceholder, _NotesSlideShapeFactory(placehold... | Return an instance of the appropriate placeholder proxy class for `placeholder_elm`. | _shape_factory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def __getitem__(self, idx: int):
"""Access placeholder shape having `idx`.
Note that while this looks like list access, idx is actually a dictionary key and will
raise |KeyError| if no placeholder with that idx value is in the collection.
"""
for e in self._element.iter_ph_elms(... | Access placeholder shape having `idx`.
Note that while this looks like list access, idx is actually a dictionary key and will
raise |KeyError| if no placeholder with that idx value is in the collection.
| __getitem__ | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def __iter__(self):
"""Generate placeholder shapes in `idx` order."""
ph_elms = sorted([e for e in self._element.iter_ph_elms()], key=lambda e: e.ph_idx)
return (SlideShapeFactory(e, self) for e in ph_elms) | Generate placeholder shapes in `idx` order. | __iter__ | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def BaseShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
"""Return an instance of the appropriate shape proxy class for `shape_elm`."""
tag = shape_elm.tag
if isinstance(shape_elm, CT_Picture):
videoFiles = shape_elm.xpath("./p:nvPicPr/p:nvPr/a:videoFile")
if videoF... | Return an instance of the appropriate shape proxy class for `shape_elm`. | BaseShapeFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _LayoutShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
"""Return appropriate shape object for `shape_elm` on a slide layout."""
if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
return LayoutPlaceholder(shape_elm, parent)
return BaseShapeFactory(shape_elm, pa... | Return appropriate shape object for `shape_elm` on a slide layout. | _LayoutShapeFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _MasterShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
"""Return appropriate shape object for `shape_elm` on a slide master."""
if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
return MasterPlaceholder(shape_elm, parent)
return BaseShapeFactory(shape_elm, pa... | Return appropriate shape object for `shape_elm` on a slide master. | _MasterShapeFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _NotesSlideShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
"""Return appropriate shape object for `shape_elm` on a notes slide."""
if isinstance(shape_elm, CT_Shape) and shape_elm.has_ph_elm:
return NotesSlidePlaceholder(shape_elm, parent)
return BaseShapeFactory(shape_... | Return appropriate shape object for `shape_elm` on a notes slide. | _NotesSlideShapeFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _SlidePlaceholderFactory(shape_elm: ShapeElement, parent: ProvidesPart):
"""Return a placeholder shape of the appropriate type for `shape_elm`."""
tag = shape_elm.tag
if tag == qn("p:sp"):
Constructor = {
PP_PLACEHOLDER.BITMAP: PicturePlaceholder,
PP_PLACEHOLDER.CHART: Ch... | Return a placeholder shape of the appropriate type for `shape_elm`. | _SlidePlaceholderFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def SlideShapeFactory(shape_elm: ShapeElement, parent: ProvidesPart) -> BaseShape:
"""Return appropriate shape object for `shape_elm` on a slide."""
if shape_elm.has_ph_elm:
return _SlidePlaceholderFactory(shape_elm, parent)
return BaseShapeFactory(shape_elm, parent) | Return appropriate shape object for `shape_elm` on a slide. | SlideShapeFactory | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def new_movie_pic(
cls,
shapes: SlideShapes,
shape_id: int,
movie_file: str | IO[bytes],
x: Length,
y: Length,
cx: Length,
cy: Length,
poster_frame_image: str | IO[bytes] | None,
mime_type: str | None,
) -> CT_Picture:
"""Return... | Return a new `p:pic` element containing video in `movie_file`.
If `mime_type` is None, 'video/unknown' is used. If `poster_frame_file` is None, the
default "media loudspeaker" image is used.
| new_movie_pic | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _pic(self) -> CT_Picture:
"""Return the new `p:pic` element referencing the video."""
return CT_Picture.new_video_pic(
self._shape_id,
self._shape_name,
self._video_rId,
self._media_rId,
self._poster_frame_rId,
self._x,
... | Return the new `p:pic` element referencing the video. | _pic | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _poster_frame_image_file(self) -> str | IO[bytes]:
"""Return the image file for video placeholder image.
If no poster frame file is provided, the default "media loudspeaker" image is used.
"""
poster_frame_file = self._poster_frame_file
if poster_frame_file is None:
... | Return the image file for video placeholder image.
If no poster frame file is provided, the default "media loudspeaker" image is used.
| _poster_frame_image_file | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _video_part_rIds(self) -> tuple[str, str]:
"""Return the rIds for relationships to media part for video.
This is where the media part and its relationships to the slide are actually created.
"""
media_rId, video_rId = self._slide_part.get_or_add_video_media_part(self._video)
... | Return the rIds for relationships to media part for video.
This is where the media part and its relationships to the slide are actually created.
| _video_part_rIds | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def graphicFrame(
cls,
shapes: _BaseGroupShapes,
shape_id: int,
ole_object_file: str | IO[bytes],
prog_id: PROG_ID | str,
x: Length,
y: Length,
cx: Length | None,
cy: Length | None,
icon_file: str | IO[bytes] | None,
icon_width: Len... | Return new `p:graphicFrame` element containing embedded `ole_object_file`. | graphicFrame | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _graphicFrame(self) -> CT_GraphicalObjectFrame:
"""Newly-created `p:graphicFrame` element referencing embedded OLE-object."""
return CT_GraphicalObjectFrame.new_ole_object_graphicFrame(
self._shape_id,
self._shape_name,
self._ole_object_rId,
self._prog... | Newly-created `p:graphicFrame` element referencing embedded OLE-object. | _graphicFrame | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _cx(self) -> Length:
"""Emu object specifying width of "show-as-icon" image for OLE shape."""
# --- a user-specified width overrides any default ---
if self._cx_arg is not None:
return self._cx_arg
# --- the default width is specified by the PROG_ID member if prog_id is ... | Emu object specifying width of "show-as-icon" image for OLE shape. | _cx | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _cy(self) -> Length:
"""Emu object specifying height of "show-as-icon" image for OLE shape."""
# --- a user-specified width overrides any default ---
if self._cy_arg is not None:
return self._cy_arg
# --- the default height is specified by the PROG_ID member if prog_id i... | Emu object specifying height of "show-as-icon" image for OLE shape. | _cy | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _icon_image_file(self) -> str | IO[bytes]:
"""Reference to image file containing icon to show in lieu of this object.
This can be either a str path or a file-like object (io.BytesIO typically).
"""
# --- a user-specified icon overrides any default ---
if self._icon_file_arg ... | Reference to image file containing icon to show in lieu of this object.
This can be either a str path or a file-like object (io.BytesIO typically).
| _icon_image_file | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _ole_object_rId(self) -> str:
"""str rId like "rId6" of relationship to embedded ole_object part.
This is where the ole_object part and its relationship to the slide are actually created.
"""
return self._slide_part.add_embedded_ole_object_part(
self._prog_id_arg, self._... | str rId like "rId6" of relationship to embedded ole_object part.
This is where the ole_object part and its relationship to the slide are actually created.
| _ole_object_rId | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def _progId(self) -> str:
"""str like "Excel.Sheet.12" identifying program used to open object.
This value appears in the `progId` attribute of the `p:oleObj` element for the object.
"""
prog_id_arg = self._prog_id_arg
# --- member of PROG_ID enumeration knows its progId keyphr... | str like "Excel.Sheet.12" identifying program used to open object.
This value appears in the `progId` attribute of the `p:oleObj` element for the object.
| _progId | python | scanny/python-pptx | src/pptx/shapes/shapetree.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/shapes/shapetree.py | MIT |
def find(cls, family_name: str, is_bold: bool, is_italic: bool) -> str:
"""Return the absolute path to an installed OpenType font.
File is matched by `family_name` and the styles `is_bold` and `is_italic`.
"""
if cls._font_files is None:
cls._font_files = cls._installed_font... | Return the absolute path to an installed OpenType font.
File is matched by `family_name` and the styles `is_bold` and `is_italic`.
| find | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _installed_fonts(cls):
"""
Return a dict mapping a font descriptor to its font file path,
containing all the font files resident on the current machine. The
font descriptor is a (family_name, is_bold, is_italic) 3-tuple.
"""
fonts = {}
for d in cls._font_direc... |
Return a dict mapping a font descriptor to its font file path,
containing all the font files resident on the current machine. The
font descriptor is a (family_name, is_bold, is_italic) 3-tuple.
| _installed_fonts | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _font_directories(cls):
"""
Return a sequence of directory paths likely to contain fonts on the
current platform.
"""
if sys.platform.startswith("darwin"):
return cls._os_x_font_directories()
if sys.platform.startswith("win32"):
return cls._win... |
Return a sequence of directory paths likely to contain fonts on the
current platform.
| _font_directories | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _iter_font_files_in(cls, directory):
"""
Generate the OpenType font files found in and under *directory*. Each
item is a key/value pair. The key is a (family_name, is_bold,
is_italic) 3-tuple, like ('Arial', True, False), and the value is the
absolute path to the font file.
... |
Generate the OpenType font files found in and under *directory*. Each
item is a key/value pair. The key is a (family_name, is_bold,
is_italic) 3-tuple, like ('Arial', True, False), and the value is the
absolute path to the font file.
| _iter_font_files_in | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _os_x_font_directories(cls):
"""
Return a sequence of directory paths on a Mac in which fonts are
likely to be located.
"""
os_x_font_dirs = [
"/Library/Fonts",
"/Network/Library/Fonts",
"/System/Library/Fonts",
]
home = os.... |
Return a sequence of directory paths on a Mac in which fonts are
likely to be located.
| _os_x_font_directories | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def is_bold(self):
"""
|True| if this font is marked as a bold style of its font family.
"""
try:
return self._tables["head"].is_bold
except KeyError:
# some files don't have a head table
return False |
|True| if this font is marked as a bold style of its font family.
| is_bold | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def is_italic(self):
"""
|True| if this font is marked as an italic style of its font family.
"""
try:
return self._tables["head"].is_italic
except KeyError:
# some files don't have a head table
return False |
|True| if this font is marked as an italic style of its font family.
| is_italic | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _fields(self):
"""5-tuple containing the fields read from the font file header.
Also known as the offset table.
"""
# sfnt_version, tbl_count, search_range, entry_selector, range_shift
return self._stream.read_fields(">4sHHHH", 0) | 5-tuple containing the fields read from the font file header.
Also known as the offset table.
| _fields | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _iter_table_records(self):
"""
Generate a (tag, offset, length) 3-tuple for each of the tables in
this font file.
"""
count = self._table_count
bufr = self._stream.read(offset=12, length=count * 16)
tmpl = ">4sLLL"
for i in range(count):
of... |
Generate a (tag, offset, length) 3-tuple for each of the tables in
this font file.
| _iter_table_records | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _tables(self):
"""
A mapping of OpenType table tag, e.g. 'name', to a table object
providing access to the contents of that table.
"""
return dict(
(tag, _TableFactory(tag, self._stream, off, len_))
for tag, off, len_ in self._iter_table_records()
... |
A mapping of OpenType table tag, e.g. 'name', to a table object
providing access to the contents of that table.
| _tables | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def read_fields(self, template, offset=0):
"""
Return a tuple containing the C-struct fields in this stream
specified by *template* and starting at *offset*.
"""
self._file.seek(offset)
bufr = self._file.read(calcsize(template))
return unpack_from(template, bufr) |
Return a tuple containing the C-struct fields in this stream
specified by *template* and starting at *offset*.
| read_fields | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def family_name(self):
"""
The name of the typeface family for this font, e.g. 'Arial'.
"""
def find_first(dict_, keys, default=None):
for key in keys:
value = dict_.get(key)
if value is not None:
return value
r... |
The name of the typeface family for this font, e.g. 'Arial'.
| family_name | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _decode_name(raw_name, platform_id, encoding_id):
"""
Return the unicode name decoded from *raw_name* using the encoding
implied by the combination of *platform_id* and *encoding_id*.
"""
if platform_id == 1:
# reject non-Roman Mac font names
if encodi... |
Return the unicode name decoded from *raw_name* using the encoding
implied by the combination of *platform_id* and *encoding_id*.
| _decode_name | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _iter_names(self):
"""Generate a key/value pair for each name in this table.
The key is a (platform_id, name_id) 2-tuple and the value is the unicode text
corresponding to that key.
"""
table_format, count, strings_offset = self._table_header
table_bytes = self._tabl... | Generate a key/value pair for each name in this table.
The key is a (platform_id, name_id) 2-tuple and the value is the unicode text
corresponding to that key.
| _iter_names | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _name_header(bufr, idx):
"""
The (platform_id, encoding_id, language_id, name_id, length,
name_str_offset) 6-tuple encoded in each name record C-struct.
"""
name_hdr_offset = 6 + idx * 12
return unpack_from(">HHHHHH", bufr, name_hdr_offset) |
The (platform_id, encoding_id, language_id, name_id, length,
name_str_offset) 6-tuple encoded in each name record C-struct.
| _name_header | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _raw_name_string(bufr, strings_offset, str_offset, length):
"""
Return the *length* bytes comprising the encoded string in *bufr* at
*str_offset* in the strings area beginning at *strings_offset*.
"""
offset = strings_offset + str_offset
tmpl = "%ds" % length
... |
Return the *length* bytes comprising the encoded string in *bufr* at
*str_offset* in the strings area beginning at *strings_offset*.
| _raw_name_string | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _read_name(self, bufr, idx, strings_offset):
"""Return a (platform_id, name_id, name) 3-tuple for name at `idx` in `bufr`.
The triple looks like (0, 1, 'Arial'). `strings_offset` is the for the name at
`idx` position in `bufr`. `strings_offset` is the index into `bufr` where actual
... | Return a (platform_id, name_id, name) 3-tuple for name at `idx` in `bufr`.
The triple looks like (0, 1, 'Arial'). `strings_offset` is the for the name at
`idx` position in `bufr`. `strings_offset` is the index into `bufr` where actual
name strings begin. The returned name is a unicode string.
... | _read_name | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _read_name_text(
self, bufr, platform_id, encoding_id, strings_offset, name_str_offset, length
):
"""
Return the unicode name string at *name_str_offset* or |None| if
decoding its format is not supported.
"""
raw_name = self._raw_name_string(bufr, strings_offset, ... |
Return the unicode name string at *name_str_offset* or |None| if
decoding its format is not supported.
| _read_name_text | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def _TableFactory(tag, stream, offset, length):
"""
Return an instance of |Table| appropriate to *tag*, loaded from
*font_file* with content of *length* starting at *offset*.
"""
TableClass = {"head": _HeadTable, "name": _NameTable}.get(tag, _BaseTable)
return TableClass(tag, stream, offset, len... |
Return an instance of |Table| appropriate to *tag*, loaded from
*font_file* with content of *length* starting at *offset*.
| _TableFactory | python | scanny/python-pptx | src/pptx/text/fonts.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/fonts.py | MIT |
def best_fit_font_size(
cls, text: str, extents: tuple[Length, Length], max_size: int, font_file: str
) -> int:
"""Return whole-number best fit point size less than or equal to `max_size`.
The return value is the largest whole-number point size less than or equal to
`max_size` that ... | Return whole-number best fit point size less than or equal to `max_size`.
The return value is the largest whole-number point size less than or equal to
`max_size` that allows `text` to fit completely within `extents` when rendered
using font defined in `font_file`.
| best_fit_font_size | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _best_fit_font_size(self, max_size):
"""
Return the largest whole-number point size less than or equal to
*max_size* that this fitter can fit.
"""
predicate = self._fits_inside_predicate
sizes = _BinarySearchTree.from_ordered_sequence(range(1, int(max_size) + 1))
... |
Return the largest whole-number point size less than or equal to
*max_size* that this fitter can fit.
| _best_fit_font_size | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _break_line(self, line_source, point_size):
"""
Return a (line, remainder) pair where *line* is the longest line in
*line_source* that will fit in this fitter's width and *remainder* is
a |_LineSource| object containing the text following the break point.
"""
lines = ... |
Return a (line, remainder) pair where *line* is the longest line in
*line_source* that will fit in this fitter's width and *remainder* is
a |_LineSource| object containing the text following the break point.
| _break_line | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _fits_in_width_predicate(self, point_size):
"""
Return a function taking a text string value and returns |True| if
that text fits in this fitter when rendered at *point_size*. Used as
predicate for _break_line()
"""
def predicate(line):
"""
Re... |
Return a function taking a text string value and returns |True| if
that text fits in this fitter when rendered at *point_size*. Used as
predicate for _break_line()
| _fits_in_width_predicate | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def predicate(line):
"""
Return |True| if *line* fits in this fitter when rendered at
*point_size*.
"""
cx = _rendered_size(line.text, point_size, self._font_file)[0]
return cx <= self._width |
Return |True| if *line* fits in this fitter when rendered at
*point_size*.
| predicate | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _fits_inside_predicate(self):
"""Return function taking an integer point size argument.
The function returns |True| if the text in this fitter can be wrapped to fit
entirely within its extents when rendered at that point size.
"""
def predicate(point_size):
"""... | Return function taking an integer point size argument.
The function returns |True| if the text in this fitter can be wrapped to fit
entirely within its extents when rendered at that point size.
| _fits_inside_predicate | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def predicate(point_size):
"""Return |True| when text in `line_source` can be wrapped to fit.
Fit means text can be broken into lines that fit entirely within `extents`
when rendered at `point_size` using the font defined in `font_file`.
"""
text_lines = self... | Return |True| when text in `line_source` can be wrapped to fit.
Fit means text can be broken into lines that fit entirely within `extents`
when rendered at `point_size` using the font defined in `font_file`.
| predicate | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _wrap_lines(self, line_source, point_size):
"""
Return a sequence of str values representing the text in
*line_source* wrapped within this fitter when rendered at
*point_size*.
"""
text, remainder = self._break_line(line_source, point_size)
lines = [text]
... |
Return a sequence of str values representing the text in
*line_source* wrapped within this fitter when rendered at
*point_size*.
| _wrap_lines | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def find_max(self, predicate, max_=None):
"""
Return the largest item in or under this node that satisfies
*predicate*.
"""
if predicate(self.value):
max_ = self.value
next_node = self._greater
else:
next_node = self._lesser
if ... |
Return the largest item in or under this node that satisfies
*predicate*.
| find_max | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def from_ordered_sequence(cls, iseq):
"""
Return the root of a balanced binary search tree populated with the
values in iterable *iseq*.
"""
seq = list(iseq)
# optimize for usually all fits by making longest first
bst = cls(seq.pop())
bst._insert_from_orde... |
Return the root of a balanced binary search tree populated with the
values in iterable *iseq*.
| from_ordered_sequence | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def insert(self, value):
"""
Insert a new node containing *value* into this tree such that its
structure as a binary search tree is preserved.
"""
side = "_lesser" if value < self.value else "_greater"
child = getattr(self, side)
if child is None:
seta... |
Insert a new node containing *value* into this tree such that its
structure as a binary search tree is preserved.
| insert | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _bisect(seq):
"""
Return a (medial_value, greater_values, lesser_values) 3-tuple
obtained by bisecting sequence *seq*.
"""
if len(seq) == 0:
return [], None, []
mid_idx = int(len(seq) / 2)
mid = seq[mid_idx]
greater = seq[mid_idx + 1 :]
... |
Return a (medial_value, greater_values, lesser_values) 3-tuple
obtained by bisecting sequence *seq*.
| _bisect | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _insert_from_ordered_sequence(self, seq):
"""
Insert the new values contained in *seq* into this tree such that
a balanced tree is produced.
"""
if len(seq) == 0:
return
mid, greater, lesser = self._bisect(seq)
self.insert(mid)
self._insert... |
Insert the new values contained in *seq* into this tree such that
a balanced tree is produced.
| _insert_from_ordered_sequence | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def __iter__(self):
"""
Generate a (text, remainder) pair for each possible even-word line
break in this line source, where *text* is a str value and remainder
is a |_LineSource| value.
"""
words = self._text.split()
for idx in range(1, len(words) + 1):
... |
Generate a (text, remainder) pair for each possible even-word line
break in this line source, where *text* is a str value and remainder
is a |_LineSource| value.
| __iter__ | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def _rendered_size(text, point_size, font_file):
"""
Return a (width, height) pair representing the size of *text* in English
Metric Units (EMU) when rendered at *point_size* in the font defined in
*font_file*.
"""
emu_per_inch = 914400
px_per_inch = 72.0
font = _Fonts.font(font_file, p... |
Return a (width, height) pair representing the size of *text* in English
Metric Units (EMU) when rendered at *point_size* in the font defined in
*font_file*.
| _rendered_size | python | scanny/python-pptx | src/pptx/text/layout.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/layout.py | MIT |
def add_paragraph(self):
"""
Return new |_Paragraph| instance appended to the sequence of
paragraphs contained in this text frame.
"""
p = self._txBody.add_p()
return _Paragraph(p, self) |
Return new |_Paragraph| instance appended to the sequence of
paragraphs contained in this text frame.
| add_paragraph | python | scanny/python-pptx | src/pptx/text/text.py | https://github.com/scanny/python-pptx/blob/master/src/pptx/text/text.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.