def to_ligolw_tables(self, ilwdchar_compat=None, **attrs):
if ilwdchar_compat is None:<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>PendingDeprecationWarning)<EOL>ilwdchar_compat = True<EOL><DEDENT>if ilwdchar_compat:<EOL><INDENT>from glue.ligolw import lsctables<EOL><DEDENT>else:<EOL><INDENT>from ligo.lw import lsctables<EOL><DEDENT>from ..io.ligolw import to_table_type as to_ligolw_table_type<EOL>SegmentDefTable = lsctables.SegmentDefTable<EOL>SegmentSumTable = lsctables.SegmentSumTable<EOL>SegmentTable = lsctables.SegmentTable<EOL>segdeftab = lsctables.New(SegmentDefTable)<EOL>segsumtab = lsctables.New(SegmentSumTable)<EOL>segtab = lsctables.New(SegmentTable)<EOL>def _write_attrs(table, row):<EOL><INDENT>for key, val in attrs.items():<EOL><INDENT>setattr(row, key, to_ligolw_table_type(val, table, key))<EOL><DEDENT><DEDENT>for flag in self.values():<EOL><INDENT>segdef = segdeftab.RowType()<EOL>for col in segdeftab.columnnames:  <EOL><INDENT>setattr(segdef, col, None)<EOL><DEDENT>segdef.instruments = {flag.ifo}<EOL>segdef.name = flag.tag<EOL>segdef.version = flag.version<EOL>segdef.comment = flag.description<EOL>segdef.insertion_time = to_gps(datetime.datetime.now()).gpsSeconds<EOL>segdef.segment_def_id = SegmentDefTable.get_next_id()<EOL>_write_attrs(segdeftab, segdef)<EOL>segdeftab.append(segdef)<EOL>for vseg in flag.known:<EOL><INDENT>segsum = segsumtab.RowType()<EOL>for col in segsumtab.columnnames:  <EOL><INDENT>setattr(segsum, col, None)<EOL><DEDENT>segsum.segment_def_id = segdef.segment_def_id<EOL>segsum.segment = map(LIGOTimeGPS, vseg)<EOL>segsum.comment = None<EOL>segsum.segment_sum_id = SegmentSumTable.get_next_id()<EOL>_write_attrs(segsumtab, segsum)<EOL>segsumtab.append(segsum)<EOL><DEDENT>for aseg in flag.active:<EOL><INDENT>seg = segtab.RowType()<EOL>for col in segtab.columnnames:  <EOL><INDENT>setattr(seg, col, None)<EOL><DEDENT>seg.segment_def_id = segdef.segment_def_id<EOL>seg.segment = map(LIGOTimeGPS, aseg)<EOL>seg.segment_id = SegmentTable.get_next_id()<EOL>_write_attrs(segtab, seg)<EOL>segtab.append(seg)<EOL><DEDENT><DEDENT>return segdeftab, segsumtab, segtab<EOL>
Convert this `DataQualityDict` into a trio of LIGO_LW segment tables

        Parameters
        ----------
        ilwdchar_compat : `bool`, optional
            whether to write in the old format, compatible with
            ILWD characters (`True`), or to use the new format (`False`);
            the current default is `True` to maintain backwards
            compatibility, but this will change for gwpy-1.0.0.

        **attrs
            other attributes to add to all rows in all tables
            (e.g. ``'process_id'``)

        Returns
        -------
        segmentdeftable : :class:`~ligo.lw.lsctables.SegmentDefTable`
            the ``segment_definer`` table

        segmentsumtable : :class:`~ligo.lw.lsctables.SegmentSumTable`
            the ``segment_summary`` table

        segmenttable : :class:`~ligo.lw.lsctables.SegmentTable`
            the ``segment`` table