<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_meta(self, text):
 """ Takes input as the entire file. Reads the first yaml document as metadata. and the rest of the document as text """

        first_line = True
        metadata = []
        content = []
        metadata_parsed = False

        for line in text.split('\n'):
            if first_line:
                first_line = False
                if line.strip() != '---':
                    raise MetaParseException('Invalid metadata')
                else:
                    continue
            if line.strip() == '' and not metadata_parsed:
                continue
            if line.strip() == '---' and not metadata_parsed:
                # reached the last line
                metadata_parsed = True
            elif not metadata_parsed:
                metadata.append(line)
            else:
                content.append(line)

        content = '\n'.join(content)
        try:
            metadata = yaml.load('\n'.join(metadata))
        except:
            raise
            content = text
            metadata = yaml.load('')

        return content, metadata