Remove C-style comment from GLSL code string.
967378
def remove_comments(code):
    """"""

    pattern = r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*\n)"
    # first group captures quoted strings (double or single)
    # second group captures comments (//single-line or /* multi-line */)
    regex = re.compile(pattern, re.MULTILINE | re.DOTALL)

    def do_replace(match):
        # if the 2nd group (capturing comments) is not None,
        # it means we have captured a non-quoted (real) comment string.
        if match.group(2) is not None:
            return ""  # so we will return empty to remove the comment
        else:  # otherwise, we will return the 1st group
            return match.group(1)  # captured quoted-string

    return regex.sub(do_replace, code)
509912
def strip_non_ascii(string):
    ''' '''
    stripped = (c for c in string if 0 < ord(c) < 127)
    return ''.join(stripped)
639356
def __str_cleanup(line):
        
        if '#' in line:
            line = line.replace("#", "")
            line = line.strip()
        if '-----------' in line:
            line = ''
        return line
364103
def CleanComments(line, quote=False):
    
    if line.find('#') == -1 and line.find('"') == -1:
        if quote:
            return '', quote
        else:
            return line, quote
    # else have to check for comment
    prior = []
    prev = ''
    for char in line:
        try:
            if char == '"':
                if prev != '\\':
                    quote = not quote
                    prior.append(char)
                continue
            elif char == '#' and not quote:
                break
            if not quote:
                prior.append(char)
        finally:
            prev = char

    # rstrip removes trailing space between end of command and the comment # start

    return ''.join(prior).rstrip(), quote
518494
private void skipWhitespace(boolean skipComments) {
    while (pos < data.length) {
      char c = data[pos];
      if (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
        pos++;
        if (c == '\n') newline();
      } else if (skipComments && c == '/') {
        readComment();
      } else {
        break;
      }
    }
  }
751949
def clean_readme(fname):
    """"""
    with codecs.open(fname, 'r', 'utf-8') as f:
        return ''.join(
            re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
            for line in f
            if not (line.startswith('.. currentmodule') or line.startswith('.. toctree'))
        )
352849
function (commentLine) {
    if (state === STATES.IN_COMMENT) {
        commentLine = removePrecedingAsterisks(commentLine);
        // If there is a single space after the * then remove it. Otherwise assume that the user is indenting.
        if (commentLine.indexOf("  ") !== 0 && commentLine.indexOf(" ") === 0) {
            commentLine = commentLine.substr(1);
        }
    }

    return commentLine;
}
511944
def t_whitespace_or_comment(self, s):
        '
        if '#' in s:
            # We have a comment
            matches = re.match('(\s+)(.*[\n]?)', s)
            if matches and self.is_newline:
                self.handle_indent_dedent(matches.group(1))
                s = matches.group(2)
            if s.endswith("\n"):
                self.add_token('COMMENT', s[:-1])
                self.add_token('NEWLINE', "\n")
            else:
                self.add_token('COMMENT', s)
        elif self.is_newline:
            self.handle_indent_dedent(s)
            pass
        return
767141
def remove_formatting_codes(line, irc=False):
    """"""
    if irc:
        line = escape(line)
    new_line = ''
    while len(line) > 0:
        try:
            if line[0] == '$':
                line = line[1:]

                if line[0] == '$':
                    new_line += '$'
                    line = line[1:]

                elif line[0] == 'c':
                    line = line[1:]
                    if line[0].isdigit():
                        line = line[1:]
                        if line[0].isdigit():
                            line = line[1:]
                            if line[0] == ',':
                                line = line[1:]
                                if line[0].isdigit():
                                    line = line[1:]
                                    if line[0].isdigit():
                                        line = line[1:]
                        elif line[0] == ',':
                            line = line[1:]
                            if line[0].isdigit():
                                line = line[1:]
                                if line[0].isdigit():
                                    line = line[1:]
                    if line[0] == '[':
                        while line[0] != ']':
                            line = line[1:]
                        line = line[1:]

                elif line[0] == '{':
                    if line[:3] == '{$}':
                        new_line += '$'
                        line = line[3:]
                        continue
                    while line[0] != '}':
                        line = line[1:]
                    line = line[1:]

                else:
                    line = line[1:]

            else:
                new_line += line[0]
                line = line[1:]
        except IndexError:
            continue
    return new_line
637477
def split_comment(cls, code):
        
        if '#' not in code: return code
        #: Remove comments only (leave quoted strings as they are)
        subf = lambda m: '' if m.group(0)[0]=='#' else m.group(0)
        return re.sub(cls.re_pytokens, subf, code)
