Parses a comment.

    Args:
      structure (pyparsing.ParseResults): structure parsed from the log file.
960890
def _ParseComment(self, structure):
    
    if structure[1] == 'Date:':
      self._year, self._month, self._day_of_month, _, _, _ = structure.date_time
    elif structure[1] == 'Fields:':
      self._ParseFieldsMetadata(structure)
1341825
def sort_untl(self, sort_structure):
        
        self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
621026
def __parse(self, lines):
        

        # Every line in the file must consist of either a comment
        # or a key-value pair. A key-value pair is a line consisting
        # of a key which is a combination of non-white space characters
        # The separator character between key-value pairs is a '=',
        # ':' or a whitespace character not including the newline.
        # If the '=' or ':' characters are found, in the line, even
        # keys containing whitespace chars are allowed.

        # A line with only a key according to the rules above is also
        # fine. In such case, the value is considered as the empty string.
        # In order to include characters '=' or ':' in a key or value,
        # they have to be properly escaped using the backslash character.

        # Some examples of valid key-value pairs:
        #
        # key     value
        # key=value
        # key:value
        # key     value1,value2,value3
        # key     value1,value2,value3 \
        #         value4, value5
        # key
        # This key= this value
        # key = value1 value2 value3

        # Any line that starts with a '#' or '!' is considerered a comment
        # and skipped. Also any trailing or preceding whitespaces
        # are removed from the key/value.

        # This is a line parser. It parses the
        # contents like by line.

        lineno=0
        i = iter(lines)

        for line in i:
            lineno += 1
            line = line.strip()
            # Skip null lines
            if not line: continue
            # Skip lines which are comments
            if line[0] in ('#','!'): continue
            # Some flags
            escaped=False
            # Position of first separation char
            sepidx = -1
            # A flag for performing wspace re check
            flag = 0
            # Check for valid space separation
            # First obtain the max index to which we
            # can search.
            m = self.othercharre.search(line)
            if m:
                first, last = m.span()
                start, end = 0, first
                flag = 1
                wspacere = re.compile(r'(?<![\\\=\:])(\s)')
            else:
                if self.othercharre2.search(line):
                    # Check if either '=' or ':' is present
                    # in the line. If they are then it means
                    # they are preceded by a backslash.

                    # This means, we need to modify the
                    # wspacere a bit, not to look for
                    # : or = characters.
                    wspacere = re.compile(r'(?<![\\])(\s)')
                start, end = 0, len(line)

            m2 = wspacere.search(line, start, end)
            if m2:
                # print 'Space match=>',line
                # Means we need to split by space.
                first, last = m2.span()
                sepidx = first
            elif m:
                # print 'Other match=>',line
                # No matching wspace char found, need
                # to split by either '=' or ':'
                first, last = m.span()
                sepidx = last - 1
                # print line[sepidx]


            # If the last character is a backslash
            # it has to be preceded by a space in which
            # case the next line is read as part of the
            # same property
            while line[-1] == '\\':
                # Read next line
                nextline = next(i)
                nextline = nextline.strip()
                lineno += 1
                # This line will become part of the value
                line = line[:-1] + nextline

            # Now split to key,value according to separation char
            if sepidx != -1:
                key, value = line[:sepidx], line[sepidx+1:]
            else:
                key,value = line,''
            self._keyorder.append(key)
            self.process_pair(key, value)
331428
def parse_py_statement(line):
    
    state = 0
    cur_token = ""
    spaces = " \t\n"
    ops = ".,;:+-*/%&!=|(){}[]^<>"
    i = 0

    def _escape_char(_c):
        if _c == "n":
            return "\n"
        elif _c == "t":
            return "\t"
        else:
            return _c

    while i < len(line):
        c = line[i]
        i += 1
        if state == 0:
            if c in spaces:
                pass
            elif c in ops:
                yield ("op", c)
            elif c == "#":
                state = 6
            elif c == "\"":
                state = 1
            elif c == "'":
                state = 2
            else:
                cur_token = c
                state = 3
        elif state == 1:  # string via "
            if c == "\\":
                state = 4
            elif c == "\"":
                yield ("str", cur_token)
                cur_token = ""
                state = 0
            else:
                cur_token += c
        elif state == 2:  # string via '
            if c == "\\":
                state = 5
            elif c == "'":
                yield ("str", cur_token)
                cur_token = ""
                state = 0
            else:
                cur_token += c
        elif state == 3:  # identifier
            if c in spaces + ops + "#\"'":
                yield ("id", cur_token)
                cur_token = ""
                state = 0
                i -= 1
            else:
                cur_token += c
        elif state == 4:  # escape in "
            cur_token += _escape_char(c)
            state = 1
        elif state == 5:  # escape in '
            cur_token += _escape_char(c)
            state = 2
        elif state == 6:  # comment
            cur_token += c
    if state == 3:
        yield ("id", cur_token)
    elif state == 6:
        yield ("comment", cur_token)
