'Extract a corefile from an apport crash file contents.
Arguments:
crashfile_data(str): Crash file contents
Returns:
`str`: Raw binary data for the core file, or ``None``.'

def apport_crash_extract_corefile(self, crashfile_data):

    file = StringIO.StringIO(crashfile_data)
    for line in file:
        if line.startswith('    Pid:'):
            pid = int(line.split()[(-1)])
            if (pid == self.pid):
                break
    else:
        return
    for line in file:
        if line.startswith('CoreDump:    base64'):
            break
    else:
        return
    chunks = []
    for line in file:
        if (not line.startswith('    ')):
            break
        chunks.append(b64d(line))
    compressed_data = ''.join(chunks)
    compressed_file = StringIO.StringIO(compressed_data)
    gzip_file = gzip.GzipFile(fileobj=compressed_file)
    core_data = gzip_file.read()
    return core_data