811644
function removeDuplicateComments(ast) {
    // Some comments are duplicated as both the leadingComment for one node,
    // and the trailing comment for another. Every comment's range is unique,
    // so two comments with the same range are talking about the same comment.
    // So we'll just remove all trailing comments which are also a leading
    // comment somewhere.
    //eslint-disable-next-line no-undef
    const rangesInLeadingComments = new Set();
    estreeWalker.walk(ast, {
        enter: (node) => {
            for (let leadingComment of node.leadingComments || []) {
                rangesInLeadingComments.add(leadingComment.range.join(','));
            }
        }
    });
    estreeWalker.walk(ast, {
        enter: (node) => {
            if (!node.trailingComments) {
                return;
            }
            node.trailingComments = node.trailingComments.filter((comment) => {
                return !rangesInLeadingComments.has(comment.range.join(','));
            });
        }
    });
}
213106
def clean(inputline, strip=True, rem_indents=True, encoding_errors="replace"):
    """"""
    stdout_encoding = get_encoding(sys.stdout)
    inputline = str(inputline)
    if rem_indents:
        inputline = inputline.replace(openindent, "").replace(closeindent, "")
    if strip:
        inputline = inputline.strip()
    return inputline.encode(stdout_encoding, encoding_errors).decode(stdout_encoding)
536510
def strip_line_magic_v3(cls,line):
        """"""

        matches = re.findall("run_line_magic\(([^]]+)", line)
        if matches and matches[0]: # This line contains the pattern
            match = matches[0]
            if match[-1] == ')':
                match = match[:-1] # Just because the re way is hard
            magic_kind,stripped = eval(match)
        else:
            stripped = line
            magic_kind = ""
        return stripped,magic_kind
472256
function(f) {
        var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,
            fn_text        = this.reflector.getProto()[this.name].toString().replace(STRIP_COMMENTS, '');

        return fn_text.substr(fn_text.indexOf('{') + 1, fn_text.lastIndexOf('}') - 4).replace(/}([^}]*)$/, '$1');
    }
24802
function removeComments(line) {
	var commentStartIndex = line.indexOf('#');
	if (commentStartIndex > -1) {
		return line.substr(0, commentStartIndex);
	}

	return line;
}
917488
private void cleanLeftEdge(int cutIndex) {
        if (cutIndex < (1 << 5)) {
            zeroLeft(pointer.display0, cutIndex);
        } else if (cutIndex < (1 << 10)) {
            zeroLeft(pointer.display0, cutIndex & 0x1f);
            pointer.display1 = copyRight(pointer.display1, (cutIndex >>> 5));
        } else if (cutIndex < (1 << 15)) {
            zeroLeft(pointer.display0, cutIndex & 0x1f);
            pointer.display1 = copyRight(pointer.display1, (cutIndex >>> 5) & 0x1f);
            pointer.display2 = copyRight(pointer.display2, (cutIndex >>> 10));
        } else if (cutIndex < (1 << 20)) {
            zeroLeft(pointer.display0, cutIndex & 0x1f);
            pointer.display1 = copyRight(pointer.display1, (cutIndex >>> 5) & 0x1f);
            pointer.display2 = copyRight(pointer.display2, (cutIndex >>> 10) & 0x1f);
            pointer.display3 = copyRight(pointer.display3, (cutIndex >>> 15));
        } else if (cutIndex < (1 << 25)) {
            zeroLeft(pointer.display0, cutIndex & 0x1f);
            pointer.display1 = copyRight(pointer.display1, (cutIndex >>> 5) & 0x1f);
            pointer.display2 = copyRight(pointer.display2, (cutIndex >>> 10) & 0x1f);
            pointer.display3 = copyRight(pointer.display3, (cutIndex >>> 15) & 0x1f);
            pointer.display4 = copyRight(pointer.display4, (cutIndex >>> 20));
        } else if (cutIndex < (1 << 30)) {
            zeroLeft(pointer.display0, cutIndex & 0x1f);
            pointer.display1 = copyRight(pointer.display1, (cutIndex >>> 5) & 0x1f);
            pointer.display2 = copyRight(pointer.display2, (cutIndex >>> 10) & 0x1f);
            pointer.display3 = copyRight(pointer.display3, (cutIndex >>> 15) & 0x1f);
            pointer.display4 = copyRight(pointer.display4, (cutIndex >>> 20) & 0x1f);
            pointer.display5 = copyRight(pointer.display5, (cutIndex >>> 25));
        } else {
            throw new IllegalArgumentException();
        }
    }
671494
def clean(string):
    '''  '''
    # manual fixes in the source
    # 24/1.png
    # 9/1.png
    # 3/1.png
    #if ')' in string:  # fix in the source data
        #string = string.split(')')[0] + ')'  # remove trailing garbage
    return (string
            .replace('_', '')
            .replace('-', '')
            .replace('—', '')
            .replace('.', '')
            .replace('=', '')
            .replace('\u2018',"'")  # LEFT SINGLE QUOTATION MARK
            .replace('\u2019', "'")  # RIGHT SINGLE QUOTATION MARK
            .strip())