def structparser(token):
 m = STRUCT_PACK_RE.match(token)
 if (not m):
  return [token]
 else:
  endian = m.group('endian')
  if (endian is None):
   return [token]
  formatlist = re.findall(STRUCT_SPLIT_RE, m.group('fmt'))
  fmt = ''.join([((f[(-1)] * int(f[:(-1)])) if (len(f) != 1) else f) for f in formatlist])
  if (endian == '@'):
   if (byteorder == 'little'):
    endian = '<'
   else:
    assert (byteorder == 'big')
    endian = '>'
  if (endian == '<'):
   tokens = [REPLACEMENTS_LE[c] for c in fmt]
  else:
   assert (endian == '>')
   tokens = [REPLACEMENTS_BE[c] for c in fmt]
 return tokens

def structparser ( token ) : m = STRUCT_PACK_RE . match ( token ) if ( not m ) : return [ token ] else : endian = m . group ( 'endian' ) if ( endian is None ) : return [ token ] formatlist = re . findall ( STRUCT_SPLIT_RE , m . group ( 'fmt' ) ) fmt = '' . join ( [ ( ( f [ ( - 1 ) ] * int ( f [ : ( - 1 ) ] ) ) if ( len ( f ) != 1 ) else f ) for f in formatlist ] ) if ( endian == '@' ) : if ( byteorder == 'little' ) : endian = '<' else : assert ( byteorder == 'big' ) endian = '>' if ( endian == '<' ) : tokens = [ REPLACEMENTS_LE [ c ] for c in fmt ] else : assert ( endian == '>' ) tokens = [ REPLACEMENTS_BE [ c ] for c in fmt ] return tokens
parse struct-like format string token into sub-token list .