'Creates an HDU header from a byte string containing the entire header
data.
Parameters
data : str
String containing the entire header.
sep : str, optional
The string separating cards from each other, such as a newline.  By
default there is no card separator (as is the case in a raw FITS
file).
Returns
header
A new `Header` instance.'

@classmethod
def fromstring(cls, data, sep=''):

    cards = []
    require_full_cardlength = set(sep).issubset(VALID_HEADER_CHARS)
    idx = 0
    image = []
    while (idx < len(data)):
        if require_full_cardlength:
            end_idx = (idx + Card.length)
        else:
            try:
                end_idx = data.index(sep, idx)
            except ValueError:
                end_idx = len(data)
        next_image = data[idx:end_idx]
        idx = (end_idx + len(sep))
        if image:
            if (next_image[:8] == 'CONTINUE'):
                image.append(next_image)
                continue
            cards.append(Card.fromstring(''.join(image)))
        if require_full_cardlength:
            if (next_image == END_CARD):
                image = []
                break
        elif (next_image.split(sep)[0].rstrip() == 'END'):
            image = []
            break
        image = [next_image]
    if image:
        cards.append(Card.fromstring(''.join(image)))
    return cls(cards)