895943
def parse(self, scode, args_chain=None, join_with=None, default=''):
        
        assert args_chain and isinstance(
            args_chain, (list, tuple)
        ) and isinstance(args_chain[0], (list, tuple)), ValueError(
            'args_chain type should be list of list, like: [["1-n", "html", "p", "html"], ["n-n", "html", "p", "text"]].'
        )
        for arg in args_chain:
            # py2 not support * unpack
            one_to_many, parser_name, parse_args = (arg[0], arg[1], arg[2:])
            assert self._re.match(
                '^[1n]-[1n]$',
                one_to_many), 'one_to_many should be one of 1-1, 1-n, n-n, n-1'
            input_count, output_count = one_to_many.split('-')
            parser = self._choose_parser(parser_name)
            # input data to parse.
            if input_count == 'n':
                scode = list(map(lambda item: parser(item, *parse_args), scode))
            if input_count == '1':
                if parser not in (self.jsonpath_parser, self.objectpath_parser,
                                  self.python_parser):
                    # json may remain multi-items
                    scode = get_one(scode, default=default)
                scode = parser(scode, *parse_args)
            # ensure result match n or 1 after parsing.
            if parser in (self.objectpath_parser,):
                # objectpath not need
                continue
            if output_count == '1':
                # 1-1 or n-1
                scode = get_one(scode, default=default)
            elif input_count == 'n':
                # n-n
                scode = [get_one(i, default=default) for i in scode]
            else:
                # 1-n
                scode = list(scode)
        if join_with:
            scode = join_with.join(map(str, scode))
        return scode
1111744
def comment_parser(comment):
    
    try:
        if comment['type'] != 'comment':
            return item_parser(comment)
    except KeyError:
        return deleted_parser(comment)
    return Comment(
        comment['id'],
        comment['by'],
        __check_key('kids', comment),  # some comments do not have kids key
        comment['parent'],
        comment['text'],
        comment['time'],
        comment['type'],
    )
404237
def Parse(factory, file):
    

    entities = []

    while 1:
        # Just gets the whole struct nicely formatted
        data = GetNextStruct(file)

        if not data:
            break

        entities.extend(ProcessStruct(factory, data))

    return entities
885154
def parse_comment(comment):
    
    names, vals = [], []
    pieces = comment.split('=')
    for i, piece in enumerate(pieces):
        if i == 0:  # first line
            names.append(piece.strip())
        elif i == len(pieces) - 1:  # last line
            vals.append(ast.literal_eval(piece))
        else:
            val, name = piece.rsplit(',', 1)
            vals.append(ast.literal_eval(val))
            names.append(name.strip())
    return list(zip(names, vals))
957725
def read(*components, **kwargs):
    
    rstrip = kwargs.get("rstrip", True)
    comment_char = kwargs.get("comment_char", None)

    ignore_comments = comment_char is not None

    file = open(path(*components))
    lines = file.readlines()
    file.close()

    # Multiple definitions to handle all cases.
    if ignore_comments:
        comment_line_re = re.compile("^\s*{char}".format(char=comment_char))
        not_comment_re = re.compile("[^{char}]+".format(char=comment_char))

        if rstrip:
            # Ignore comments, and right strip results.
            return [re.match(not_comment_re, line).group(0).rstrip()
                    for line in lines
                    if not re.match(comment_line_re, line)]
        else:
            # Ignore comments, and don't strip results.
            return [re.match(not_comment_re, line).group(0)
                    for line in lines
                    if not re.match(comment_line_re, line)]
    elif rstrip:
        # No comments, and right strip results.
        return [line.rstrip() for line in lines]
    else:
        # Just a good old-fashioned read!
        return lines
963481
def _comment_system_for_file(contents):
    """"""
    if contents[0] == "#":
        return FileCommentSystem(begin="#", middle="", end="", single="#")
    elif contents[:2] == "/*":
        return FileCommentSystem(begin="/*", middle="*", end="*/", single="//")
    elif contents[:2] == "//":
        return FileCommentSystem(begin="//", middle="//", end="", single="//")
    elif contents[:3] == "rem":
        return FileCommentSystem(begin="rem",
                                 middle="rem",
                                 end="",
                                 single="rem")
    else:
        raise RuntimeError("Couldn't detect comment "
                           "system from {0}".format(contents[:3]))
451754
def VerifyStructure(self, parser_mediator, line):
    
    try:
      structure = self._DPKG_LOG_LINE.parseString(line)
    except pyparsing.ParseException as exception:
      logger.debug(
          'Unable to parse Debian dpkg.log file with error: {0!s}'.format(
              exception))
      return False

    return 'date_time' in structure and 'body' in structure
797014
def parse(source, remove_comments=True, **kw):
    """"""
    return ElementTree.parse(source, SourceLineParser(), **kw)
