@ -8,12 +8,32 @@
#
import sys
import argparse
def parse_enum_line ( line ):
def parse_enum_line ( line , ct ):
line = line . strip ( )
parts = line . split ( )
if len ( parts ) != 3 or parts [ 1 ] != ' = ' or not parts [ 0 ] . startswith ( " PEP_ " ) :
if ( line . startswith ( " // " ) or line == " " ) :
return
parts = [ ]
if ( ct ) :
temp = line . split ( " , " )
if len ( temp ) == 0 :
return
else :
parts = temp [ 0 ] . split ( )
else :
parts = line . split ( )
if len ( parts ) != 3 or parts [ 1 ] != ' = ' :
return
if not ct and not parts [ 0 ] . startswith ( " PEP_ " ) :
return
elif ct and not parts [ 0 ] . startswith ( " PEP_ct_ " ) :
return
key = int ( parts [ 2 ] . strip ( ' , ' ) , 0 )
value = parts [ 0 ]
valueDict [ key ] = value
@ -27,11 +47,13 @@ def get_error(code):
print ( str ( code ) + " -> " + error )
error_val = int ( sys . argv [ 1 ] , 0 )
if error_val == None :
print ( " No error code, no error status! " )
exit ( - 1 )
parser = argparse . ArgumentParser ( )
parser . add_argument ( " value " , type = int )
parser . add_argument ( " --comm_type " , " -ct " , help = " number represents a comm type " , action = ' store_true ' )
args = parser . parse_args ( )
error_val = args . value
input_fname = " src/pEpEngine.h "
@ -46,16 +68,20 @@ valueDict = dict()
# If another struct is added first, expect chaos! ;)
#
for line in content :
if line . startswith ( " } PEP_STATUS; " ) :
break
if not args . comm_type :
if line . startswith ( " } PEP_STATUS; " ) :
break
else :
if line . startswith ( " } PEP_comm_type; " ) :
break
if not line . startswith ( " typedef enum { " ) and not inStruct :
if ( ( not args . comm_type and not line . startswith ( " typedef enum { " ) ) or ( args . comm_type and not line . startswith ( " typedef enum _PEP_comm_type { " ) ) ) and not inStruct :
continue
if not inStruct :
inStruct = True
continue
parse_enum_line ( line )
parse_enum_line ( line , args . comm_type )
get_error ( error_val )