def write_channel_list_file(channels, fobj):
if not isinstance(fobj, FILE_LIKE):<EOL><INDENT>with open(fobj, "<STR_LIT:w>") as fobj:<EOL><INDENT>return write_channel_list_file(channels, fobj)<EOL><DEDENT><DEDENT>out = configparser.ConfigParser(dict_type=OrderedDict)<EOL>for channel in channels:<EOL><INDENT>group = channel.group<EOL>if not out.has_section(group):<EOL><INDENT>out.add_section(group)<EOL><DEDENT>for param, value in channel.params.items():<EOL><INDENT>out.set(group, param, value)<EOL><DEDENT>if channel.sample_rate is not None:<EOL><INDENT>entry = '<STR_LIT>' % (str(channel),<EOL>str(channel.sample_rate.to('<STR_LIT>').value))<EOL><DEDENT>else:<EOL><INDENT>entry = str(channel)<EOL><DEDENT>entry += '<STR_LIT>' % channel.params.get('<STR_LIT>', '<STR_LIT>')<EOL>entry += '<STR_LIT>' % channel.params.get('<STR_LIT>', '<STR_LIT>')<EOL>try:<EOL><INDENT>clist = out.get(group, '<STR_LIT>')<EOL><DEDENT>except configparser.NoOptionError:<EOL><INDENT>out.set(group, '<STR_LIT>', '<STR_LIT>' % entry)<EOL><DEDENT>else:<EOL><INDENT>out.set(group, '<STR_LIT>', clist + '<STR_LIT>' % entry)<EOL><DEDENT><DEDENT>out.write(fobj)<EOL>
Write a `~gwpy.detector.ChannelList` to a INI-format channel list file