code: def write_hdf5_flag_group(flag, h5group, **kwargs):
      
      # write segmentlists
      flag.active.write(h5group, 'active', **kwargs)
      kwargs['append'] = True
      flag.known.write(h5group, 'known', **kwargs)
  
      # store metadata
      for attr in ['name', 'label', 'category', 'description', 'isgood',
                   'padding']:
          value = getattr(flag, attr)
          if value is None:
              continue
          elif isinstance(value, Quantity):
              h5group.attrs[attr] = value.value
          elif isinstance(value, UnitBase):
              h5group.attrs[attr] = str(value)
          else:
              h5group.attrs[attr] = value
  
      return h5group
docs: Write a `DataQualityFlag` into the given HDF5 group