<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_ligolw_tables(cls, segmentdeftable, segmentsumtable, segmenttable, names=None, gpstype=LIGOTimeGPS, on_missing='error'):
 """Build a `DataQualityDict` from a set of LIGO_LW segment tables Parameters segmentdeftable : :class:`~ligo.lw.lsctables.SegmentDefTable` the ``segment_definer`` table to read segmentsumtable : :class:`~ligo.lw.lsctables.SegmentSumTable` the ``segment_summary`` table to read segmenttable : :class:`~ligo.lw.lsctables.SegmentTable` the ``segment`` table to read names : `list` of `str`, optional a list of flag names to read, defaults to returning all gpstype : `type`, `callable`, optional class to use for GPS times in returned objects, can be a function to convert GPS time to something else, default is `~gwpy.time.LIGOTimeGPS` on_missing : `str`, optional action to take when a one or more ``names`` are not found in the ``segment_definer`` table, one of - ``'ignore'`` : do nothing - ``'warn'`` : print a warning - ``error'`` : raise a `ValueError` Returns ------- dqdict : `DataQualityDict` a dict of `DataQualityFlag` objects populated from the LIGO_LW tables """

        out = cls()

        id_ = dict()  # need to record relative IDs from LIGO_LW

        # read segment definers and generate DataQualityFlag object
        for row in segmentdeftable:
            ifos = sorted(row.instruments)
            ifo = ''.join(ifos) if ifos else None
            tag = row.name
            version = row.version
            name = ':'.join([str(k) for k in (ifo, tag, version) if
                             k is not None])
            if names is None or name in names:
                out[name] = DataQualityFlag(name)
                thisid = int(row.segment_def_id)
                try:
                    id_[name].append(thisid)
                except (AttributeError, KeyError):
                    id_[name] = [thisid]

        # verify all requested flags were found
        for flag in names or []:
            if flag not in out and on_missing != 'ignore':
                msg = ("no segment definition found for flag={0!r} in "
                       "file".format(flag))
                if on_missing == 'warn':
                    warnings.warn(msg)
                else:
                    raise ValueError(msg)

        # parse a table into the target DataQualityDict
        def _parse_segments(table, listattr):
            for row in table:
                for flag in out:
                    # match row ID to list of IDs found for this flag
                    if int(row.segment_def_id) in id_[flag]:
                        getattr(out[flag], listattr).append(
                            Segment(*map(gpstype, row.segment)),
                        )
                        break

        # read segment summary table as 'known'
        _parse_segments(segmentsumtable, "known")

        # read segment table as 'active'
        _parse_segments(segmenttable, "active")

        return out