code: def read_hdf5_flag(h5f, path=None, gpstype=LIGOTimeGPS):
      
      # extract correct group
      dataset = _get_flag_group(h5f, path)
  
      # read dataset
      active = SegmentList.read(dataset['active'], format='hdf5',
                                gpstype=gpstype)
      try:
          known = SegmentList.read(dataset['known'], format='hdf5',
                                   gpstype=gpstype)
      except KeyError as first_keyerror:
          try:
              known = SegmentList.read(dataset['valid'], format='hdf5',
                                       gpstype=gpstype)
          except KeyError:
              raise first_keyerror
  
      return DataQualityFlag(active=active, known=known, **dict(dataset.attrs))
docs: Read a `DataQualityFlag` object from an HDF5 file or group.