code: def write_ligolw(flags, target, attrs=None, ilwdchar_compat=None, **kwargs):
      
      if isinstance(flags, DataQualityFlag):
          flags = DataQualityDict({flags.name: flags})
      return write_tables(
          target,
          flags.to_ligolw_tables(ilwdchar_compat=ilwdchar_compat,
                                 **attrs or dict()),
          **kwargs
      )
docs: Write this `DataQualityFlag` to the given LIGO_LW Document
  
      Parameters
      ----------
      flags : `DataQualityFlag`, `DataQualityDict`
          `gwpy.segments` object to write
  
      target : `str`, `file`, :class:`~ligo.lw.ligolw.Document`
          the file or document to write into
  
      attrs : `dict`, optional
          extra attributes to write into segment tables
  
      **kwargs
          keyword arguments to use when writing
  
      See also
      --------
      gwpy.io.ligolw.write_ligolw_tables
          for details of acceptable keyword arguments