Parse the input lines from a robots.txt file.

        We allow that a user-agent: line is not preceded by
        one or more blank lines.
485984
def parse(self, lines):
        
        # states:
        #   0: start state
        #   1: saw user-agent line
        #   2: saw an allow or disallow line
        state = 0
        entry = Entry()

        for line in lines:
            if not line:
                if state == 1:
                    entry = Entry()
                    state = 0
                elif state == 2:
                    self._add_entry(entry)
                    entry = Entry()
                    state = 0
            # remove optional comment and strip line
            i = line.find('#')
            if i >= 0:
                line = line[:i]
            line = line.strip()
            if not line:
                continue
            line = line.split(':', 1)
            if len(line) == 2:
                line[0] = line[0].strip().lower()
                line[1] = urllib.parse.unquote(line[1].strip())
                if line[0] == "user-agent":
                    if state == 2:
                        self._add_entry(entry)
                        entry = Entry()
                    entry.useragents.append(line[1])
                    state = 1
                elif line[0] == "disallow":
                    if state != 0:
                        entry.rulelines.append(RuleLine(line[1], False))
                        state = 2
                elif line[0] == "allow":
                    if state != 0:
                        entry.rulelines.append(RuleLine(line[1], True))
                        state = 2
        if state == 2:
            self._add_entry(entry)
173045
def parse(self, lines):
    

    if isinstance(lines, str):
      lines = lines.split('\n')
    sub = _re.sub
    for line in lines:
      if line.endswith('\n'):
        line = line[:-1]
      line = line.lstrip()
      if not line.startswith('#'):
        invert = False
        if line.startswith('!'):
          line = line[1:]
          invert = True
        while line.endswith(' ') and line[-2:] != '\ ':
          line = line[:-1]
        line = sub(r'\\([!# ])', r'\1', line)
        if '/' in line and not line.startswith('/'):
          # Patterns with a slash can only be matched absolute.
          line = '/' + line
        self.patterns.append(Pattern(line, invert))
556536
def parse_line(self, line: str) -> None:
        
        if line[0].isspace():
            # continuation of a multi-line header
            if self._last_key is None:
                raise HTTPInputError("first header line cannot start with whitespace")
            new_part = " " + line.lstrip()
            self._as_list[self._last_key][-1] += new_part
            self._dict[self._last_key] += new_part
        else:
            try:
                name, value = line.split(":", 1)
            except ValueError:
                raise HTTPInputError("no colon in header line")
            self.add(name, value.strip())
137194
def _read_parsed(self, lines):
        
        self.log(u"Parsing fragments from parsed text format")
        pairs = []
        for line in lines:
            pieces = line.split(gc.PARSED_TEXT_SEPARATOR)
            if len(pieces) == 2:
                identifier = pieces[0].strip()
                text = pieces[1].strip()
                if len(identifier) > 0:
                    pairs.append((identifier, [text]))
        self._create_text_fragments(pairs)
1298130
def readlines(self):
        
        continuation = False
        while True:
            yield self.readline(continuation)
            continuation = True
1008372
def line_data(line:str) -> tuple:
    
    for regex, _ in LINE_TYPES.items():
        match = re.fullmatch(regex, line)
        if match:
            return match.groups()
    raise ValueError("Input line \"{}\" is not bubble formatted".format(line))
77265
def _parse_line(sep, line):
    
    strs = line.split(sep, 1)
    return (strs[0].strip(), None) if len(strs) == 1 else (strs[0].strip(), strs[1].strip())
761391
def parse_lines(stream, separator=None):
    
    separator = None if separator is None else unicode(separator)
    for line in stream:
        line = line.rstrip(u'\r\n')
        row = [interpret_segment(i) for i in line.split(separator)]
        yield line, row
110369
def parse(self, lines):
        
        patterns = [re.compile(r'^(.+?):(\d+)'),
                    re.compile(r'^\s+(.+)$')]
        for i, line in enumerate(lines):
            if i % 2 == 0:
                path, line_nr = patterns[0].match(line).groups()
            else:
                msg = patterns[1].match(line).group(1)
                yield LinterOutput(self.name, path, msg, line_nr)
153751
def gen_lines_from_textfiles(
        files: Iterable[TextIO]) -> Generator[str, None, None]:
    
    for file in files:
        for line in file:
            yield line
