@classmethod<EOL><INDENT>def from_ligolw_tables(cls, segmentdeftable, segmentsumtable,<EOL>segmenttable, names=None, gpstype=LIGOTimeGPS,<EOL>on_missing='<STR_LIT:error>'):<DEDENT>
out = cls()<EOL>id_ = dict()  <EOL>for row in segmentdeftable:<EOL><INDENT>ifos = sorted(row.instruments)<EOL>ifo = '<STR_LIT>'.join(ifos) if ifos else None<EOL>tag = row.name<EOL>version = row.version<EOL>name = '<STR_LIT::>'.join([str(k) for k in (ifo, tag, version) if<EOL>k is not None])<EOL>if names is None or name in names:<EOL><INDENT>out[name] = DataQualityFlag(name)<EOL>thisid = int(row.segment_def_id)<EOL>try:<EOL><INDENT>id_[name].append(thisid)<EOL><DEDENT>except (AttributeError, KeyError):<EOL><INDENT>id_[name] = [thisid]<EOL><DEDENT><DEDENT><DEDENT>for flag in names or []:<EOL><INDENT>if flag not in out and on_missing != '<STR_LIT:ignore>':<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT:file>".format(flag))<EOL>if on_missing == '<STR_LIT>':<EOL><INDENT>warnings.warn(msg)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT><DEDENT><DEDENT>def _parse_segments(table, listattr):<EOL><INDENT>for row in table:<EOL><INDENT>for flag in out:<EOL><INDENT>if int(row.segment_def_id) in id_[flag]:<EOL><INDENT>getattr(out[flag], listattr).append(<EOL>Segment(*map(gpstype, row.segment)),<EOL>)<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>_parse_segments(segmentsumtable, "<STR_LIT>")<EOL>_parse_segments(segmenttable, "<STR_LIT>")<EOL>return out<EOL>
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