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

Method get_by_id

src/docx/styles/styles.py:75–83  ·  view source on GitHub ↗

Return the style of `style_type` matching `style_id`. Returns the default for `style_type` if `style_id` is not found or is |None|, or if the style having `style_id` is not of `style_type`.

(self, style_id: str | None, style_type: WD_STYLE_TYPE)

Source from the content-addressed store, hash-verified

73 return StyleFactory(style)
74
75 def get_by_id(self, style_id: str | None, style_type: WD_STYLE_TYPE):
76 """Return the style of `style_type` matching `style_id`.
77
78 Returns the default for `style_type` if `style_id` is not found or is |None|, or
79 if the style having `style_id` is not of `style_type`.
80 """
81 if style_id is None:
82 return self.default(style_type)
83 return self._get_by_id(style_id, style_type)
84
85 def get_style_id(self, style_or_name, style_type):
86 """Return the id of the style corresponding to `style_or_name`, or |None| if

Callers 5

get_styleMethod · 0.45
__getitem__Method · 0.45
_get_by_idMethod · 0.45

Calls 2

defaultMethod · 0.95
_get_by_idMethod · 0.95