878216
def parse_line(self, line):
        

        # Skip blanks
        if line == '':
            return

        # Skip comments
        if regex_comment.search(line):
            return

        # Special case / header: parse global parameters into metadata
        global_parameters = regex_global.search(line)
        if global_parameters:
            self.parse_global_meta(global_parameters.group('parameters'))
            return

        # Tries to check the validity of the line.
        crtf_line = regex_line.search(line)
        if crtf_line:
            # Tries to parse the line.

            # Finds info about the region.
            region = regex_region.search(crtf_line.group('region'))
            type_ = region.group('type') or 'reg'
            include = region.group('include') or '+'
            region_type = region.group('regiontype').lower()
            if region_type in self.valid_definition:
                helper = CRTFRegionParser(self.global_meta, include, type_, region_type,
                                          *crtf_line.group('region', 'parameters'))
                self.shapes.append(helper.shape)
            else:
                self._raise_error("Not a valid CRTF Region type: '{0}'.".format(region_type))

        else:
            self._raise_error("Not a valid CRTF line: '{0}'.".format(line))
            return
821702
def _line_parse(line):
    
    if line[-2:] in ['\r\n', b'\r\n']:
        return line[:-2], True
    elif line[-1:] in ['\r', '\n', b'\r', b'\n']:
        return line[:-1], True
    return line, False
332862
def parse_line(line):
    '''  '''
    line = line.rstrip()
    line_type = _get_line_type(line)
    return TabLine(
        type=line_type,
        data=_DATA_PARSERS[line_type](line),
        original=line,
    )
662064
def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
        
        source = None
        if loader is not None and hasattr(loader, "get_source"):
            try:
                source = loader.get_source(module_name)
            except ImportError:
                pass
            if source is not None:
                source = source.splitlines()
        if source is None:
            try:
                with open(filename, 'rb') as fp:
                    source = fp.read().splitlines()
            except (OSError, IOError):
                pass
        if source is None:
            return None, [], None, []

        # If we just read the source from a file, or if the loader did not
        # apply tokenize.detect_encoding to decode the source into a Unicode
        # string, then we should do that ourselves.
        if isinstance(source[0], six.binary_type):
            encoding = 'ascii'
            for line in source[:2]:
                # File coding may be specified. Match pattern from PEP-263
                # (http://www.python.org/dev/peps/pep-0263/)
                match = re.search(br'coding[:=]\s*([-\w.]+)', line)
                if match:
                    encoding = match.group(1).decode('ascii')
                    break
            source = [six.text_type(sline, encoding, 'replace') for sline in source]

        lower_bound = max(0, lineno - context_lines)
        upper_bound = lineno + context_lines

        pre_context = source[lower_bound:lineno]
        context_line = source[lineno]
        post_context = source[lineno + 1:upper_bound]

        return lower_bound, pre_context, context_line, post_context
1205516
def _parse_line(line=''):
    '''
    
    '''
    parts = line.split()
    key = parts.pop(0)
    value = ' '.join(parts)
    return key, value
768701
public void parse(InputStream is) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(
				(InputStream) is));
        String read;
        ArrayList<String> current = null;
        while (br != null) {
            do {
                read = br.readLine();
                // Skip comments & blanks
            } while ((read != null) && ((read = read.trim()).startsWith("#") ||
                read.length() == 0));
            if (read == null) {
            	br.close();
            	br = null;
            } else {
                int commentIndex = read.indexOf("#");
                if (commentIndex > -1) {
                    // Strip trailing comment
                    read = read.substring(0, commentIndex);
                }
                read = read.trim();
                if (read.matches("(?i)^User-agent:.*")) {
                    String ua = read.substring(11).trim().toLowerCase();
                    if (current == null || current.size() != 0) {
                        // only create new rules-list if necessary
                        // otherwise share with previous user-agent
                        current = new ArrayList<String>();
                    }
                    rules.put(ua, current);
                    LOGGER.fine("Found User-agent(" + ua + ") rules...");
                    continue;
                }
                if (read.matches("(?i)Disallow:.*")) {
                    if (current == null) {
                        // buggy robots.txt
                    	bSyntaxErrors = true;
                        continue;
                    }
                    String path = read.substring(9).trim();
                    current.add(path);
                    continue;
                }
                // unknown line; do nothing for now
                
                // TODO: check for "Allow" lines, and flag a syntax error if 
                //       we encounter any unknown lines?
            }
        }
    }
545661
def from_lines(lines: Iterable[str], **kwargs) -> BELGraph:
    
    graph = BELGraph()
    parse_lines(graph=graph, lines=lines, **kwargs)
    return graph