Load a BEL graph from an iterable over the lines of a BEL script.

    :param lines: An iterable of strings (the lines in a BEL script)

    The remaining keyword arguments are passed to :func:`pybel.io.line_utils.parse_lines`.
545661
def from_lines(lines: Iterable[str], **kwargs) -> BELGraph:
    
    graph = BELGraph()
    parse_lines(graph=graph, lines=lines, **kwargs)
    return graph
244214
def parse_columns(lines):
    
    data = []
    index = []
    for line in lines:
        line = line.rstrip()
        if line.startswith("#"):
            tmp = __parse_entry(line)
            data.append(tmp[1])
            index.append(tmp[0])

    return DataFrame(data, index=index, columns=['description'])
211933
def decode(cls, line):
        
        if line.encoded:
            line.value = stringToTextValues(line.value,
                listSeparator=cls.listSeparator)
            line.encoded=False
1369724
def parse(self, lines):
        ''''''
        if self.type == 'msdos':
            return self.parse_msdos(lines)
        elif self.type == 'unix':
            return self.parse_unix(lines)
        elif self.type == 'nlst':
            return self.parse_nlst(lines)
        else:
            raise UnknownListingError('Unsupported listing type.')
709290
function parse(lines) {
  var i, line, key, parts, values;

  for(i = 0;i < lines.length;i++) {
    line = lines[i];
    this.lineNumber++;

    // ignore comments and whitespace lines
    if(COMMENT.test(line) || WHITESPACE.test(line)) {
      continue;
    // got something to parse
    }else{

      // strip empty entires, leading whitespace is allowed
      parts = line.split(/\s+/).filter(function(p) {
        return p;
      })

      // get the config key
      key = parts[0];

      // remaining parts to parse as values
      values = parts.slice(1);
      try {
        this.conf.add(key, values, this.lineNumber);
      }catch(e) {
        throw new ConfigError(this.lineNumber, line, this.file, e);
      }
    }
  }
}
342977
def parse_values_from_lines(self,lines,iskeyword=False):
        

        if iskeyword:
            extra = {}
            for line in lines:
                raw = line.strip().split()
                if len(raw) == 0 or raw[0] == "#":
                    continue
                name = raw[0].strip().lower()

                value = raw[1].strip()
                v,t,f = self._parse_value(value)
                if name not in self._df.index:
                    extra[name] = v
                else:
                    # if the parsed values type isn't right
                    if t != self._df.loc[name, "type"]:

                        # if a float was expected and int return, not a problem
                        if t == np.int32 and self._df.loc[name, "type"] == np.float64:
                            self._df.loc[name, "value"] = np.float64(v)


                        # if this is a required input, throw
                        elif self._df.loc[name, "required"]:
                            raise Exception("wrong type found for variable " + name + ":" + str(t))
                        else:

                            # else, since this problem is usually a string, check for acceptable values
                            found = False
                            for nname, avalues in self.accept_values.items():
                                if v in avalues:
                                    if t == self._df.loc[nname, "type"]:
                                        self._df.loc[nname, "value"] = v
                                        found = True
                                        break
                            if not found:
                                warnings.warn("non-conforming value found for " + \
                                              name + ":" + str(v) + "...ignoring", PyemuWarning)


                    else:
                        self._df.loc[name, "value"] = v
            return extra




        assert len(lines) == len(CONTROL_VARIABLE_LINES),\
        "ControlData error: len of lines not equal to " +\
        str(len(CONTROL_VARIABLE_LINES))

        for iline,line in enumerate(lines):
            vals = line.strip().split()
            names = CONTROL_VARIABLE_LINES[iline].strip().split()
            for name,val in zip(names,vals):
                v,t,f = self._parse_value(val)
                name = name.replace('[','').replace(']','')
                
                #if the parsed values type isn't right
                if t != self._df.loc[name,"type"]:

                    # if a float was expected and int return, not a problem
                    if t == np.int32 and self._df.loc[name,"type"] == np.float64:
                        self._df.loc[name,"value"] = np.float64(v)


                    # if this is a required input, throw
                    elif self._df.loc[name,"required"]:
                        raise Exception("wrong type found for variable " + name + ":" + str(t))
                    else:
                        
                        #else, since this problem is usually a string, check for acceptable values
                        found = False
                        for nname,avalues in self.accept_values.items():
                            if v in avalues:
                                if t == self._df.loc[nname,"type"]:
                                    self._df.loc[nname,"value"] = v
                                    found = True
                                    break
                        if not found:
                            warnings.warn("non-conforming value found for " +\
                                  name + ":" + str(v) + "...ignoring",PyemuWarning)


                else:
                    self._df.loc[name,"value"] = v
