-path,opcode,bitsel,suffix,mode
-minor_19.csv,19,21:30,NONE,pattern
-minor_30.csv,30,27:30,NONE,pattern
-minor_31.csv,31,21:30,0b101,integer
-minor_58.csv,58,30:31,NONE,integer
-minor_62.csv,62,30:31,NONE,integer
-minor_22.csv,22,21:31,NONE,pattern
-minor_5.csv,5,21:31,NONE,pattern
-minor_4.csv,4,26:31,NONE,integer
-minor_63.csv,63,21:30,NONE,pattern
-minor_59.csv,59,21:30,NONE,pattern
-major.csv,NONE,0:5,NONE,integer
-extra.csv,NONE,0:31,NONE,pattern
+path,opcode,bitsel,suffix,mode,priority
+minor_19.csv,19,21:30,NONE,pattern,normal
+minor_30.csv,30,27:30,NONE,pattern,normal
+minor_31.csv,31,21:30,0b101,integer,normal
+minor_58.csv,58,30:31,NONE,integer,normal
+minor_62.csv,62,30:31,NONE,integer,normal
+minor_22.csv,22,21:31,NONE,pattern,normal
+minor_5.csv,5,21:31,NONE,pattern,normal
+minor_4.csv,4,26:31,NONE,integer,normal
+minor_63.csv,63,21:30,NONE,pattern,normal
+minor_59.csv,59,21:30,NONE,pattern,normal
+major.csv,NONE,0:5,NONE,integer,normal
+extra.csv,NONE,0:31,NONE,pattern,high
return (self.value < other.value)
+@_functools.total_ordering
+class Priority(_enum.Enum):
+ LOW = -1
+ NORMAL = 0
+ HIGH = +1
+
+ @classmethod
+ def _missing_(cls, value):
+ if isinstance(value, str):
+ value = value.upper()
+ try:
+ return cls[value]
+ except ValueError:
+ return super()._missing_(value)
+
+ def __lt__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+
+ # NOTE: the order is inversed, LOW < NORMAL < HIGH
+ return (self.value > other.value)
+
+
def dataclass(cls, record, keymap=None, typemap=None):
if keymap is None:
keymap = {}
suffix: Suffix
mode: Mode
opcode: IntegerOpcode = None
+ priority: Priority = Priority.NORMAL
+
+ def __lt__(self, other):
+ if not isinstance(other, self.__class__):
+ return NotImplemented
+ return (self.priority < other.priority)
@classmethod
def CSV(cls, record):
records = _collections.defaultdict(set)
path = (root / "insndb.csv")
with open(path, "r", encoding="UTF-8") as stream:
- for section in parse(stream, Section.CSV):
+ for section in sorted(parse(stream, Section.CSV)):
path = (root / section.path)
opcode_cls = {
section.Mode.INTEGER: IntegerOpcode,