Python 3 compatibility: dict related modifications.
1. iteritems() -> items() 2. remove has_key() Story: 2003310 Task: 24266 Change-Id: I1c92c003333d798d89251e40a1d6cb069c1a922a Signed-off-by: chenyan <yan.chen@intel.com>
This commit is contained in:
parent
2d16767e7c
commit
b156c7d2a2
@ -33,7 +33,7 @@ def get_events_alarm_list(events):
|
||||
def get_constants_alarms():
|
||||
fm_constants_raw_dict = fm_constants.__dict__
|
||||
|
||||
fm_constants_alarms_dict = {k:v for k,v in fm_constants_raw_dict.iteritems() if 'FM_ALARM_ID' in k}
|
||||
fm_constants_alarms_dict = {k:v for k,v in fm_constants_raw_dict.items() if 'FM_ALARM_ID' in k}
|
||||
del fm_constants_alarms_dict['FM_ALARM_ID_INDEX'] # this is not an alarm
|
||||
|
||||
fm_constants_alarms = []
|
||||
|
@ -101,7 +101,7 @@ serviceAffecting_FieldName : serviceAffecting_FieldValues
|
||||
|
||||
|
||||
def checkField( fieldKey, fieldValues, key, event ):
|
||||
if not event.has_key(fieldKey):
|
||||
if fieldKey not in event:
|
||||
print("\n ERROR: %s missing \'%s\' field." % (key, fieldKey))
|
||||
return False
|
||||
# print ("START: %s :END" % event[fieldKey])
|
||||
@ -126,7 +126,7 @@ def checkField( fieldKey, fieldValues, key, event ):
|
||||
return False
|
||||
|
||||
if type(event[fieldKey]) is dict:
|
||||
for dictKey, dictValue in event[fieldKey].iteritems():
|
||||
for dictKey, dictValue in event[fieldKey].items():
|
||||
if not dictKey in severity_FieldValues:
|
||||
print("\n ERROR: \'%s\' is not a valid \'%s\' index value." % (dictKey, fieldKey))
|
||||
print(" Valid index values are:", severity_FieldValues)
|
||||
@ -140,7 +140,7 @@ def checkField( fieldKey, fieldValues, key, event ):
|
||||
|
||||
|
||||
def checkTypeField( key, event ):
|
||||
if not event.has_key(type_FieldName):
|
||||
if type_FieldName not in event:
|
||||
print("\n ERROR: %s missing \'%s\' field." % (key, type_FieldName))
|
||||
return False
|
||||
if event[type_FieldName] in type_FieldValues:
|
||||
@ -157,12 +157,12 @@ def checkFields( key, event ):
|
||||
isAlarm = (event[type_FieldName] == type_FieldValue_Alarm)
|
||||
eventFields = alarmFields if isAlarm else logFields
|
||||
|
||||
for fieldKey, fieldValues in eventFields.iteritems():
|
||||
for fieldKey, fieldValues in eventFields.items():
|
||||
if not checkField(fieldKey, fieldValues, key, event) :
|
||||
isOk = False
|
||||
|
||||
for itemKey, itemValue in event.iteritems():
|
||||
if not eventFields.has_key(itemKey):
|
||||
for itemKey, itemValue in event.items():
|
||||
if itemKey not in eventFields:
|
||||
print("\n ERROR: \'%s\' is not a valid \'%s\' field." % (itemKey, ("Alarm" if isAlarm else "Log") ))
|
||||
isOk = False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user