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

Method default_for

src/docx/oxml/styles.py:292–300  ·  view source on GitHub ↗

Return `w:style[@w:type="*{style_type}*][-1]` or |None| if not found.

(self, style_type)

Source from the content-addressed store, hash-verified

290 return style
291
292 def default_for(self, style_type):
293 """Return `w:style[@w:type="*{style_type}*][-1]` or |None| if not found."""
294 default_styles_for_type = [
295 s for s in self._iter_styles() if s.type == style_type and s.default
296 ]
297 if not default_styles_for_type:
298 return None
299 # spec calls for last default in document order
300 return default_styles_for_type[-1]
301
302 def get_by_id(self, styleId: str) -> CT_Style | None:
303 """`w:style` child where @styleId = `styleId`.

Callers 1

defaultMethod · 0.80

Calls 1

_iter_stylesMethod · 0.95

Tested by

no test coverage detected