diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /share/extensions/inkex/interfaces | |
parent | Initial commit. (diff) | |
download | inkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.tar.xz inkscape-12fc8abae6d434cac7670a59ed3a67301cc2eb10.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/extensions/inkex/interfaces')
-rw-r--r-- | share/extensions/inkex/interfaces/IElement.py | 39 | ||||
-rw-r--r-- | share/extensions/inkex/interfaces/__init__.py | 0 |
2 files changed, 39 insertions, 0 deletions
diff --git a/share/extensions/inkex/interfaces/IElement.py b/share/extensions/inkex/interfaces/IElement.py new file mode 100644 index 0000000..3e9df53 --- /dev/null +++ b/share/extensions/inkex/interfaces/IElement.py @@ -0,0 +1,39 @@ +"""Element abstractions for type comparisons without circular imports + +.. versionadded:: 1.2""" + +from __future__ import annotations + +from abc import ABC, abstractmethod + +import sys +from lxml import etree + +if sys.version_info >= (3, 8): + from typing import Protocol +else: + from typing_extensions import Protocol + + +class IBaseElement(ABC, etree.ElementBase): + """Abstraction for BaseElement to avoid circular imports""" + + @abstractmethod + def get_id(self, as_url=0): + """Returns the element ID. If not set, generates a unique ID.""" + raise NotImplementedError + + +class BaseElementProtocol(Protocol): + """Abstraction for BaseElement, to be used as typehint in mixin classes""" + + def get_id(self, as_url=0) -> str: + """Returns the element ID. If not set, generates a unique ID.""" + + @property + def root(self) -> ISVGDocumentElement: + """Returns the element's root.""" + + +class ISVGDocumentElement(IBaseElement): + """Abstraction for SVGDocumentElement""" diff --git a/share/extensions/inkex/interfaces/__init__.py b/share/extensions/inkex/interfaces/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/share/extensions/inkex/interfaces/__init__.py |