Custom element class for elements.
| 7 | |
| 8 | |
| 9 | class CT_Hyperlink(BaseOxmlElement): |
| 10 | """Custom element class for <a:hlinkClick> elements.""" |
| 11 | |
| 12 | rId: str = OptionalAttribute("r:id", XsdString) # pyright: ignore[reportAssignmentType] |
| 13 | action: str | None = OptionalAttribute( # pyright: ignore[reportAssignmentType] |
| 14 | "action", XsdString |
| 15 | ) |
| 16 | |
| 17 | @property |
| 18 | def action_fields(self) -> dict[str, str]: |
| 19 | """Query portion of the `ppaction://` URL as dict. |
| 20 | |
| 21 | For example `{'id':'0', 'return':'true'}` in 'ppaction://customshow?id=0&return=true'. |
| 22 | |
| 23 | Returns an empty dict if the URL contains no query string or if no action attribute is |
| 24 | present. |
| 25 | """ |
| 26 | url = self.action |
| 27 | |
| 28 | if url is None: |
| 29 | return {} |
| 30 | |
| 31 | halves = url.split("?") |
| 32 | if len(halves) == 1: |
| 33 | return {} |
| 34 | |
| 35 | key_value_pairs = halves[1].split("&") |
| 36 | return dict([pair.split("=") for pair in key_value_pairs]) |
| 37 | |
| 38 | @property |
| 39 | def action_verb(self) -> str | None: |
| 40 | """The host portion of the `ppaction://` URL contained in the action attribute. |
| 41 | |
| 42 | For example 'customshow' in 'ppaction://customshow?id=0&return=true'. Returns |None| if no |
| 43 | action attribute is present. |
| 44 | """ |
| 45 | url = self.action |
| 46 | |
| 47 | if url is None: |
| 48 | return None |
| 49 | |
| 50 | protocol_and_host = url.split("?")[0] |
| 51 | host = protocol_and_host[11:] |
| 52 | |
| 53 | return host |
nothing calls this directly
no test coverage detected
searching dependent graphs…