code: def edit(self, config, state, name, value=None):
          
          config = str(config)  # make a copy so we can alter it
          matches = list(self._GRUB_KERNEL_BOOT_ENTRY.finditer(config))
          # process matches in reverse order, so replacing one match
          # does not alter the start/end positions of other matches
          for match in reversed(matches):
              start = match.end()
              # Linux command line extends up to the newline
              if config[start] == '\n':
                  cmdline = ''
              else:
                  end = config.find('\n', start)
                  cmdline = config[start:end]
              new_cmdline = _assemble_linux_cmdline(cmdline, state, name, value)
              config = config[:start] + new_cmdline + config[end:]
          return config
docs: Change all occurrences of `name` in a kernel boot line in the
          given `config` text.