+class NIM(object):
+ def __init__(self, slot, type, description):
+ self.slot = slot
+
+ if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
+ print "warning: unknown NIM type %s, not using." % type
+ type = None
+
+ self.type = type
+ self.description = description
+
+ def isCompatible(self, what):
+ compatible = {
+ None: [None],
+ "DVB-S": ["DVB-S", None],
+ "DVB-C": ["DVB-C", None],
+ "DVB-T": ["DVB-T", None],
+ "DVB-S2": ["DVB-S", "DVB-S2", None]
+ }
+ return what in compatible[self.type]
+
+ def getSlotName(self):
+ # get a friendly description for a slot name.
+ # we name them "Tuner A/B/C/...", because that's what's usually written on the back
+ # of the device.
+ return _("Tuner ") + chr(ord('A') + self.slot)
+
+ slot_name = property(getSlotName)
+
+ def getSlotID(self):
+ return chr(ord('A') + self.slot)
+
+ slot_id = property(getSlotID)
+
+ def getFriendlyType(self):
+ return {
+ "DVB-S": "DVB-S",
+ "DVB-T": "DVB-T",
+ "DVB-S2": "DVB-S2",
+ "DVB-C": "DVB-C",
+ None: _("empty")
+ }[self.type]
+
+ friendly_type = property(getFriendlyType)
+
+ def getFriendlyFullDescription(self):
+ nim_text = self.slot_name + ": "
+
+ if self.empty:
+ nim_text += _("(empty)")
+ else:
+ nim_text += self.description + " (" + self.friendly_type + ")"
+
+ return nim_text
+
+ friendly_full_description = property(getFriendlyFullDescription)
+ config_mode = property(lambda self: config.Nims[self.slot].configMode.value)
+ config = property(lambda self: config.Nims[self.slot])
+
+ empty = property(lambda self: self.type is None)
+
+ cable_trust_nit = property(lambda self: self.config.cabletype.value == "quick")