The deviceMap passed to this function is a
dictionary obtained from GetHardware in
which the keys are device types such as 'VIDEO' and the associated value is a list of
two-element lists [. We want the detail, other] if present; the detail is a
dictionary that contains stuff we don't need to know.
other
If the deviceMap does have an entry for
the desired device type, add to self.deviceList a two-element list
“[” for
each instance of that device type. For example, if a
client has two video cards, there will be two elements in
devType,
[detail]self.deviceList of the form ["VIDEO", ".
model-info"]
# - - - C l i e n t C o n f i g . _ _ d e v i c e C h e c k
def __deviceCheck ( self, deviceMap, deviceType ):
'''Extract from deviceMap any device details for type deviceType
[ (deviceMap has the format of a value from
hardMap[self.DEVICES]) and
(deviceType is a string) ->
if deviceMap has a key equal to deviceType ->
self.deviceList +:= a list [deviceType,
detail] for each device of that type in
deviceMap
else -> I ]
'''
First we check to see if this client has any devices of
type deviceType.n
#-- 1 --
# [ if deviceMap has a key that matches deviceType ->
# multiList := deviceMap[deviceType]
# else -> return ]
try:
multiList = deviceMap[deviceType]
except KeyError:
return
At this point, multiList is a list with
one member for each device of the right type. Each
member is itself a two-element list [, where detail, other] is a string describing the
device's details, and detail is a dictionary whose
contents don't interest us.
other
Our job is to add to self.deviceList a
two-element list of the form [ for each instance of this
device type in devType, detail]multiList.
#-- 2 --
# [ self.deviceList +:= two-element lists [devType,
# detail] for each element of multiList ]
for detail, other in multiList:
self.deviceList.append ( [deviceType, detail] )