1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #!/usr/bin/python
# -*- coding: utf-8 -*-
def param1_decode(mylistoflist=[]):
mylistoflist[0][1] = mylistoflist[0][1].upper()
return mylistoflist[0][1]
def param2_decode(mylistoflist=[]):
mylistoflist[0][1] = mylistoflist[0][1].upper()
return mylistoflist[0][1]
def param3_decode(mylistoflist=[]):
mylistoflist[0][1] = mylistoflist[0][1].upper()
return mylistoflist[0][1]
mylistoflist = [[32, 'service_type', '00', 'Default'], [34, 'source_addr_ton', '0x00', 'Unknown']]
myparamlist = [("param1",6,"coctetstring"),("param2",1,"integer"),("param3",1,"integer")]
for x in range(len(myparamlist)):
myparam_decode = ""
myparam_name = myparamlist[x][0]
myparam_length = myparamlist[x][1]
myparam_type = myparamlist[x][2]
exec "myparam_decode = " + myparam_name + "_decode(" + repr(mylistoflist) + ")"
print myparam_decode |
Partager