mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-06 19:58:38 +02:00
scanner: pass the Enum to the Entry class
So we can compose the fqdn (and possibly do value checks and whatnot)
This commit is contained in:
parent
1c9ce9b680
commit
72c570e096
1 changed files with 14 additions and 3 deletions
|
|
@ -181,14 +181,19 @@ class Entry:
|
|||
|
||||
name: str = attr.ib()
|
||||
value: int = attr.ib()
|
||||
enum: "Enum" = attr.ib()
|
||||
summary: str = attr.ib()
|
||||
since: int = attr.ib()
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
cls, name: str, value: int, summary: str = "", since: int = 1
|
||||
cls, name: str, value: int, enum: "Enum", summary: str = "", since: int = 1
|
||||
) -> "Entry":
|
||||
return cls(name=name, value=value, summary=summary, since=since)
|
||||
return cls(name=name, value=value, enum=enum, summary=summary, since=since)
|
||||
|
||||
@property
|
||||
def fqdn(self) -> str:
|
||||
return f"{self.enum.fqdn}_{self.name}"
|
||||
|
||||
|
||||
@attr.s
|
||||
|
|
@ -532,7 +537,13 @@ class Protocol(xml.sax.handler.ContentHandler):
|
|||
value = int(attrs["value"])
|
||||
summary = attrs.get("summary", "")
|
||||
since = int(attrs.get("since", 1))
|
||||
entry = Entry.create(name=name, value=value, summary=summary, since=since)
|
||||
entry = Entry.create(
|
||||
name=name,
|
||||
value=value,
|
||||
enum=self.current_message,
|
||||
summary=summary,
|
||||
since=since,
|
||||
)
|
||||
try:
|
||||
self.current_message.add_entry(entry)
|
||||
except ValueError as e:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue