def load_raw_data(self, path, alt=PRIMARY_ALT, cls=None,
                      fallback=True):
        """Internal helper that loads the raw record data.  This performs
        very little data processing on the data.
        """
        path = cleanup_path(path)
        if cls is None:
            cls = dict

        fn_base = self.to_fs_path(path)

        rv = cls()
        rv_type = None

        choiceiter = _iter_filename_choices(fn_base, [alt], self.config,
                                            fallback=fallback)
        for fs_path, source_alt, is_attachment in choiceiter:
            # If we already determined what our return value is but the
            # type mismatches what we try now, we have to abort.  Eg:
            # a page can not become an attachment or the other way round.
            if rv_type is not None and rv_type != is_attachment:
                break

            try:
                with open(fs_path, 'rb') as f:
                    if rv_type is None:
                        rv_type = is_attachment
                    for key, lines in metaformat.tokenize(f, encoding='utf-8'):
                        if key not in rv:
                            rv[key] = u''.join(lines)
            except __HOLE__ as e:
                if e.errno not in (errno.ENOTDIR, errno.ENOENT):
                    raise
                if not is_attachment or not os.path.isfile(fs_path[:-3]):
                    continue
                # Special case: we are loading an attachment but the meta
                # data file does not exist.  In that case we still want to
                # record that we're loading an attachment.
                elif is_attachment:
                    rv_type = True

            if '_source_alt' not in rv:
                rv['_source_alt'] = source_alt

        if rv_type is None:
            return

        rv['_path'] = path
        rv['_id'] = posixpath.basename(path)
        rv['_gid'] = hashlib.md5(path.encode('utf-8')).hexdigest()
        rv['_alt'] = alt
        if rv_type:
            rv['_attachment_for'] = posixpath.dirname(path)

        return rv
dataset/ETHPy150Open lektor/lektor/lektor/db.py/Database.load_raw_data