Skip to content

Commit 9196c9a

Browse files
committed
Merge remote-tracking branch 'origin/pr/812'
* origin/pr/812: Cache device information from hwdata
2 parents 18afb70 + d7212cd commit 9196c9a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

qubes/device_protocol.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,15 +837,18 @@ def __str__(self):
837837
return "Microphone"
838838
return repr(self)
839839

840-
@staticmethod
841-
def _load_classes(bus: str):
840+
@classmethod
841+
def _load_classes(cls, bus: str):
842842
"""
843843
List of known device classes, subclasses and programming interfaces.
844844
"""
845845
# Syntax:
846846
# C class class_name
847847
# subclass subclass_name <-- single tab
848848
# prog-if prog-if_name <-- two tabs
849+
data = "_{}_known_classes".format(bus)
850+
if hasattr(cls, data):
851+
return getattr(cls, data)
849852
result = {}
850853
with open(
851854
f"/usr/share/hwdata/{bus}.ids", encoding="utf-8", errors="ignore"
@@ -872,6 +875,7 @@ def _load_classes(bus: str):
872875
result[class_id + "****"] = class_name
873876
subclass_id = None
874877

878+
setattr(cls, data, result)
875879
return result
876880

877881
def matches(self, other: "DeviceInterface") -> bool:

0 commit comments

Comments
 (0)