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_creator(self): """Add a `_new_{prop_name}()` method to the element class. This method creates a new, empty element of the correct type, having no attributes. """ creator = self._creator creator.__doc__ = ( 'Return a "loose", newly created ``<%s>`` element having no attri' "butes, text, or children." % self._nsptagname ) self._add_to_class(self._new_method_name, creator)
Add a `_new_{prop_name}()` method to the element class. This method creates a new, empty element of the correct type, having no attributes.
_add_creator
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_getter(self): """Add a read-only `{prop_name}` property to the parent element class. The property locates and returns this child element or `None` if not present. """ property_ = property(self._getter, None, None) # assign unconditionally to overwrite element name definition setattr(self._element_cls, self._prop_name, property_)
Add a read-only `{prop_name}` property to the parent element class. The property locates and returns this child element or `None` if not present.
_add_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_inserter(self): """Add an ``_insert_x()`` method to the element class for this child element.""" def _insert_child(obj: BaseOxmlElement, child: BaseOxmlElement): obj.insert_element_before(child, *self._successors) return child _insert_child.__doc__ = ( "Return the passed ``<%s>`` element after inserting it as a chil" "d in the correct sequence." % self._nsptagname ) self._add_to_class(self._insert_method_name, _insert_child)
Add an ``_insert_x()`` method to the element class for this child element.
_add_inserter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_list_getter(self): """ Add a read-only ``{prop_name}_lst`` property to the element class to retrieve a list of child elements matching this type. """ prop_name = f"{self._prop_name}_lst" property_ = property(self._list_getter, None, None) setattr(self._element_cls, prop_name, property_)
Add a read-only ``{prop_name}_lst`` property to the element class to retrieve a list of child elements matching this type.
_add_list_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_to_class(self, name: str, method: Callable[..., Any]): """Add `method` to the target class as `name`, unless `name` is already defined there.""" if hasattr(self._element_cls, name): return setattr(self._element_cls, name, method)
Add `method` to the target class as `name`, unless `name` is already defined there.
_add_to_class
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _creator(self) -> Callable[[BaseOxmlElement], BaseOxmlElement]: """Callable that creates a new, empty element of the child type, having no attributes.""" def new_child_element(obj: BaseOxmlElement): return OxmlElement(self._nsptagname) return new_child_element
Callable that creates a new, empty element of the child type, having no attributes.
_creator
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _getter(self) -> Callable[[BaseOxmlElement], BaseOxmlElement | None]: """Callable suitable for the "get" side of the property descriptor. This default getter returns the child element with matching tag name or |None| if not present. """ def get_child_element(obj: BaseOxmlElement) -> BaseOxmlElement | None: return obj.find(qn(self._nsptagname)) get_child_element.__doc__ = ( "``<%s>`` child element or |None| if not present." % self._nsptagname ) return get_child_element
Callable suitable for the "get" side of the property descriptor. This default getter returns the child element with matching tag name or |None| if not present.
_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _list_getter(self) -> Callable[[BaseOxmlElement], list[BaseOxmlElement]]: """Callable suitable for the "get" side of a list property descriptor.""" def get_child_element_list(obj: BaseOxmlElement) -> list[BaseOxmlElement]: return cast("list[BaseOxmlElement]", obj.findall(qn(self._nsptagname))) get_child_element_list.__doc__ = ( "A list containing each of the ``<%s>`` child elements, in the o" "rder they appear." % self._nsptagname ) return get_child_element_list
Callable suitable for the "get" side of a list property descriptor.
_list_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_get_or_change_to_method(self) -> None: """Add a `get_or_change_to_x()` method to the element class for this child element.""" def get_or_change_to_child(obj: BaseOxmlElement): child = getattr(obj, self._prop_name) if child is not None: return child remove_group_method = getattr(obj, self._remove_group_method_name) remove_group_method() add_method = getattr(obj, self._add_method_name) child = add_method() return child get_or_change_to_child.__doc__ = ( "Return the ``<%s>`` child, replacing any other group element if" " found." ) % self._nsptagname self._add_to_class(self._get_or_change_to_method_name, get_or_change_to_child)
Add a `get_or_change_to_x()` method to the element class for this child element.
_add_get_or_change_to_method
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _prop_name(self): """ Calculate property name from tag name, e.g. a:schemeClr -> schemeClr. """ if ":" in self._nsptagname: start = self._nsptagname.index(":") + 1 else: start = 0 return self._nsptagname[start:]
Calculate property name from tag name, e.g. a:schemeClr -> schemeClr.
_prop_name
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _getter(self) -> Callable[[BaseOxmlElement], BaseOxmlElement]: """Callable suitable for the "get" side of the property descriptor.""" def get_child_element(obj: BaseOxmlElement) -> BaseOxmlElement: child = obj.find(qn(self._nsptagname)) if child is None: raise InvalidXmlError( "required ``<%s>`` child element not present" % self._nsptagname ) return child get_child_element.__doc__ = "Required ``<%s>`` child element." % self._nsptagname return get_child_element
Callable suitable for the "get" side of the property descriptor.
_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_public_adder(self) -> None: """Add a public `.add_x()` method to the parent element class.""" def add_child(obj: BaseOxmlElement) -> BaseOxmlElement: private_add_method = getattr(obj, self._add_method_name) child = private_add_method() return child add_child.__doc__ = ( "Add a new ``<%s>`` child element unconditionally, inserted in t" "he correct sequence." % self._nsptagname ) self._add_to_class(self._public_add_method_name, add_child)
Add a public `.add_x()` method to the parent element class.
_add_public_adder
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_get_or_adder(self): """Add a `.get_or_add_x()` method to the element class for this child element.""" def get_or_add_child(obj: BaseOxmlElement) -> BaseOxmlElement: child = getattr(obj, self._prop_name) if child is None: add_method = getattr(obj, self._add_method_name) child = add_method() return child get_or_add_child.__doc__ = ( "Return the ``<%s>`` child element, newly added if not present." ) % self._nsptagname self._add_to_class(self._get_or_add_method_name, get_or_add_child)
Add a `.get_or_add_x()` method to the element class for this child element.
_add_get_or_adder
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_remover(self): """Add a `._remove_x()` method to the element class for this child element.""" def _remove_child(obj: BaseOxmlElement) -> None: obj.remove_all(self._nsptagname) _remove_child.__doc__ = f"Remove all `{self._nsptagname}` child elements." self._add_to_class(self._remove_method_name, _remove_child)
Add a `._remove_x()` method to the element class for this child element.
_add_remover
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_choice_getter(self): """Add a read-only `.{prop_name}` property to the element class. The property returns the present member of this group, or |None| if none are present. """ property_ = property(self._choice_getter, None, None) # assign unconditionally to overwrite element name definition setattr(self._element_cls, self._prop_name, property_)
Add a read-only `.{prop_name}` property to the element class. The property returns the present member of this group, or |None| if none are present.
_add_choice_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _add_group_remover(self): """Add a `._remove_eg_x()` method to the element class for this choice group.""" def _remove_choice_group(obj: BaseOxmlElement) -> None: for tagname in self._member_nsptagnames: obj.remove_all(tagname) _remove_choice_group.__doc__ = "Remove the current choice group child element if present." self._add_to_class(self._remove_choice_group_method_name, _remove_choice_group)
Add a `._remove_eg_x()` method to the element class for this choice group.
_add_group_remover
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def _choice_getter(self): """ Return a function object suitable for the "get" side of the property descriptor. """ def get_group_member_element(obj: BaseOxmlElement) -> BaseOxmlElement | None: return cast( "BaseOxmlElement | None", obj.first_child_found_in(*self._member_nsptagnames) ) get_group_member_element.__doc__ = ( "Return the child element belonging to this element group, or " "|None| if no member child is present." ) return get_group_member_element
Return a function object suitable for the "get" side of the property descriptor.
_choice_getter
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def first_child_found_in(self, *tagnames: str) -> _Element | None: """First child with tag in `tagnames`, or None if not found.""" for tagname in tagnames: child = self.find(qn(tagname)) if child is not None: return child return None
First child with tag in `tagnames`, or None if not found.
first_child_found_in
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def remove_all(self, *tagnames: str) -> None: """Remove child elements with tagname (e.g. "a:p") in `tagnames`.""" for tagname in tagnames: matching = self.findall(qn(tagname)) for child in matching: self.remove(child)
Remove child elements with tagname (e.g. "a:p") in `tagnames`.
remove_all
python
scanny/python-pptx
src/pptx/oxml/xmlchemy.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/xmlchemy.py
MIT
def parse_from_template(template_file_name: str): """Return an element loaded from the XML in the template file identified by `template_name`.""" thisdir = os.path.split(__file__)[0] filename = os.path.join(thisdir, "..", "templates", "%s.xml" % template_file_name) with open(filename, "rb") as f: xml = f.read() return parse_xml(xml)
Return an element loaded from the XML in the template file identified by `template_name`.
parse_from_template
python
scanny/python-pptx
src/pptx/oxml/__init__.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/__init__.py
MIT
def register_element_cls(nsptagname: str, cls: Type[BaseOxmlElement]): """Register `cls` to be constructed when oxml parser encounters element having `nsptag_name`. `nsptag_name` is a string of the form `nspfx:tagroot`, e.g. `"w:document"`. """ nsptag = NamespacePrefixedTag(nsptagname) namespace = element_class_lookup.get_namespace(nsptag.nsuri) namespace[nsptag.local_part] = cls
Register `cls` to be constructed when oxml parser encounters element having `nsptag_name`. `nsptag_name` is a string of the form `nspfx:tagroot`, e.g. `"w:document"`.
register_element_cls
python
scanny/python-pptx
src/pptx/oxml/__init__.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/__init__.py
MIT
def defRPr(self): """ ``<a:defRPr>`` great-great-grandchild element, added with its ancestors if not present. """ txPr = self.get_or_add_txPr() defRPr = txPr.defRPr return defRPr
``<a:defRPr>`` great-great-grandchild element, added with its ancestors if not present.
defRPr
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def orientation(self): """Value of `val` attribute of `c:scaling/c:orientation` grandchild element. Defaults to `ST_Orientation.MIN_MAX` if attribute or any ancestors are not present. """ orientation = self.scaling.orientation if orientation is None: return ST_Orientation.MIN_MAX return orientation.val
Value of `val` attribute of `c:scaling/c:orientation` grandchild element. Defaults to `ST_Orientation.MIN_MAX` if attribute or any ancestors are not present.
orientation
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def maximum(self): """ The float value of the ``<c:max>`` child element, or |None| if no max element is present. """ max = self.max if max is None: return None return max.val
The float value of the ``<c:max>`` child element, or |None| if no max element is present.
maximum
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def maximum(self, value): """ Set the value of the ``<c:max>`` child element to the float *value*, or remove the max element if *value* is |None|. """ self._remove_max() if value is None: return self._add_max(val=value)
Set the value of the ``<c:max>`` child element to the float *value*, or remove the max element if *value* is |None|.
maximum
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def minimum(self): """ The float value of the ``<c:min>`` child element, or |None| if no min element is present. """ min = self.min if min is None: return None return min.val
The float value of the ``<c:min>`` child element, or |None| if no min element is present.
minimum
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def minimum(self, value): """ Set the value of the ``<c:min>`` child element to the float *value*, or remove the min element if *value* is |None|. """ self._remove_min() if value is None: return self._add_min(val=value)
Set the value of the ``<c:min>`` child element to the float *value*, or remove the min element if *value* is |None|.
minimum
python
scanny/python-pptx
src/pptx/oxml/chart/axis.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/axis.py
MIT
def has_legend(self): """ True if this chart has a legend defined, False otherwise. """ legend = self.legend if legend is None: return False return True
True if this chart has a legend defined, False otherwise.
has_legend
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def has_legend(self, bool_value): """ Add, remove, or leave alone the ``<c:legend>`` child element depending on current state and *bool_value*. If *bool_value* is |True| and no ``<c:legend>`` element is present, a new default element is added. When |False|, any existing legend element is removed. """ if bool(bool_value) is False: self._remove_legend() else: if self.legend is None: self._add_legend()
Add, remove, or leave alone the ``<c:legend>`` child element depending on current state and *bool_value*. If *bool_value* is |True| and no ``<c:legend>`` element is present, a new default element is added. When |False|, any existing legend element is removed.
has_legend
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def date_1904(self): """ Return |True| if the `c:date1904` child element resolves truthy, |False| otherwise. This value indicates whether date number values are based on the 1900 or 1904 epoch. """ date1904 = self.date1904 if date1904 is None: return False return date1904.val
Return |True| if the `c:date1904` child element resolves truthy, |False| otherwise. This value indicates whether date number values are based on the 1900 or 1904 epoch.
date_1904
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def xlsx_part_rId(self): """ The string in the required ``r:id`` attribute of the `<c:externalData>` child, or |None| if no externalData element is present. """ externalData = self.externalData if externalData is None: return None return externalData.rId
The string in the required ``r:id`` attribute of the `<c:externalData>` child, or |None| if no externalData element is present.
xlsx_part_rId
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def _add_externalData(self): """ Always add a ``<c:autoUpdate val="0"/>`` child so auto-updating behavior is off by default. """ externalData = self._new_externalData() externalData._add_autoUpdate(val=False) self._insert_externalData(externalData) return externalData
Always add a ``<c:autoUpdate val="0"/>`` child so auto-updating behavior is off by default.
_add_externalData
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def iter_sers(self): """ Generate each of the `c:ser` elements in this chart, ordered first by the document order of the containing xChart element, then by their ordering within the xChart element (not necessarily document order). """ for xChart in self.iter_xCharts(): for ser in xChart.iter_sers(): yield ser
Generate each of the `c:ser` elements in this chart, ordered first by the document order of the containing xChart element, then by their ordering within the xChart element (not necessarily document order).
iter_sers
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def iter_xCharts(self): """ Generate each xChart child element in document. """ plot_tags = ( qn("c:area3DChart"), qn("c:areaChart"), qn("c:bar3DChart"), qn("c:barChart"), qn("c:bubbleChart"), qn("c:doughnutChart"), qn("c:line3DChart"), qn("c:lineChart"), qn("c:ofPieChart"), qn("c:pie3DChart"), qn("c:pieChart"), qn("c:radarChart"), qn("c:scatterChart"), qn("c:stockChart"), qn("c:surface3DChart"), qn("c:surfaceChart"), ) for child in self.iterchildren(): if child.tag not in plot_tags: continue yield child
Generate each xChart child element in document.
iter_xCharts
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def last_ser(self): """ Return the last `<c:ser>` element in the last xChart element, based on series order (not necessarily the same element as document order). """ last_xChart = self.xCharts[-1] sers = last_xChart.sers if not sers: return None return sers[-1]
Return the last `<c:ser>` element in the last xChart element, based on series order (not necessarily the same element as document order).
last_ser
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def next_idx(self): """ Return the next available `c:ser/c:idx` value within the scope of this chart, the maximum idx value found on existing series, incremented by one. """ idx_vals = [s.idx.val for s in self.sers] if not idx_vals: return 0 return max(idx_vals) + 1
Return the next available `c:ser/c:idx` value within the scope of this chart, the maximum idx value found on existing series, incremented by one.
next_idx
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def next_order(self): """ Return the next available `c:ser/c:order` value within the scope of this chart, the maximum order value found on existing series, incremented by one. """ order_vals = [s.order.val for s in self.sers] if not order_vals: return 0 return max(order_vals) + 1
Return the next available `c:ser/c:order` value within the scope of this chart, the maximum order value found on existing series, incremented by one.
next_order
python
scanny/python-pptx
src/pptx/oxml/chart/chart.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/chart.py
MIT
def get_or_add_rich(self): """ Return the `c:rich` descendant representing the text frame of the data label, newly created if not present. Any existing `c:strRef` element is removed along with its contents. """ tx = self.get_or_add_tx() tx._remove_strRef() return tx.get_or_add_rich()
Return the `c:rich` descendant representing the text frame of the data label, newly created if not present. Any existing `c:strRef` element is removed along with its contents.
get_or_add_rich
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def get_or_add_tx_rich(self): """ Return the `c:tx[c:rich]` subtree, newly created if not present. """ tx = self.get_or_add_tx() tx._remove_strRef() tx.get_or_add_rich() return tx
Return the `c:tx[c:rich]` subtree, newly created if not present.
get_or_add_tx_rich
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def new_dLbl(cls): """Return a newly created "loose" `c:dLbl` element. The `c:dLbl` element contains the same (fairly extensive) default subtree added by PowerPoint when an individual data label is customized in the UI. Note that the idx value must be set by the client. Failure to set the idx value will likely result in any changes not being visible and may result in a repair error on open. """ return parse_xml( "<c:dLbl %s>\n" ' <c:idx val="666"/>\n' " <c:spPr/>\n" " <c:txPr>\n" " <a:bodyPr/>\n" " <a:lstStyle/>\n" " <a:p>\n" " <a:pPr>\n" " <a:defRPr/>\n" " </a:pPr>\n" " </a:p>\n" " </c:txPr>\n" ' <c:showLegendKey val="0"/>\n' ' <c:showVal val="1"/>\n' ' <c:showCatName val="0"/>\n' ' <c:showSerName val="0"/>\n' ' <c:showPercent val="0"/>\n' ' <c:showBubbleSize val="0"/>\n' "</c:dLbl>" % nsdecls("c", "a") )
Return a newly created "loose" `c:dLbl` element. The `c:dLbl` element contains the same (fairly extensive) default subtree added by PowerPoint when an individual data label is customized in the UI. Note that the idx value must be set by the client. Failure to set the idx value will likely result in any changes not being visible and may result in a repair error on open.
new_dLbl
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def remove_tx_rich(self): """ Remove any `c:tx[c:rich]` child, or do nothing if not present. """ matches = self.xpath("c:tx[c:rich]") if not matches: return tx = matches[0] self.remove(tx)
Remove any `c:tx[c:rich]` child, or do nothing if not present.
remove_tx_rich
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def defRPr(self): """ ``<a:defRPr>`` great-great-grandchild element, added with its ancestors if not present. """ txPr = self.get_or_add_txPr() defRPr = txPr.defRPr return defRPr
``<a:defRPr>`` great-great-grandchild element, added with its ancestors if not present.
defRPr
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def get_dLbl_for_point(self, idx): """ Return the `c:dLbl` child representing the label for the data point at index *idx*. """ matches = self.xpath('c:dLbl[c:idx[@val="%d"]]' % idx) if matches: return matches[0] return None
Return the `c:dLbl` child representing the label for the data point at index *idx*.
get_dLbl_for_point
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def get_or_add_dLbl_for_point(self, idx): """ Return the `c:dLbl` element representing the label of the point at index *idx*. """ matches = self.xpath('c:dLbl[c:idx[@val="%d"]]' % idx) if matches: return matches[0] return self._insert_dLbl_in_sequence(idx)
Return the `c:dLbl` element representing the label of the point at index *idx*.
get_or_add_dLbl_for_point
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def new_dLbls(cls): """Return a newly created "loose" `c:dLbls` element.""" return parse_xml( "<c:dLbls %s>\n" ' <c:showLegendKey val="0"/>\n' ' <c:showVal val="0"/>\n' ' <c:showCatName val="0"/>\n' ' <c:showSerName val="0"/>\n' ' <c:showPercent val="0"/>\n' ' <c:showBubbleSize val="0"/>\n' ' <c:showLeaderLines val="1"/>\n' "</c:dLbls>" % nsdecls("c") )
Return a newly created "loose" `c:dLbls` element.
new_dLbls
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def _insert_dLbl_in_sequence(self, idx): """ Return a newly created `c:dLbl` element having `c:idx` child of *idx* and inserted in numeric sequence among the `c:dLbl` children of this element. """ new_dLbl = self._new_dLbl() new_dLbl.idx.val = idx dLbl = None for dLbl in self.dLbl_lst: if dLbl.idx_val > idx: dLbl.addprevious(new_dLbl) return new_dLbl if dLbl is not None: dLbl.addnext(new_dLbl) else: self.insert(0, new_dLbl) return new_dLbl
Return a newly created `c:dLbl` element having `c:idx` child of *idx* and inserted in numeric sequence among the `c:dLbl` children of this element.
_insert_dLbl_in_sequence
python
scanny/python-pptx
src/pptx/oxml/chart/datalabel.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/datalabel.py
MIT
def defRPr(self): """ `./c:txPr/a:p/a:pPr/a:defRPr` great-great-grandchild element, added with its ancestors if not present. """ txPr = self.get_or_add_txPr() defRPr = txPr.defRPr return defRPr
`./c:txPr/a:p/a:pPr/a:defRPr` great-great-grandchild element, added with its ancestors if not present.
defRPr
python
scanny/python-pptx
src/pptx/oxml/chart/legend.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/legend.py
MIT
def horz_offset(self): """ The float value in ./c:layout/c:manualLayout/c:x when ./c:layout/c:manualLayout/c:xMode@val == "factor". 0.0 if that XPath expression has no match. """ layout = self.layout if layout is None: return 0.0 return layout.horz_offset
The float value in ./c:layout/c:manualLayout/c:x when ./c:layout/c:manualLayout/c:xMode@val == "factor". 0.0 if that XPath expression has no match.
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/legend.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/legend.py
MIT
def horz_offset(self, offset): """ Set the value of ./c:layout/c:manualLayout/c:x@val to *offset* and ./c:layout/c:manualLayout/c:xMode@val to "factor". Remove ./c:layout/c:manualLayout if *offset* == 0. """ layout = self.get_or_add_layout() layout.horz_offset = offset
Set the value of ./c:layout/c:manualLayout/c:x@val to *offset* and ./c:layout/c:manualLayout/c:xMode@val to "factor". Remove ./c:layout/c:manualLayout if *offset* == 0.
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/legend.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/legend.py
MIT
def size_val(self): """ Return the value of `./c:size/@val`, specifying the size of this marker in points. Returns |None| if no `c:size` element is present or its val attribute is not present. """ size = self.size if size is None: return None return size.val
Return the value of `./c:size/@val`, specifying the size of this marker in points. Returns |None| if no `c:size` element is present or its val attribute is not present.
size_val
python
scanny/python-pptx
src/pptx/oxml/chart/marker.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/marker.py
MIT
def symbol_val(self): """ Return the value of `./c:symbol/@val`, specifying the shape of this marker. Returns |None| if no `c:symbol` element is present. """ symbol = self.symbol if symbol is None: return None return symbol.val
Return the value of `./c:symbol/@val`, specifying the shape of this marker. Returns |None| if no `c:symbol` element is present.
symbol_val
python
scanny/python-pptx
src/pptx/oxml/chart/marker.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/marker.py
MIT
def cat(self): """ Return the `c:cat` element of the first series in this xChart, or |None| if not present. """ cats = self.xpath("./c:ser[1]/c:cat") return cats[0] if cats else None
Return the `c:cat` element of the first series in this xChart, or |None| if not present.
cat
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def cat_pt_count(self): """ Return the value of the `c:ptCount` descendent of this xChart element. Its parent can be one of three element types. This value represents the true number of (leaf) categories, although they might not all have a corresponding `c:pt` sibling; a category with no label does not get a `c:pt` element. Returns 0 if there is no `c:ptCount` descendent. """ cat_ptCounts = self.xpath("./c:ser//c:cat//c:ptCount") if not cat_ptCounts: return 0 return cat_ptCounts[0].val
Return the value of the `c:ptCount` descendent of this xChart element. Its parent can be one of three element types. This value represents the true number of (leaf) categories, although they might not all have a corresponding `c:pt` sibling; a category with no label does not get a `c:pt` element. Returns 0 if there is no `c:ptCount` descendent.
cat_pt_count
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def cat_pts(self): """ Return a sequence representing the `c:pt` elements under the `c:cat` element of the first series in this xChart element. A category having no value will have no corresponding `c:pt` element; |None| will appear in that position in such cases. Items appear in `idx` order. Only those in the first ``<c:lvl>`` element are included in the case of multi-level categories. """ cat_pts = self.xpath("./c:ser[1]/c:cat//c:lvl[1]/c:pt") if not cat_pts: cat_pts = self.xpath("./c:ser[1]/c:cat//c:pt") cat_pt_dict = dict((pt.idx, pt) for pt in cat_pts) return [cat_pt_dict.get(idx, None) for idx in range(self.cat_pt_count)]
Return a sequence representing the `c:pt` elements under the `c:cat` element of the first series in this xChart element. A category having no value will have no corresponding `c:pt` element; |None| will appear in that position in such cases. Items appear in `idx` order. Only those in the first ``<c:lvl>`` element are included in the case of multi-level categories.
cat_pts
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def grouping_val(self): """ Return the value of the ``./c:grouping{val=?}`` attribute, taking defaults into account when items are not present. """ grouping = self.grouping if grouping is None: return ST_Grouping.STANDARD val = grouping.val if val is None: return ST_Grouping.STANDARD return val
Return the value of the ``./c:grouping{val=?}`` attribute, taking defaults into account when items are not present.
grouping_val
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def iter_sers(self): """ Generate each ``<c:ser>`` child element in this xChart in c:order/@val sequence (not document or c:idx order). """ def ser_order(ser): return ser.order.val return (ser for ser in sorted(self.xpath("./c:ser"), key=ser_order))
Generate each ``<c:ser>`` child element in this xChart in c:order/@val sequence (not document or c:idx order).
iter_sers
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def grouping_val(self): """ Return the value of the ``./c:grouping{val=?}`` attribute, taking defaults into account when items are not present. """ grouping = self.grouping if grouping is None: return ST_Grouping.CLUSTERED val = grouping.val if val is None: return ST_Grouping.CLUSTERED return val
Return the value of the ``./c:grouping{val=?}`` attribute, taking defaults into account when items are not present.
grouping_val
python
scanny/python-pptx
src/pptx/oxml/chart/plot.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/plot.py
MIT
def new_dPt(cls): """ Return a newly created "loose" `c:dPt` element containing its default subtree. """ dPt = OxmlElement("c:dPt") dPt.append(OxmlElement("c:idx")) return dPt
Return a newly created "loose" `c:dPt` element containing its default subtree.
new_dPt
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def ptCount_val(self): """ Return the value of `./c:numRef/c:numCache/c:ptCount/@val`, specifying how many `c:pt` elements are in this numeric data cache. Returns 0 if no `c:ptCount` element is present, as this is the least disruptive way to degrade when no cached point data is available. This situation is not expected, but is valid according to the schema. """ results = self.xpath(".//c:ptCount/@val") return int(results[0]) if results else 0
Return the value of `./c:numRef/c:numCache/c:ptCount/@val`, specifying how many `c:pt` elements are in this numeric data cache. Returns 0 if no `c:ptCount` element is present, as this is the least disruptive way to degrade when no cached point data is available. This situation is not expected, but is valid according to the schema.
ptCount_val
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def pt_v(self, idx): """ Return the Y value for data point *idx* in this cache, or None if no value is present for that data point. """ results = self.xpath(".//c:pt[@idx=%d]" % idx) return results[0].value if results else None
Return the Y value for data point *idx* in this cache, or None if no value is present for that data point.
pt_v
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def bubbleSize_ptCount_val(self): """ Return the number of bubble size values as reflected in the `val` attribute of `./c:bubbleSize//c:ptCount`, or 0 if not present. """ vals = self.xpath("./c:bubbleSize//c:ptCount/@val") if not vals: return 0 return int(vals[0])
Return the number of bubble size values as reflected in the `val` attribute of `./c:bubbleSize//c:ptCount`, or 0 if not present.
bubbleSize_ptCount_val
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def cat_ptCount_val(self): """ Return the number of categories as reflected in the `val` attribute of `./c:cat//c:ptCount`, or 0 if not present. """ vals = self.xpath("./c:cat//c:ptCount/@val") if not vals: return 0 return int(vals[0])
Return the number of categories as reflected in the `val` attribute of `./c:cat//c:ptCount`, or 0 if not present.
cat_ptCount_val
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def get_dLbl(self, idx): """ Return the `c:dLbl` element representing the label for the data point at offset *idx* in this series, or |None| if not present. """ dLbls = self.dLbls if dLbls is None: return None return dLbls.get_dLbl_for_point(idx)
Return the `c:dLbl` element representing the label for the data point at offset *idx* in this series, or |None| if not present.
get_dLbl
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def get_or_add_dPt_for_point(self, idx): """ Return the `c:dPt` child representing the visual properties of the data point at index *idx*. """ matches = self.xpath('c:dPt[c:idx[@val="%d"]]' % idx) if matches: return matches[0] dPt = self._add_dPt() dPt.idx.val = idx return dPt
Return the `c:dPt` child representing the visual properties of the data point at index *idx*.
get_or_add_dPt_for_point
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def xVal_ptCount_val(self): """ Return the number of X values as reflected in the `val` attribute of `./c:xVal//c:ptCount`, or 0 if not present. """ vals = self.xpath("./c:xVal//c:ptCount/@val") if not vals: return 0 return int(vals[0])
Return the number of X values as reflected in the `val` attribute of `./c:xVal//c:ptCount`, or 0 if not present.
xVal_ptCount_val
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def yVal_ptCount_val(self): """ Return the number of Y values as reflected in the `val` attribute of `./c:yVal//c:ptCount`, or 0 if not present. """ vals = self.xpath("./c:yVal//c:ptCount/@val") if not vals: return 0 return int(vals[0])
Return the number of Y values as reflected in the `val` attribute of `./c:yVal//c:ptCount`, or 0 if not present.
yVal_ptCount_val
python
scanny/python-pptx
src/pptx/oxml/chart/series.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/series.py
MIT
def horz_offset(self): """ The float value in ./c:manualLayout/c:x when c:layout/c:manualLayout/c:xMode@val == "factor". 0.0 if that XPath expression finds no match. """ manualLayout = self.manualLayout if manualLayout is None: return 0.0 return manualLayout.horz_offset
The float value in ./c:manualLayout/c:x when c:layout/c:manualLayout/c:xMode@val == "factor". 0.0 if that XPath expression finds no match.
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def horz_offset(self, offset): """ Set the value of ./c:manualLayout/c:x@val to *offset* and ./c:manualLayout/c:xMode@val to "factor". Remove ./c:manualLayout if *offset* == 0. """ if offset == 0.0: self._remove_manualLayout() return manualLayout = self.get_or_add_manualLayout() manualLayout.horz_offset = offset
Set the value of ./c:manualLayout/c:x@val to *offset* and ./c:manualLayout/c:xMode@val to "factor". Remove ./c:manualLayout if *offset* == 0.
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def horz_offset(self): """ The float value in ./c:x@val when ./c:xMode@val == "factor". 0.0 when ./c:x is not present or ./c:xMode@val != "factor". """ x, xMode = self.x, self.xMode if x is None or xMode is None or xMode.val != ST_LayoutMode.FACTOR: return 0.0 return x.val
The float value in ./c:x@val when ./c:xMode@val == "factor". 0.0 when ./c:x is not present or ./c:xMode@val != "factor".
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def horz_offset(self, offset): """ Set the value of ./c:x@val to *offset* and ./c:xMode@val to "factor". """ self.get_or_add_xMode().val = ST_LayoutMode.FACTOR self.get_or_add_x().val = offset
Set the value of ./c:x@val to *offset* and ./c:xMode@val to "factor".
horz_offset
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def get_or_add_tx_rich(self): """Return `c:tx/c:rich`, newly created if not present. Return the `c:rich` grandchild at `c:tx/c:rich`. Both the `c:tx` and `c:rich` elements are created if not already present. Any `c:tx/c:strRef` element is removed. (Such an element would contain a cell reference for the axis title text in the chart's Excel worksheet.) """ tx = self.get_or_add_tx() tx._remove_strRef() return tx.get_or_add_rich()
Return `c:tx/c:rich`, newly created if not present. Return the `c:rich` grandchild at `c:tx/c:rich`. Both the `c:tx` and `c:rich` elements are created if not already present. Any `c:tx/c:strRef` element is removed. (Such an element would contain a cell reference for the axis title text in the chart's Excel worksheet.)
get_or_add_tx_rich
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def tx_rich(self): """Return `c:tx/c:rich` or |None| if not present.""" richs = self.xpath("c:tx/c:rich") if not richs: return None return richs[0]
Return `c:tx/c:rich` or |None| if not present.
tx_rich
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def new_title(): """Return "loose" `c:title` element containing default children.""" return parse_xml( "<c:title %s>" " <c:layout/>" ' <c:overlay val="0"/>' "</c:title>" % nsdecls("c") )
Return "loose" `c:title` element containing default children.
new_title
python
scanny/python-pptx
src/pptx/oxml/chart/shared.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/chart/shared.py
MIT
def add_lumMod(self, value): """ Return a newly added <a:lumMod> child element. """ lumMod = self._add_lumMod() lumMod.val = value return lumMod
Return a newly added <a:lumMod> child element.
add_lumMod
python
scanny/python-pptx
src/pptx/oxml/dml/color.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/color.py
MIT
def add_lumOff(self, value): """ Return a newly added <a:lumOff> child element. """ lumOff = self._add_lumOff() lumOff.val = value return lumOff
Return a newly added <a:lumOff> child element.
add_lumOff
python
scanny/python-pptx
src/pptx/oxml/dml/color.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/color.py
MIT
def clear_lum(self): """ Return self after removing any <a:lumMod> and <a:lumOff> child elements. """ self._remove_lumMod() self._remove_lumOff() return self
Return self after removing any <a:lumMod> and <a:lumOff> child elements.
clear_lum
python
scanny/python-pptx
src/pptx/oxml/dml/color.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/color.py
MIT
def crop(self, cropping): """ Set `a:srcRect` child to crop according to *cropping* values. """ srcRect = self._add_srcRect() srcRect.l, srcRect.t, srcRect.r, srcRect.b = cropping
Set `a:srcRect` child to crop according to *cropping* values.
crop
python
scanny/python-pptx
src/pptx/oxml/dml/fill.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/fill.py
MIT
def new_gradFill(cls): """Return newly-created "loose" default gradient subtree.""" return parse_xml( '<a:gradFill %s rotWithShape="1">\n' " <a:gsLst>\n" ' <a:gs pos="0">\n' ' <a:schemeClr val="accent1">\n' ' <a:tint val="100000"/>\n' ' <a:shade val="100000"/>\n' ' <a:satMod val="130000"/>\n' " </a:schemeClr>\n" " </a:gs>\n" ' <a:gs pos="100000">\n' ' <a:schemeClr val="accent1">\n' ' <a:tint val="50000"/>\n' ' <a:shade val="100000"/>\n' ' <a:satMod val="350000"/>\n' " </a:schemeClr>\n" " </a:gs>\n" " </a:gsLst>\n" ' <a:lin scaled="0"/>\n' "</a:gradFill>\n" % nsdecls("a") )
Return newly-created "loose" default gradient subtree.
new_gradFill
python
scanny/python-pptx
src/pptx/oxml/dml/fill.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/fill.py
MIT
def new_gsLst(cls): """Return newly-created "loose" default stop-list subtree. An `a:gsLst` element must have at least two `a:gs` children. These are the default from the PowerPoint built-in "White" template. """ return parse_xml( "<a:gsLst %s>\n" ' <a:gs pos="0">\n' ' <a:schemeClr val="accent1">\n' ' <a:tint val="100000"/>\n' ' <a:shade val="100000"/>\n' ' <a:satMod val="130000"/>\n' " </a:schemeClr>\n" " </a:gs>\n" ' <a:gs pos="100000">\n' ' <a:schemeClr val="accent1">\n' ' <a:tint val="50000"/>\n' ' <a:shade val="100000"/>\n' ' <a:satMod val="350000"/>\n' " </a:schemeClr>\n" " </a:gs>\n" "</a:gsLst>\n" % nsdecls("a") )
Return newly-created "loose" default stop-list subtree. An `a:gsLst` element must have at least two `a:gs` children. These are the default from the PowerPoint built-in "White" template.
new_gsLst
python
scanny/python-pptx
src/pptx/oxml/dml/fill.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/fill.py
MIT
def _new_bgClr(self): """Override default to add minimum subtree.""" xml = ("<a:bgClr %s>\n" ' <a:srgbClr val="FFFFFF"/>\n' "</a:bgClr>\n") % nsdecls("a") bgClr = parse_xml(xml) return bgClr
Override default to add minimum subtree.
_new_bgClr
python
scanny/python-pptx
src/pptx/oxml/dml/fill.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/fill.py
MIT
def _new_fgClr(self): """Override default to add minimum subtree.""" xml = ("<a:fgClr %s>\n" ' <a:srgbClr val="000000"/>\n' "</a:fgClr>\n") % nsdecls("a") fgClr = parse_xml(xml) return fgClr
Override default to add minimum subtree.
_new_fgClr
python
scanny/python-pptx
src/pptx/oxml/dml/fill.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/dml/fill.py
MIT
def add_lnTo(self, x: Length, y: Length) -> CT_Path2DLineTo: """Return a newly created `a:lnTo` subtree with end point *(x, y)*. The new `a:lnTo` element is appended to this `a:path` element. """ lnTo = self._add_lnTo() pt = lnTo._add_pt() pt.x, pt.y = x, y return lnTo
Return a newly created `a:lnTo` subtree with end point *(x, y)*. The new `a:lnTo` element is appended to this `a:path` element.
add_lnTo
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def add_moveTo(self, x: Length, y: Length): """Return a newly created `a:moveTo` subtree with point `(x, y)`. The new `a:moveTo` element is appended to this `a:path` element. """ moveTo = self._add_moveTo() pt = moveTo._add_pt() pt.x, pt.y = x, y return moveTo
Return a newly created `a:moveTo` subtree with point `(x, y)`. The new `a:moveTo` element is appended to this `a:path` element.
add_moveTo
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def add_path(self, w: Length, h: Length): """Return a newly created `a:path` child element.""" path = self._add_path() path.w, path.h = w, h return path
Return a newly created `a:path` child element.
add_path
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def gd_lst(self) -> list[CT_GeomGuide]: """Sequence of `a:gd` element children of `a:avLst`. Empty if none are present.""" avLst = self.avLst if avLst is None: return [] return avLst.gd_lst
Sequence of `a:gd` element children of `a:avLst`. Empty if none are present.
gd_lst
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def rewrite_guides(self, guides: list[tuple[str, int]]): """Replace any `a:gd` element children of `a:avLst` with ones forme from `guides`.""" self._remove_avLst() avLst = self._add_avLst() for name, val in guides: gd = avLst._add_gd() gd.name = name gd.fmla = "val %d" % val
Replace any `a:gd` element children of `a:avLst` with ones forme from `guides`.
rewrite_guides
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def is_autoshape(self): """True if this shape is an auto shape. A shape is an auto shape if it has a `a:prstGeom` element and does not have a txBox="1" attribute on cNvSpPr. """ prstGeom = self.prstGeom if prstGeom is None: return False return self.nvSpPr.cNvSpPr.txBox is not True
True if this shape is an auto shape. A shape is an auto shape if it has a `a:prstGeom` element and does not have a txBox="1" attribute on cNvSpPr.
is_autoshape
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def new_autoshape_sp( id_: int, name: str, prst: str, left: int, top: int, width: int, height: int ) -> CT_Shape: """Return a new `p:sp` element tree configured as a base auto shape.""" xml = ( "<p:sp %s>\n" " <p:nvSpPr>\n" ' <p:cNvPr id="%s" name="%s"/>\n' " <p:cNvSpPr/>\n" " <p:nvPr/>\n" " </p:nvSpPr>\n" " <p:spPr>\n" " <a:xfrm>\n" ' <a:off x="%s" y="%s"/>\n' ' <a:ext cx="%s" cy="%s"/>\n' " </a:xfrm>\n" ' <a:prstGeom prst="%s">\n' " <a:avLst/>\n" " </a:prstGeom>\n" " </p:spPr>\n" " <p:style>\n" ' <a:lnRef idx="1">\n' ' <a:schemeClr val="accent1"/>\n' " </a:lnRef>\n" ' <a:fillRef idx="3">\n' ' <a:schemeClr val="accent1"/>\n' " </a:fillRef>\n" ' <a:effectRef idx="2">\n' ' <a:schemeClr val="accent1"/>\n' " </a:effectRef>\n" ' <a:fontRef idx="minor">\n' ' <a:schemeClr val="lt1"/>\n' " </a:fontRef>\n" " </p:style>\n" " <p:txBody>\n" ' <a:bodyPr rtlCol="0" anchor="ctr"/>\n' " <a:lstStyle/>\n" " <a:p>\n" ' <a:pPr algn="ctr"/>\n' " </a:p>\n" " </p:txBody>\n" "</p:sp>" % (nsdecls("a", "p"), "%d", "%s", "%d", "%d", "%d", "%d", "%s") ) % (id_, name, left, top, width, height, prst) return cast(CT_Shape, parse_xml(xml))
Return a new `p:sp` element tree configured as a base auto shape.
new_autoshape_sp
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def new_freeform_sp(shape_id: int, name: str, x: int, y: int, cx: int, cy: int): """Return new `p:sp` element tree configured as freeform shape. The returned shape has a `a:custGeom` subtree but no paths in its path list. """ xml = ( "<p:sp %s>\n" " <p:nvSpPr>\n" ' <p:cNvPr id="%s" name="%s"/>\n' " <p:cNvSpPr/>\n" " <p:nvPr/>\n" " </p:nvSpPr>\n" " <p:spPr>\n" " <a:xfrm>\n" ' <a:off x="%s" y="%s"/>\n' ' <a:ext cx="%s" cy="%s"/>\n' " </a:xfrm>\n" " <a:custGeom>\n" " <a:avLst/>\n" " <a:gdLst/>\n" " <a:ahLst/>\n" " <a:cxnLst/>\n" ' <a:rect l="l" t="t" r="r" b="b"/>\n' " <a:pathLst/>\n" " </a:custGeom>\n" " </p:spPr>\n" " <p:style>\n" ' <a:lnRef idx="1">\n' ' <a:schemeClr val="accent1"/>\n' " </a:lnRef>\n" ' <a:fillRef idx="3">\n' ' <a:schemeClr val="accent1"/>\n' " </a:fillRef>\n" ' <a:effectRef idx="2">\n' ' <a:schemeClr val="accent1"/>\n' " </a:effectRef>\n" ' <a:fontRef idx="minor">\n' ' <a:schemeClr val="lt1"/>\n' " </a:fontRef>\n" " </p:style>\n" " <p:txBody>\n" ' <a:bodyPr rtlCol="0" anchor="ctr"/>\n' " <a:lstStyle/>\n" " <a:p>\n" ' <a:pPr algn="ctr"/>\n' " </a:p>\n" " </p:txBody>\n" "</p:sp>" % (nsdecls("a", "p"), "%d", "%s", "%d", "%d", "%d", "%d") ) % (shape_id, name, x, y, cx, cy) return cast(CT_Shape, parse_xml(xml))
Return new `p:sp` element tree configured as freeform shape. The returned shape has a `a:custGeom` subtree but no paths in its path list.
new_freeform_sp
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def new_placeholder_sp( id_: int, name: str, ph_type: PP_PLACEHOLDER, orient: str, sz, idx ) -> CT_Shape: """Return a new `p:sp` element tree configured as a placeholder shape.""" sp = cast( CT_Shape, parse_xml( f"<p:sp {nsdecls('a', 'p')}>\n" f" <p:nvSpPr>\n" f' <p:cNvPr id="{id_}" name="{name}"/>\n' f" <p:cNvSpPr>\n" f' <a:spLocks noGrp="1"/>\n' f" </p:cNvSpPr>\n" f" <p:nvPr/>\n" f" </p:nvSpPr>\n" f" <p:spPr/>\n" f"</p:sp>" ), ) ph = sp.nvSpPr.nvPr.get_or_add_ph() ph.type = ph_type ph.idx = idx ph.orient = orient ph.sz = sz placeholder_types_that_have_a_text_frame = ( PP_PLACEHOLDER.TITLE, PP_PLACEHOLDER.CENTER_TITLE, PP_PLACEHOLDER.SUBTITLE, PP_PLACEHOLDER.BODY, PP_PLACEHOLDER.OBJECT, ) if ph_type in placeholder_types_that_have_a_text_frame: sp.append(CT_TextBody.new()) return sp
Return a new `p:sp` element tree configured as a placeholder shape.
new_placeholder_sp
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def new_textbox_sp(id_, name, left, top, width, height): """Return a new `p:sp` element tree configured as a base textbox shape.""" tmpl = CT_Shape._textbox_sp_tmpl() xml = tmpl % (id_, name, left, top, width, height) sp = parse_xml(xml) return sp
Return a new `p:sp` element tree configured as a base textbox shape.
new_textbox_sp
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def prst(self): """Value of `prst` attribute of `a:prstGeom` element or |None| if not present.""" prstGeom = self.prstGeom if prstGeom is None: return None return prstGeom.prst
Value of `prst` attribute of `a:prstGeom` element or |None| if not present.
prst
python
scanny/python-pptx
src/pptx/oxml/shapes/autoshape.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/autoshape.py
MIT
def new_cxnSp( cls, id_: int, name: str, prst: str, x: int, y: int, cx: int, cy: int, flipH: bool, flipV: bool, ) -> CT_Connector: """Return a new `p:cxnSp` element tree configured as a base connector.""" flip = (' flipH="1"' if flipH else "") + (' flipV="1"' if flipV else "") return cast( CT_Connector, parse_xml( f"<p:cxnSp {nsdecls('a', 'p')}>\n" f" <p:nvCxnSpPr>\n" f' <p:cNvPr id="{id_}" name="{name}"/>\n' f" <p:cNvCxnSpPr/>\n" f" <p:nvPr/>\n" f" </p:nvCxnSpPr>\n" f" <p:spPr>\n" f" <a:xfrm{flip}>\n" f' <a:off x="{x}" y="{y}"/>\n' f' <a:ext cx="{cx}" cy="{cy}"/>\n' f" </a:xfrm>\n" f' <a:prstGeom prst="{prst}">\n' f" <a:avLst/>\n" f" </a:prstGeom>\n" f" </p:spPr>\n" f" <p:style>\n" f' <a:lnRef idx="2">\n' f' <a:schemeClr val="accent1"/>\n' f" </a:lnRef>\n" f' <a:fillRef idx="0">\n' f' <a:schemeClr val="accent1"/>\n' f" </a:fillRef>\n" f' <a:effectRef idx="1">\n' f' <a:schemeClr val="accent1"/>\n' f" </a:effectRef>\n" f' <a:fontRef idx="minor">\n' f' <a:schemeClr val="tx1"/>\n' f" </a:fontRef>\n" f" </p:style>\n" f"</p:cxnSp>" ), )
Return a new `p:cxnSp` element tree configured as a base connector.
new_cxnSp
python
scanny/python-pptx
src/pptx/oxml/shapes/connector.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/connector.py
MIT
def _oleObj(self) -> CT_OleObject | None: """Optional `p:oleObj` element contained in this `p:graphicData' element. Returns `None` when this graphic-data element does not enclose an OLE object. Note that this returns the last `p:oleObj` element found. There can be more than one `p:oleObj` element because an `mc.AlternateContent` element may appear as the child of `p:graphicData` and that alternate-content subtree can contain multiple compatibility choices. The last one should suit best for reading purposes because it contains the lowest common denominator. """ oleObjs = cast("list[CT_OleObject]", self.xpath(".//p:oleObj")) return oleObjs[-1] if oleObjs else None
Optional `p:oleObj` element contained in this `p:graphicData' element. Returns `None` when this graphic-data element does not enclose an OLE object. Note that this returns the last `p:oleObj` element found. There can be more than one `p:oleObj` element because an `mc.AlternateContent` element may appear as the child of `p:graphicData` and that alternate-content subtree can contain multiple compatibility choices. The last one should suit best for reading purposes because it contains the lowest common denominator.
_oleObj
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def chart_rId(self) -> str | None: """The `rId` attribute of the `c:chart` great-grandchild element. |None| if not present. """ chart = self.chart if chart is None: return None return chart.rId
The `rId` attribute of the `c:chart` great-grandchild element. |None| if not present.
chart_rId
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def new_chart_graphicFrame( cls, id_: int, name: str, rId: str, x: int, y: int, cx: int, cy: int ) -> CT_GraphicalObjectFrame: """Return a `p:graphicFrame` element tree populated with a chart element.""" graphicFrame = CT_GraphicalObjectFrame.new_graphicFrame(id_, name, x, y, cx, cy) graphicData = graphicFrame.graphic.graphicData graphicData.uri = GRAPHIC_DATA_URI_CHART graphicData.append(CT_Chart.new_chart(rId)) return graphicFrame
Return a `p:graphicFrame` element tree populated with a chart element.
new_chart_graphicFrame
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def new_graphicFrame( cls, id_: int, name: str, x: int, y: int, cx: int, cy: int ) -> CT_GraphicalObjectFrame: """Return a new `p:graphicFrame` element tree suitable for containing a table or chart. Note that a graphicFrame element is not a valid shape until it contains a graphical object such as a table. """ return cast( CT_GraphicalObjectFrame, parse_xml( f"<p:graphicFrame {nsdecls('a', 'p')}>\n" f" <p:nvGraphicFramePr>\n" f' <p:cNvPr id="{id_}" name="{name}"/>\n' f" <p:cNvGraphicFramePr>\n" f' <a:graphicFrameLocks noGrp="1"/>\n' f" </p:cNvGraphicFramePr>\n" f" <p:nvPr/>\n" f" </p:nvGraphicFramePr>\n" f" <p:xfrm>\n" f' <a:off x="{x}" y="{y}"/>\n' f' <a:ext cx="{cx}" cy="{cy}"/>\n' f" </p:xfrm>\n" f" <a:graphic>\n" f" <a:graphicData/>\n" f" </a:graphic>\n" f"</p:graphicFrame>" ), )
Return a new `p:graphicFrame` element tree suitable for containing a table or chart. Note that a graphicFrame element is not a valid shape until it contains a graphical object such as a table.
new_graphicFrame
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def new_ole_object_graphicFrame( cls, id_: int, name: str, ole_object_rId: str, progId: str, icon_rId: str, x: int, y: int, cx: int, cy: int, imgW: int, imgH: int, ) -> CT_GraphicalObjectFrame: """Return newly-created `p:graphicFrame` for embedded OLE-object. `ole_object_rId` identifies the relationship to the OLE-object part. `progId` is a str identifying the object-type in terms of the application (program) used to open it. This becomes an attribute of the same name in the `p:oleObj` element. `icon_rId` identifies the relationship to an image part used to display the OLE-object as an icon (vs. a preview). """ return cast( CT_GraphicalObjectFrame, parse_xml( f"<p:graphicFrame {nsdecls('a', 'p', 'r')}>\n" f" <p:nvGraphicFramePr>\n" f' <p:cNvPr id="{id_}" name="{name}"/>\n' f" <p:cNvGraphicFramePr>\n" f' <a:graphicFrameLocks noGrp="1"/>\n' f" </p:cNvGraphicFramePr>\n" f" <p:nvPr/>\n" f" </p:nvGraphicFramePr>\n" f" <p:xfrm>\n" f' <a:off x="{x}" y="{y}"/>\n' f' <a:ext cx="{cx}" cy="{cy}"/>\n' f" </p:xfrm>\n" f" <a:graphic>\n" f" <a:graphicData" f' uri="http://schemas.openxmlformats.org/presentationml/2006/ole">\n' f' <p:oleObj showAsIcon="1"' f' r:id="{ole_object_rId}"' f' imgW="{imgW}"' f' imgH="{imgH}"' f' progId="{progId}">\n' f" <p:embed/>\n" f" <p:pic>\n" f" <p:nvPicPr>\n" f' <p:cNvPr id="0" name=""/>\n' f" <p:cNvPicPr/>\n" f" <p:nvPr/>\n" f" </p:nvPicPr>\n" f" <p:blipFill>\n" f' <a:blip r:embed="{icon_rId}"/>\n' f" <a:stretch>\n" f" <a:fillRect/>\n" f" </a:stretch>\n" f" </p:blipFill>\n" f" <p:spPr>\n" f" <a:xfrm>\n" f' <a:off x="{x}" y="{y}"/>\n' f' <a:ext cx="{cx}" cy="{cy}"/>\n' f" </a:xfrm>\n" f' <a:prstGeom prst="rect">\n' f" <a:avLst/>\n" f" </a:prstGeom>\n" f" </p:spPr>\n" f" </p:pic>\n" f" </p:oleObj>\n" f" </a:graphicData>\n" f" </a:graphic>\n" f"</p:graphicFrame>" ), )
Return newly-created `p:graphicFrame` for embedded OLE-object. `ole_object_rId` identifies the relationship to the OLE-object part. `progId` is a str identifying the object-type in terms of the application (program) used to open it. This becomes an attribute of the same name in the `p:oleObj` element. `icon_rId` identifies the relationship to an image part used to display the OLE-object as an icon (vs. a preview).
new_ole_object_graphicFrame
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def new_table_graphicFrame( cls, id_: int, name: str, rows: int, cols: int, x: int, y: int, cx: int, cy: int ) -> CT_GraphicalObjectFrame: """Return a `p:graphicFrame` element tree populated with a table element.""" graphicFrame = cls.new_graphicFrame(id_, name, x, y, cx, cy) graphicFrame.graphic.graphicData.uri = GRAPHIC_DATA_URI_TABLE graphicFrame.graphic.graphicData.append(CT_Table.new_tbl(rows, cols, cx, cy)) return graphicFrame
Return a `p:graphicFrame` element tree populated with a table element.
new_table_graphicFrame
python
scanny/python-pptx
src/pptx/oxml/shapes/graphfrm.py
https://github.com/scanny/python-pptx/blob/master/src/pptx/oxml/shapes/graphfrm.py
MIT
def add_autoshape( self, id_: int, name: str, prst: str, x: int, y: int, cx: int, cy: int ) -> CT_Shape: """Return new `p:sp` appended to the group/shapetree with specified attributes.""" sp = CT_Shape.new_autoshape_sp(id_, name, prst, x, y, cx, cy) self.insert_element_before(sp, "p:extLst") return sp
Return new `p:sp` appended to the group/shapetree with specified attributes.
add_autoshape
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