MCPcopy Index your code
hub / github.com/python-openxml/python-docx / get_by_name

Method get_by_name

src/docx/oxml/styles.py:310–316  ·  view source on GitHub ↗

`w:style` child with `w:name` grandchild having value `name`. |None| if not found.

(self, name: str)

Source from the content-addressed store, hash-verified

308 return next(iter(self.xpath(xpath)), None)
309
310 def get_by_name(self, name: str) -> CT_Style | None:
311 """`w:style` child with `w:name` grandchild having value `name`.
312
313 |None| if not found.
314 """
315 xpath = 'w:style[w:name/@w:val="%s"]' % name
316 return next(iter(self.xpath(xpath)), None)
317
318 def _iter_styles(self):
319 """Generate each of the `w:style` child elements in document order."""

Callers 2

__getitem__Method · 0.45
__getitem__Method · 0.45

Calls 1

xpathMethod · 0.80

Tested by

no test coverage detected