850831
def parser(self, lines):
        """"""
        while len(lines) > 0:
            if lines[0].startswith('##') and lines[1].startswith('# '):
                # A two-line keyword/value line starts here.
                self._header_append(lines.pop(0), lines.pop(0))
            elif lines[0].startswith('# '):
                # Lines with single comments are exposure numbers unless preceeded by double comment line
                self._append_file_id(lines.pop(0))
            elif lines[0].startswith('##'):
                # Double comment lines without a single comment following are column headers for dataset.
                self._set_column_names(lines.pop(0)[2:])
            else:
                # Last line of the header reached.
                return self
        raise IOError("Failed trying to read header")
485939
def load(self, text, fieldnames=None):
    """"""
    lines = text.split('\n')
    fieldnames = load_line(lines[0])
    values = load_line(lines[1])
    self.__dict__ = dict(zip(fieldnames, values))
1263041
def _get_lines_from_node_text(cls, node):
        
        # TODO more robust parsing
        from lxml import etree
        parts = ([node.text] + list(chain(*([etree.tostring(c, with_tail=False), c.tail] for c in node.getchildren()))) + [node.tail])
        parts = [gf.safe_unicode(p) for p in parts]
        parts = [p.strip() for p in parts if not p.startswith(u"<br ")]
        parts = [p for p in parts if len(p) > 0]
        uparts = []
        for part in parts:
            uparts.append(gf.safe_unicode(part))
        return uparts
170898
async def _parse_lines(lines, regex):
    
    results = []
    if inspect.iscoroutinefunction(lines):
        lines = await lines
    for line in lines:
        if line:
            match = regex.search(line)
            if not match:
                _LOGGER.debug("Could not parse row: %s", line)
                continue
            results.append(match.groupdict())
    return results
318058
def _parse_script(list, line, line_iter):
    
    ifIdx = 0
    while (True):
        line = next(line_iter)
        if line.startswith("fi"):
            if ifIdx == 0:
                return
            ifIdx -= 1
        elif line.startswith("if"):
            ifIdx += 1
432971
def iter_lines(f):
    
    linenum = 1
    try:
        for text in f.readlines():
            # ignore lines that consist entirely of whitespace
            if text.isspace():
                continue
            indent,value = parse_line(text)
            yield linenum,indent,value
            linenum += 1
    except:
        raise ParserError(linenum, 0, '', 'failed to parse line')
834975
def _lines(self):
        

        chunkIndices = self._listChunks()
        for chunkIndex in chunkIndices:
            with self._openChunk(chunkIndex) as chunk:
                yield from chunk._lines()
835478
def get_lines(handle, line):
    
    for i, l in enumerate(handle):
        if i == line:
            return l
1354032
def split(line, lines):
    
    out = empty((len(lines) + 1, 4))

    p1 = line[:2]
    for n, l2 in enumerate(lines):
        p2 = intersection(line, l2)
        out[n][:2] = p1
        out[n][2:] = p2
        p1 = p2
    out[n + 1][:2] = p2
    out[n + 1][2:] = line[2:]
    return out
603835
def _parse_header(lines):
    
    header_count = _extract_header_number(lines)
    header_dict = {}
    for i in range(2, header_count + 2):
        pair = _extract_header_value(lines[i])

        if not pair:  # Ignore empty strings
            continue

        header_dict.update(pair)
    return header_dict
13861
def _split_lines(self):
        ''''''
        parsed_lines = {}
        for rt in all_record_types:
            parsed_lines[rt] = []
        parsed_lines[0] = []

        for line in self.lines:
            linetype = line[0:6]
            if linetype in all_record_types:
                parsed_lines[linetype].append(line)
            else:
                parsed_lines[0].append(line)

        self.parsed_lines = parsed_lines
        self._update_structure_lines()