Remove use of has_key() for Python 3 compat. (nw)

This commit is contained in:
Mike Naberezny 2015-03-03 12:50:00 -08:00
parent e7c07fbb52
commit dd7ea6355b

View File

@ -77,7 +77,7 @@ while count < len(lines):
next_dispatch = lines[count+1][percent_pos+1:].strip("\t\n; ") next_dispatch = lines[count+1][percent_pos+1:].strip("\t\n; ")
# If there is no state number associated with the next dispatch, make one # If there is no state number associated with the next dispatch, make one
if not dispatch_to_states.has_key(next_dispatch): if next_dispatch not in dispatch_to_states:
dispatch_to_states[next_dispatch] = state dispatch_to_states[next_dispatch] = state
states_to_dispatch[state] = next_dispatch states_to_dispatch[state] = next_dispatch
state = state + 1 state = state + 1
@ -113,7 +113,7 @@ while count < len(lines):
# Output the case labels # Output the case labels
for i in range(0, state): for i in range(0, state):
print "\tcase %d: goto %s;" % (i, states_to_dispatch[i] if states_to_dispatch.has_key(i) else "state_%s" % str(i)) print("\tcase %d: goto %s;" % (i, states_to_dispatch.get(i, "state_%d" % i)))
# Output a default case # Output a default case
print "\tdefault:" print "\tdefault:"