Add JavaScript line-hint comments to every 10th line of a file.
326505
function addLineHints(name, content) {
		var
			i = -1,
			lines = content.split('\n'),
			len = lines.length,
			out = []
		;
		while (++i < len) {
			out.push(lines[i] +
				((i % 10 === 9) ? ' //' + name + ':' + (i + 1) + '//' : ''));
		}
		return out.join('\n');
	}
1072792
def comment(comment, opts = {})
      @context.lines << Lines::Comment.new(
        line_options(opts.merge(:comment => comment))
      )
    end
1117769
function eachLine(str, callback)
    {
        var lines = splitLines(str);

        for (var i = 0; i < lines.length; i++)
            lines[i] = callback(lines[i], i);

        // include \r to enable copy-paste on windows (ie8) without getting everything on one line
        return lines.join('\r\n');
    }
982863
function commentStrip(string) {
  // Remove commented lines
  string = string.replace(RE_COMMENT_SINGLE_LINE, '');
  string = string.replace(RE_COMMENT_MULTI_LINES, '');
  return string;
}
591748
def append_to_file(file_name, line_data):
    """"""
    with open(file_name, mode='a', encoding='utf-8') as f1:
        f1.write(line_data)
        f1.write("\n")
106799
def getcomments(object):
    """"""
    try: lines, lnum = findsource(object)
    except IOError: return None

    if ismodule(object):
        # Look for a comment block at the top of the file.
        start = 0
        if lines and lines[0][:2] == '#!': start = 1
        while start < len(lines) and string.strip(lines[start]) in ['', '#']:
            start = start + 1
        if start < len(lines) and lines[start][:1] == '#':
            comments = []
            end = start
            while end < len(lines) and lines[end][:1] == '#':
                comments.append(string.expandtabs(lines[end]))
                end = end + 1
            return string.join(comments, '')

    # Look for a preceding block of comments at the same indentation.
    elif lnum > 0:
        indent = indentsize(lines[lnum])
        end = lnum - 1
        if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \
            indentsize(lines[end]) == indent:
            comments = [string.lstrip(string.expandtabs(lines[end]))]
            if end > 0:
                end = end - 1
                comment = string.lstrip(string.expandtabs(lines[end]))
                while comment[:1] == '#' and indentsize(lines[end]) == indent:
                    comments[:0] = [comment]
                    end = end - 1
                    if end < 0: break
                    comment = string.lstrip(string.expandtabs(lines[end]))
            while comments and string.strip(comments[0]) == '#':
                comments[:1] = []
            while comments and string.strip(comments[-1]) == '#':
                comments[-1:] = []
            return string.join(comments, '')
1322463
def add_line_if_absent(filename: str, line: str) -> None:
    
    assert "\n" not in line
    if not is_line_in_file(filename, line):
        log.info("Appending line {!r} to file {!r}", line, filename)
        with open(filename, "a") as file:
            file.writelines([line])
80560
def copy_all_lines_from_to(inputFile, outputFile):
    """"""
    currentLine = inputFile.readline()
    while currentLine:
        outputFile.write(currentLine)
        currentLine = inputFile.readline()
823942
def insert_comment(event):
    
    buff = event.current_buffer

    # Transform all lines.
    if event.arg != 1:
        def change(line):
            return line[1:] if line.startswith('#') else line
    else:
        def change(line):
            return '#' + line

    buff.document = Document(
        text='\n'.join(map(change, buff.text.splitlines())),
        cursor_position=0)

    # Accept input.
    buff.accept_action.validate_and_handle(event.cli, buff)
1072916
def combine_comments(comments):
    '''
    
    '''
    if isinstance(comments, list):
        for idx in range(len(comments)):
            if not isinstance(comments[idx], six.string_types):
                comments[idx] = six.text_type(comments[idx])
    else:
        if not isinstance(comments, six.string_types):
            comments = [six.text_type(comments)]
        else:
            comments = [comments]
    return ' '.join(comments).strip()
601695
function addComment( text, multiline ) {

          if ( options.extractComments ) {

              const loc = location();

              comments[ loc.start.offset ] = {
                  text: text,
                  multiline: multiline,
                  location: loc,
              };

          }

          return text;

      }
1287844
def _replace_lines(fn, startswith, new_line):
  """"""
  new_lines = []
  for line in open(fn):
    if line.startswith(startswith):
      new_lines.append(new_line)
    else:
      new_lines.append(line)
  with open(fn, 'w') as f:
    f.write('\n'.join(new_lines))
549496
def _default(self, line):
        '''
        '''
        if line.strip().startswith('#'):
            return self._comment(line)
        self.install.append(line)
811902
def _strip_comments(line, comments=None):
        """"""
        if comments is None:
            comments = []

        new_comments = False
        comment_start = line.find("#")
        if comment_start != -1:
            comments.append(line[comment_start + 1:].strip())
            new_comments = True
            line = line[:comment_start]

        return line, comments, new_comments
895537
def send_inline_comment(issues)
      target_files = (git.modified_files - git.deleted_files) + git.added_files
      dir = "#{Dir.pwd}/"
      SEVERITY_LEVELS.reverse.each do |level|
        filtered = issues.select { |issue| issue.get("severity") == level }
        next if filtered.empty?
        filtered.each do |r|
          location = r.parent
          filename = location.get("name").gsub(dir, "")
          next unless !filtering || (target_files.include? filename)
          line = (r.get("line") || "0").to_i
          send(level == "warning" ? "warn" : "fail", r.get("message"), file: filename, line: line)
        end
      end
    end
1240838
def comment_out_line(filename, line, comment='#'):
    '''
    '''
    return comment_out_local(filename, line, comment,
                             update_or_append_line=update_or_append_line)
319664
def add_comment(self, line: str) -> None:
        ''' '''
        # the rule is like
        #
        # # comment line  --> add to last comment
        # blank line --> clears last comment
        # [ ] --> use last comment
        # parameter: --> use last comment
        # All others: clear last comment
        self._last_comment += (' ' if self._last_comment else '') + \
            line.lstrip('#').strip()