src/pybel/io/line_utils.py
def parse_statements(
    graph: BELGraph,
    enumerated_lines: Iterable[Tuple[int, str]],
    bel_parser: BELParser,
    use_tqdm: bool = True,
    tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
    """Parse a list of statements from a BEL Script.

    :param graph: A BEL graph
    :param enumerated_lines: An enumerated iterable over the lines in the statements section of a BEL script
    :param bel_parser: A BEL parser
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar? Requires reading whole file to memory.
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    """
    parse_statements_start_time = time.time()

    if use_tqdm:
        tqdm_kwargs = {} if tqdm_kwargs is None else dict(tqdm_kwargs)
        tqdm_kwargs.setdefault('desc', 'Statements')
        tqdm_kwargs.setdefault('leave', False)
        enumerated_lines = tqdm(list(enumerated_lines), **tqdm_kwargs)

    for line_number, line in enumerated_lines:
        try:
            bel_parser.parseString(line, line_number=line_number)
        except ParseException as e:
            exc = BELSyntaxError(line_number, line, e.loc)
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except PlaceholderAminoAcidWarning as exc:
            exc.line_number = line_number
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except BELParserWarning as exc:
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except Exception:
            parser_logger.exception(LOG_FMT, line_number, 0, 'General Failure', line)
            raise

    logger.info(
        'Parsed statements section in %.02f seconds with %d warnings',
        time.time() - parse_statements_start_time,
        len(graph.warnings),
    )
Parse a list of statements from a BEL Script.

    :param graph: A BEL graph
    :param enumerated_lines: An enumerated iterable over the lines in the statements section of a BEL script
    :param bel_parser: A BEL parser
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar? Requires reading whole file to memory.
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    
Parse a list of statements from a BEL Script.
Parse a list of statements from a BEL Script .
def parse_statements(
    graph: BELGraph,
    enumerated_lines: Iterable[Tuple[int, str]],
    bel_parser: BELParser,
    use_tqdm: bool = True,
    tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
    parse_statements_start_time = time.time()
    if use_tqdm:
        tqdm_kwargs = {} if tqdm_kwargs is None else dict(tqdm_kwargs)
        tqdm_kwargs.setdefault('desc', 'Statements')
        tqdm_kwargs.setdefault('leave', False)
        enumerated_lines = tqdm(list(enumerated_lines), **tqdm_kwargs)
    for line_number, line in enumerated_lines:
        try:
            bel_parser.parseString(line, line_number=line_number)
        except ParseException as e:
            exc = BELSyntaxError(line_number, line, e.loc)
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except PlaceholderAminoAcidWarning as exc:
            exc.line_number = line_number
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except BELParserWarning as exc:
            _log_parse_exception(graph, exc)
            graph.add_warning(exc, bel_parser.get_annotations())
        except Exception:
            parser_logger.exception(LOG_FMT, line_number, 0, 'General Failure', line)
            raise
    logger.info(
        'Parsed statements section in %.02f seconds with %d warnings',
        time.time() - parse_statements_start_time,
        len(graph.warnings),
    )
def parse_statements ( graph : BELGraph , enumerated_lines : Iterable [ Tuple [ int , str ] ] , bel_parser : BELParser , use_tqdm : bool = True , tqdm_kwargs : Optional [ Mapping [ str , Any ] ] = None , ) -> None : parse_statements_start_time = time . time ( ) if use_tqdm : tqdm_kwargs = { } if tqdm_kwargs is None else dict ( tqdm_kwargs ) tqdm_kwargs . setdefault ( 'desc' , 'Statements' ) tqdm_kwargs . setdefault ( 'leave' , False ) enumerated_lines = tqdm ( list ( enumerated_lines ) , ** tqdm_kwargs ) for line_number , line in enumerated_lines : try : bel_parser . parseString ( line , line_number = line_number ) except ParseException as e : exc = BELSyntaxError ( line_number , line , e . loc ) _log_parse_exception ( graph , exc ) graph . add_warning ( exc , bel_parser . get_annotations ( ) ) except PlaceholderAminoAcidWarning as exc : exc . line_number = line_number _log_parse_exception ( graph , exc ) graph . add_warning ( exc , bel_parser . get_annotations ( ) ) except BELParserWarning as exc : _log_parse_exception ( graph , exc ) graph . add_warning ( exc , bel_parser . get_annotations ( ) ) except Exception : parser_logger . exception ( LOG_FMT , line_number , 0 , 'General Failure' , line ) raise logger . info ( 'Parsed statements section in %.02f seconds with %d warnings' , time . time ( ) - parse_statements_start_time , len ( graph . warnings ) , )
Parse a list of statements from a BEL Script.
Parse a list of statements from a BEL Script .
"""Parse a list of statements from a BEL Script.

    :param graph: A BEL graph
    :param enumerated_lines: An enumerated iterable over the lines in the statements section of a BEL script
    :param bel_parser: A BEL parser
    :param use_tqdm: Use :mod:`tqdm` to show a progress bar? Requires reading whole file to memory.
    :param tqdm_kwargs: Keywords to pass to ``tqdm``
    """
graph
BELGraph
A BEL graph
A BEL graph
enumerated_lines
Iterable[Tuple[int, str]]
An enumerated iterable over the lines in the statements section of a BEL script
An enumerated iterable over the lines in the statements section of a BEL script
bel_parser
BELParser
A BEL parser
A BEL parser
use_tqdm
bool
Use :mod:`tqdm` to show a progress bar. Requires reading whole file to memory.
Use : mod : ` tqdm ` to show a progress bar . Requires reading whole file to memory .
tqdm_kwargs
Optional[Mapping[str, Any]]
Keywords to pass to ``tqdm``
Keywords to pass to ` ` tqdm ` `