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

Method _get_style_id_from_style

src/docx/styles/styles.py:127–136  ·  view source on GitHub ↗

Id of `style`, or |None| if it is the default style of `style_type`. Raises |ValueError| if style is not of `style_type`.

(self, style: BaseStyle, style_type: WD_STYLE_TYPE)

Source from the content-addressed store, hash-verified

125 return self._get_style_id_from_style(self[style_name], style_type)
126
127 def _get_style_id_from_style(self, style: BaseStyle, style_type: WD_STYLE_TYPE) -> str | None:
128 """Id of `style`, or |None| if it is the default style of `style_type`.
129
130 Raises |ValueError| if style is not of `style_type`.
131 """
132 if style.type != style_type:
133 raise ValueError("assigned style is type %s, need type %s" % (style.type, style_type))
134 if style == self.default(style_type):
135 return None
136 return style.style_id

Calls 1

defaultMethod · 0.95