def parse_type(type_):
 if (not type_):
  raise MsgSpecException('Invalid empty type')
 if ('[' in type_):
  var_length = type_.endswith('[]')
  splits = type_.split('[')
  if (len(splits) > 2):
   raise MsgSpecException(('Currently only support 1-dimensional array types: %s' % type_))
  if var_length:
   return (type_[:(-2)], True, None)
  else:
   try:
    length = int(splits[1][:(-1)])
    return (splits[0], True, length)
   except ValueError:
    raise MsgSpecException(('Invalid array dimension: [%s]' % splits[1][:(-1)]))
 else:
  return (type_, False, None)

def parse_type ( type_ ) : if ( not type_ ) : raise MsgSpecException ( 'Invalid empty type' ) if ( '[' in type_ ) : var_length = type_ . endswith ( '[]' ) splits = type_ . split ( '[' ) if ( len ( splits ) > 2 ) : raise MsgSpecException ( ( 'Currently only support 1-dimensional array types: %s' % type_ ) ) if var_length : return ( type_ [ : ( - 2 ) ] , True , None ) else : try : length = int ( splits [ 1 ] [ : ( - 1 ) ] ) return ( splits [ 0 ] , True , length ) except ValueError : raise MsgSpecException ( ( 'Invalid array dimension: [%s]' % splits [ 1 ] [ : ( - 1 ) ] ) ) else : return ( type_ , False , None )
parse ros message field type .