Enables dictionary-style access by UI name. Lookup by style id is deprecated, triggers a warning, and will be removed in a near-future release.
(self, key: str)
| 29 | return any(style.name_val == internal_name for style in self._element.style_lst) |
| 30 | |
| 31 | def __getitem__(self, key: str): |
| 32 | """Enables dictionary-style access by UI name. |
| 33 | |
| 34 | Lookup by style id is deprecated, triggers a warning, and will be removed in a |
| 35 | near-future release. |
| 36 | """ |
| 37 | style_elm = self._element.get_by_name(BabelFish.ui2internal(key)) |
| 38 | if style_elm is not None: |
| 39 | return StyleFactory(style_elm) |
| 40 | |
| 41 | style_elm = self._element.get_by_id(key) |
| 42 | if style_elm is not None: |
| 43 | msg = "style lookup by style_id is deprecated. Use style name as key instead." |
| 44 | warn(msg, UserWarning, stacklevel=2) |
| 45 | return StyleFactory(style_elm) |
| 46 | |
| 47 | raise KeyError("no style with name '%s'" % key) |
| 48 | |
| 49 | def __iter__(self): |
| 50 | return (StyleFactory(style) for style in self._element.style_lst) |
nothing calls this directly
no test coverage detected