def _parse_remind(self, filename, lines=''):
        """Calls remind and parses the output into a dict

        filename -- the remind file (included files will be used as well)
        lines -- used as stdin to remind (filename will be set to -)
        """
        files = {}
        reminders = {}
        if lines:
            filename = '-'
            files[filename] = lines
            reminders[filename] = {}

        cmd = ['remind', '-l', '-s%d' % self._month, '-b1', '-y', '-r',
               filename, str(self._startdate)]
        try:
            rem = Popen(cmd, stdin=PIPE, stdout=PIPE).communicate(input=lines.encode('utf-8'))[0].decode('utf-8')
        except OSError:
            raise OSError('Error running: %s' % ' '.join(cmd))

        rem = rem.splitlines()
        for (fileinfo, line) in zip(rem[::2], rem[1::2]):
            fileinfo = fileinfo.split()

            src_filename = fileinfo[3]
            if src_filename not in files:
                # There is a race condition with the remind call above here.
                # This could be solved by parsing the remind -de output,
                # but I don't see an easy way to do that.
                files[src_filename] = open(src_filename).readlines()
                reminders[src_filename] = {}
                mtime = getmtime(src_filename)
                if mtime > self._mtime:
                    self._mtime = mtime

            text = files[src_filename][int(fileinfo[2]) - 1]
            event = self._parse_remind_line(line, text)
            if event['uid'] in reminders[src_filename]:
                reminders[src_filename][event['uid']]['dtstart'] += event['dtstart']
                reminders[src_filename][event['uid']]['line'] += line
            else:
                reminders[src_filename][event['uid']] = event
                reminders[src_filename][event['uid']]['line'] = line

        # Find included files without reminders and add them to the file list
        for source in files.values():
            for line in source:
                if line.startswith('include'):
                    new_file = line.split(' ')[1].strip()
                    if new_file not in reminders:
                        reminders[new_file] = {}
                        mtime = getmtime(new_file)
                        if mtime > self._mtime:
                            self._mtime = mtime

        return reminders