@classmethod<EOL><INDENT>def pack(cls, integer, *, size=<NUM_LIT:1>, signed=False, lilendian=False):<DEDENT>
endian = '<STR_LIT:<>' if lilendian else '<STR_LIT:>>'<EOL>if size == <NUM_LIT:8>:                       <EOL><INDENT>kind = '<STR_LIT:q>' if signed else '<STR_LIT>'<EOL><DEDENT>elif size == <NUM_LIT:4>:                     <EOL><INDENT>kind = '<STR_LIT:i>' if signed else '<STR_LIT:I>'<EOL><DEDENT>elif size == <NUM_LIT:2>:                     <EOL><INDENT>kind = '<STR_LIT:h>' if signed else '<STR_LIT:H>'<EOL><DEDENT>elif size == <NUM_LIT:1>:                     <EOL><INDENT>kind = '<STR_LIT:b>' if signed else '<STR_LIT:B>'<EOL><DEDENT>else:                               <EOL><INDENT>kind = None<EOL><DEDENT>if kind is None:<EOL><INDENT>end = '<STR_LIT>' if lilendian else '<STR_LIT>'<EOL>buf = integer.to_bytes(size, end, signed=signed)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>fmt = f'<STR_LIT>'<EOL>buf = struct.pack(fmt, integer)<EOL><DEDENT>except struct.error:<EOL><INDENT>raise StructError(f'<STR_LIT>') from None<EOL><DEDENT><DEDENT>return buf<EOL>
Pack integers to bytes.

        Positional arguments:
            * integer  -- int, integer to be packed

        Keyword arguments:
            * size  -- int, buffer size (default is 1)
            * signed -- bool, signed flag (default is False)
                           <keyword> True / False
            * lilendian -- bool, little-endian flag (default is False)
                           <keyword> True / False

        Returns:
            * bytes -- packed data upon success