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

Function StyleFactory

src/docx/styles/style.py:15–24  ·  view source on GitHub ↗

Return `Style` object of appropriate |BaseStyle| subclass for `style_elm`.

(style_elm: CT_Style)

Source from the content-addressed store, hash-verified

13
14
15def StyleFactory(style_elm: CT_Style) -> BaseStyle:
16 """Return `Style` object of appropriate |BaseStyle| subclass for `style_elm`."""
17 style_cls: Type[BaseStyle] = {
18 WD_STYLE_TYPE.PARAGRAPH: ParagraphStyle,
19 WD_STYLE_TYPE.CHARACTER: CharacterStyle,
20 WD_STYLE_TYPE.TABLE: _TableStyle,
21 WD_STYLE_TYPE.LIST: _NumberingStyle,
22 }[style_elm.type]
23
24 return style_cls(style_elm)
25
26
27class BaseStyle(ElementProxy):

Callers 8

__getitem__Method · 0.90
__iter__Method · 0.90
add_styleMethod · 0.90
defaultMethod · 0.90
_get_by_idMethod · 0.90
base_styleMethod · 0.85
next_paragraph_styleMethod · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…