'Similar to :meth:`Header.fromstring`, but reads the header string from
a given file-like object or filename.
Parameters
fileobj : str, file-like
A filename or an open file-like object from which a FITS header is
to be read.  For open file handles the file pointer must be at the
beginning of the 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).
endcard : bool, optional
If True (the default) the header must end with an END card in order
to be considered valid.  If an END card is not found an
`IOError` is raised.
padding : bool, optional
If True (the default) the header will be required to be padded out
to a multiple of 2880, the FITS header block size.  Otherwise any
padding, or lack thereof, is ignored.
Returns
header
A new `Header` instance.'

@classmethod
def fromfile(cls, fileobj, sep='', endcard=True, padding=True):

    close_file = False
    if isinstance(fileobj, string_types):
        fileobj = open(fileobj, 'r')
        close_file = True
    try:
        is_binary = fileobj_is_binary(fileobj)
        def block_iter(nbytes):
            while True:
                data = fileobj.read(nbytes)
                if data:
                    (yield data)
                else:
                    break
        return cls._from_blocks(block_iter, is_binary, sep, endcard, padding)[1]
    finally:
        if close_file:
            fileobj.close()