380117
def parse_comments(document, xmlcontent):
    

    comments = etree.fromstring(xmlcontent)
    document.comments = {}

    for comment in comments.xpath('.//w:comment', namespaces=NAMESPACES):
        # w:author
        # w:id
        # w: date
        comment_id = comment.attrib[_name('{{{w}}}id')]

        comm = doc.CommentContent(comment_id)
        comm.author = comment.attrib.get(_name('{{{w}}}author'), None)
        comm.date = comment.attrib.get(_name('{{{w}}}date'), None)

        comm.elements = [parse_paragraph(document, para) for para in comment.xpath('.//w:p', namespaces=NAMESPACES)]

        document.comments[comment_id] = comm
631820
def parse(cls, raw):
        
        msg = cls()
        for line in raw.splitlines():
            m = cls.sse_line_pattern.match(line)
            if m is None:
                # Malformed line.  Discard but warn.
                warnings.warn('Invalid SSE line: "%s"' % line, SyntaxWarning)
                continue

            name = m.group('name')
            if name == '':
                # line began with a ":", so is a comment.  Ignore
                continue
            value = m.group('value')

            if name == 'data':
                # If we already have some data, then join to it with a newline.
                # Else this is it.
                if msg.data:
                    msg.data = '%s\n%s' % (msg.data, value)
                else:
                    msg.data = value
            elif name == 'event':
                msg.event = value
            elif name == 'id':
                msg.id = value
            elif name == 'retry':
                msg.retry = int(value)

        return msg
744822
void parse(Reader reader) throws ParseException {
        if (reader == null) {
            //just log and return default properties
            Log.warn("parsing NULL reader, so fallback on default configuration!");
            return;
        }
        
        BufferedReader br = new BufferedReader(reader);
        String line;
        try {
            while ((line = br.readLine()) != null) {
                int commentMarker = line.indexOf('#');
                if (commentMarker != -1) {
                    if (commentMarker == 0) {
                        //skip its a comment
                        continue;
                    } else {
                        //it's a malformed comment
                        throw new ParseException(line, commentMarker);
                    }
                } else {
                    if (line.isEmpty() || line.matches("^\\s*$")) {
                        //skip it's a black line
                        continue;
                    }
                    
                    //split till the first space
                    int deilimiterIdx = line.indexOf(' ');
                    String key = line.substring(0, deilimiterIdx).trim();
                    String value = line.substring(deilimiterIdx).trim();
                    
                    m_properties.put(key, value);
                }
            }
        } catch (IOException ex) {
            throw new ParseException("Failed to read", 1);
        }
    }
276990
def parse(self):
        
        index_server = None
        for num, line in enumerate(self.iter_lines()):
            line = line.rstrip()
            if not line:
                continue
            if line.startswith('#'):
                # comments are lines that start with # only
                continue
            if line.startswith('-i') or \
                line.startswith('--index-url') or \
                line.startswith('--extra-index-url'):
                # this file is using a private index server, try to parse it
                index_server = self.parse_index_server(line)
                continue
            elif self.obj.path and (line.startswith('-r') or line.startswith('--requirement')):
                self.obj.resolved_files.append(self.resolve_file(self.obj.path, line))
            elif line.startswith('-f') or line.startswith('--find-links') or \
                line.startswith('--no-index') or line.startswith('--allow-external') or \
                line.startswith('--allow-unverified') or line.startswith('-Z') or \
                line.startswith('--always-unzip'):
                continue
            elif self.is_marked_line(line):
                continue
            else:
                try:

                    parseable_line = line

                    # multiline requirements are not parseable
                    if "\\" in line:
                        parseable_line = line.replace("\\", "")
                        for next_line in self.iter_lines(num + 1):
                            parseable_line += next_line.strip().replace("\\", "")
                            line += "\n" + next_line
                            if "\\" in next_line:
                                continue
                            break
                        # ignore multiline requirements if they are marked
                        if self.is_marked_line(parseable_line):
                            continue

                    hashes = []
                    if "--hash" in parseable_line:
                        parseable_line, hashes = Parser.parse_hashes(parseable_line)

                    req = RequirementsTXTLineParser.parse(parseable_line)
                    if req:
                        req.hashes = hashes
                        req.index_server = index_server
                        # replace the requirements line with the 'real' line
                        req.line = line
                        self.obj.dependencies.append(req)
                except ValueError:
                    continue
638021
def comment(parent, indent)
      return unless accept :comment

      # Get first comment line
      buffer = accept(:line_feed)
      buffer += accept(:newline) || ''

      # Get indented comment lines
      buffer += get_indented_lines indent

      # If we have a comment which is visible in the output, we will
      # create a new comment element. Otherwise, we ignore the current
      # gathered text and we simply begin the root parsing again
      if buffer[0] == '!'
        offset = 1
        options = {}

        # Allow leading comment newline
        if buffer[1] == '^'
          offset = 2
          options[:newline] = true
        end

        parent[@children] << [
          :comment,
          buffer[offset..-1].strip,
          options,
          nil,
          indent
        ]
      end

      parent
    end