From 00fb458cb21fbb5ce694596daf46890ccd2b94a4 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 22 Jun 2023 22:23:00 +0300 Subject: [PATCH] insndb/core: hide section bitsel type --- src/openpower/insndb/core.py | 57 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 7490cf67..c5b586f9 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -512,44 +512,43 @@ class SVP64Record(Dataclass): return (_RegType(self.extra_CR.reg) is _RegType.CR_3BIT) -class BitSel: - def __init__(self, value=(0, 32)): - if isinstance(value, str): - (start, end) = map(int, value.split(":")) - else: - (start, end) = value - if start < 0 or end < 0 or start >= end: - raise ValueError(value) - - self.__start = start - self.__end = end +class Section(Dataclass): + class Path(type(_pathlib.Path("."))): + pass - return super().__init__() + class BitSel: + def __init__(self, value=(0, 32)): + if isinstance(value, str): + (start, end) = map(int, value.split(":")) + else: + (start, end) = value + if start < 0 or end < 0 or start >= end: + raise ValueError(value) - def __len__(self): - return (self.__end - self.__start + 1) + self.__start = start + self.__end = end - def __repr__(self): - return f"[{self.__start}:{self.__end}]" + return super().__init__() - def __iter__(self): - yield from range(self.start, (self.end + 1)) + def __len__(self): + return (self.__end - self.__start + 1) - def __reversed__(self): - return tuple(reversed(tuple(self))) + def __repr__(self): + return f"[{self.__start}:{self.__end}]" - @property - def start(self): - return self.__start + def __iter__(self): + yield from range(self.start, (self.end + 1)) - @property - def end(self): - return self.__end + def __reversed__(self): + return tuple(reversed(tuple(self))) + @property + def start(self): + return self.__start -class Section(Dataclass): - class Path(type(_pathlib.Path("."))): - pass + @property + def end(self): + return self.__end class Mode(_enum.Enum): INTEGER = _enum.auto() -- 2.30.2