@staticmethod<EOL><INDENT>def _detect_byteorder(ccp4file):<DEDENT>
bsaflag = None<EOL>ccp4file.seek(<NUM_LIT> * <NUM_LIT:4>)<EOL>mapbin = ccp4file.read(<NUM_LIT:4>)<EOL>for flag in '<STR_LIT>':<EOL><INDENT>mapstr = struct.unpack(flag + '<STR_LIT>', mapbin)[<NUM_LIT:0>].decode('<STR_LIT:utf-8>')<EOL>if mapstr.upper() == '<STR_LIT>':<EOL><INDENT>bsaflag = flag<EOL>break  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>")<EOL><DEDENT>ccp4file.seek(<NUM_LIT:0>)<EOL>return bsaflag<EOL>
Detect the byteorder of stream `ccp4file` and return format character.

        Try all endinaness and alignment options until we find
        something that looks sensible ("MAPS " in the first 4 bytes).

        (The ``machst`` field could be used to obtain endianness, but
        it does not specify alignment.)

        .. SeeAlso::

          :mod:`struct`