nodes: 0, module; 1, function_definition; 2, function_name:write_omega_scan_config; 3, parameters; 4, block; 5, identifier:channellist; 6, identifier:fobj; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, try_statement; 11, identifier:header; 12, True; 13, comment:"""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
      """; 14, call; 15, block; 16, else_clause; 17, comment:# print header; 18, block; 19, finally_clause; 20, identifier:isinstance; 21, argument_list; 22, expression_statement; 23, block; 24, if_statement; 25, expression_statement; 26, for_statement; 27, block; 28, identifier:fobj; 29, identifier:FILE_LIKE; 30, assignment; 31, expression_statement; 32, expression_statement; 33, identifier:header; 34, block; 35, assignment; 36, identifier:channel; 37, identifier:channellist; 38, comment:# print header; 39, block; 40, if_statement; 41, identifier:close; 42, False; 43, assignment; 44, assignment; 45, expression_statement; 46, expression_statement; 47, identifier:group; 48, None; 49, if_statement; 50, expression_statement; 51, expression_statement; 52, identifier:close; 53, block; 54, identifier:fobj; 55, call; 56, identifier:close; 57, True; 58, call; 59, call; 60, comparison_operator:channel.group != group; 61, block; 62, call; 63, call; 64, expression_statement; 65, identifier:open; 66, argument_list; 67, identifier:print; 68, argument_list; 69, identifier:print; 70, argument_list; 71, attribute; 72, identifier:group; 73, expression_statement; 74, expression_statement; 75, identifier:print; 76, argument_list; 77, identifier:print_omega_channel; 78, argument_list; 79, call; 80, identifier:fobj; 81, string; 82, string; 83, keyword_argument; 84, string; 85, keyword_argument; 86, identifier:channel; 87, identifier:group; 88, assignment; 89, call; 90, string:""; 91, keyword_argument; 92, identifier:channel; 93, keyword_argument; 94, attribute; 95, argument_list; 96, string_content:w; 97, string_content:# Q Scan configuration file; 98, identifier:file; 99, identifier:fobj; 100, string_content:# Generated with GWpy from a ChannelList; 101, identifier:file; 102, identifier:fobj; 103, identifier:group; 104, attribute; 105, identifier:print; 106, argument_list; 107, identifier:file; 108, identifier:fobj; 109, identifier:file; 110, identifier:fobj; 111, identifier:fobj; 112, identifier:close; 113, identifier:channel; 114, identifier:group; 115, binary_operator:'\n[%s]' % group; 116, keyword_argument; 117, string; 118, identifier:group; 119, identifier:file; 120, identifier:fobj; 121, string_content; 122, escape_sequence:\n
code: def write_omega_scan_config(channellist, fobj, header=True):
      """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
      """
      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()