about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/strictyaml/ruamel/scalarint.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/strictyaml/ruamel/scalarint.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/strictyaml/ruamel/scalarint.py')
-rw-r--r--.venv/lib/python3.12/site-packages/strictyaml/ruamel/scalarint.py140
1 files changed, 140 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/strictyaml/ruamel/scalarint.py b/.venv/lib/python3.12/site-packages/strictyaml/ruamel/scalarint.py
new file mode 100644
index 00000000..d3c78b44
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/strictyaml/ruamel/scalarint.py
@@ -0,0 +1,140 @@
+# coding: utf-8
+
+from __future__ import print_function, absolute_import, division, unicode_literals
+
+from .compat import no_limit_int  # NOQA
+from strictyaml.ruamel.anchor import Anchor
+
+if False:  # MYPY
+    from typing import Text, Any, Dict, List  # NOQA
+
+__all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt", "DecimalInt"]
+
+
+class ScalarInt(no_limit_int):
+    def __new__(cls, *args, **kw):
+        # type: (Any, Any, Any) -> Any
+        width = kw.pop("width", None)  # type: ignore
+        underscore = kw.pop("underscore", None)  # type: ignore
+        anchor = kw.pop("anchor", None)  # type: ignore
+        v = no_limit_int.__new__(cls, *args, **kw)  # type: ignore
+        v._width = width
+        v._underscore = underscore
+        if anchor is not None:
+            v.yaml_set_anchor(anchor, always_dump=True)
+        return v
+
+    def __iadd__(self, a):  # type: ignore
+        # type: (Any) -> Any
+        x = type(self)(self + a)
+        x._width = self._width  # type: ignore
+        x._underscore = (  # type: ignore
+            self._underscore[:] if self._underscore is not None else None  # type: ignore
+        )  # NOQA
+        return x
+
+    def __ifloordiv__(self, a):  # type: ignore
+        # type: (Any) -> Any
+        x = type(self)(self // a)
+        x._width = self._width  # type: ignore
+        x._underscore = (  # type: ignore
+            self._underscore[:] if self._underscore is not None else None  # type: ignore
+        )  # NOQA
+        return x
+
+    def __imul__(self, a):  # type: ignore
+        # type: (Any) -> Any
+        x = type(self)(self * a)
+        x._width = self._width  # type: ignore
+        x._underscore = (  # type: ignore
+            self._underscore[:] if self._underscore is not None else None  # type: ignore
+        )  # NOQA
+        return x
+
+    def __ipow__(self, a):  # type: ignore
+        # type: (Any) -> Any
+        x = type(self)(self ** a)
+        x._width = self._width  # type: ignore
+        x._underscore = (  # type: ignore
+            self._underscore[:] if self._underscore is not None else None  # type: ignore
+        )  # NOQA
+        return x
+
+    def __isub__(self, a):  # type: ignore
+        # type: (Any) -> Any
+        x = type(self)(self - a)
+        x._width = self._width  # type: ignore
+        x._underscore = (  # type: ignore
+            self._underscore[:] if self._underscore is not None else None  # type: ignore
+        )  # NOQA
+        return x
+
+    @property
+    def anchor(self):
+        # type: () -> Any
+        if not hasattr(self, Anchor.attrib):
+            setattr(self, Anchor.attrib, Anchor())
+        return getattr(self, Anchor.attrib)
+
+    def yaml_anchor(self, any=False):
+        # type: (bool) -> Any
+        if not hasattr(self, Anchor.attrib):
+            return None
+        if any or self.anchor.always_dump:
+            return self.anchor
+        return None
+
+    def yaml_set_anchor(self, value, always_dump=False):
+        # type: (Any, bool) -> None
+        self.anchor.value = value
+        self.anchor.always_dump = always_dump
+
+
+class BinaryInt(ScalarInt):
+    def __new__(cls, value, width=None, underscore=None, anchor=None):
+        # type: (Any, Any, Any, Any) -> Any
+        return ScalarInt.__new__(
+            cls, value, width=width, underscore=underscore, anchor=anchor
+        )
+
+
+class OctalInt(ScalarInt):
+    def __new__(cls, value, width=None, underscore=None, anchor=None):
+        # type: (Any, Any, Any, Any) -> Any
+        return ScalarInt.__new__(
+            cls, value, width=width, underscore=underscore, anchor=anchor
+        )
+
+
+# mixed casing of A-F is not supported, when loading the first non digit
+# determines the case
+
+
+class HexInt(ScalarInt):
+    """uses lower case (a-f)"""
+
+    def __new__(cls, value, width=None, underscore=None, anchor=None):
+        # type: (Any, Any, Any, Any) -> Any
+        return ScalarInt.__new__(
+            cls, value, width=width, underscore=underscore, anchor=anchor
+        )
+
+
+class HexCapsInt(ScalarInt):
+    """uses upper case (A-F)"""
+
+    def __new__(cls, value, width=None, underscore=None, anchor=None):
+        # type: (Any, Any, Any, Any) -> Any
+        return ScalarInt.__new__(
+            cls, value, width=width, underscore=underscore, anchor=anchor
+        )
+
+
+class DecimalInt(ScalarInt):
+    """needed if anchor"""
+
+    def __new__(cls, value, width=None, underscore=None, anchor=None):
+        # type: (Any, Any, Any, Any) -> Any
+        return ScalarInt.__new__(
+            cls, value, width=width, underscore=underscore, anchor=anchor
+        )