code: def write_omega_scan_config(channellist, fobj, header=True):
      
      if isinstance(fobj, FILE_LIKE):
          close = False
      else:
          fobj = open(fobj, 'w')
          close = True
      try:
          # print header
          if header:
              print('# Q Scan configuration file', file=fobj)
              print('# Generated with GWpy from a ChannelList', file=fobj)
          group = None
          for channel in channellist:
              # print header
              if channel.group != group:
                  group = channel.group
                  print('\n[%s]' % group, file=fobj)
              print("", file=fobj)
              print_omega_channel(channel, file=fobj)
      finally:
          if close:
              fobj.close()
docs: Write a `ChannelList` to an Omega-pipeline scan configuration file
  
      This method is dumb and assumes the channels are sorted in the right
      order already