about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/pptx/oxml/action.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/pptx/oxml/action.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-master.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/pptx/oxml/action.py')
-rw-r--r--.venv/lib/python3.12/site-packages/pptx/oxml/action.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/pptx/oxml/action.py b/.venv/lib/python3.12/site-packages/pptx/oxml/action.py
new file mode 100644
index 00000000..9b31a9e1
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/pptx/oxml/action.py
@@ -0,0 +1,53 @@
+"""lxml custom element classes for text-related XML elements."""
+
+from __future__ import annotations
+
+from pptx.oxml.simpletypes import XsdString
+from pptx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute
+
+
+class CT_Hyperlink(BaseOxmlElement):
+    """Custom element class for <a:hlinkClick> elements."""
+
+    rId: str = OptionalAttribute("r:id", XsdString)  # pyright: ignore[reportAssignmentType]
+    action: str | None = OptionalAttribute(  # pyright: ignore[reportAssignmentType]
+        "action", XsdString
+    )
+
+    @property
+    def action_fields(self) -> dict[str, str]:
+        """Query portion of the `ppaction://` URL as dict.
+
+        For example `{'id':'0', 'return':'true'}` in 'ppaction://customshow?id=0&return=true'.
+
+        Returns an empty dict if the URL contains no query string or if no action attribute is
+        present.
+        """
+        url = self.action
+
+        if url is None:
+            return {}
+
+        halves = url.split("?")
+        if len(halves) == 1:
+            return {}
+
+        key_value_pairs = halves[1].split("&")
+        return dict([pair.split("=") for pair in key_value_pairs])
+
+    @property
+    def action_verb(self) -> str | None:
+        """The host portion of the `ppaction://` URL contained in the action attribute.
+
+        For example 'customshow' in 'ppaction://customshow?id=0&return=true'. Returns |None| if no
+        action attribute is present.
+        """
+        url = self.action
+
+        if url is None:
+            return None
+
+        protocol_and_host = url.split("?")[0]
+        host = protocol_and_host[11:]
+
+        return host