def calcsize(fmt):
formatdef, endianness, i = getmode(fmt)<EOL>num = <NUM_LIT:0><EOL>result = <NUM_LIT:0><EOL>while i < len(fmt):<EOL><INDENT>num, i = getNum(fmt, i)<EOL>cur = fmt[i]<EOL>try:<EOL><INDENT>format = formatdef[cur]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise StructError("<STR_LIT>" % cur)<EOL><DEDENT>if num != None:<EOL><INDENT>result += num * format['<STR_LIT:size>']<EOL><DEDENT>else:<EOL><INDENT>result += format['<STR_LIT:size>']<EOL><DEDENT>num = <NUM_LIT:0><EOL>i += <NUM_LIT:1><EOL><DEDENT>return result<EOL>
calcsize(fmt) -> int
    Return size of C struct described by format string fmt.
    See struct.__doc__ for more on format strings.