src/pybel/io/line_utils.py
def parse_document(
    graph: BELGraph,
    enumerated_lines: Iterable[Tuple[int, str]],
    metadata_parser: MetadataParser,
) -> None:
    """Parse the lines in the document section of a BEL script."""
    parse_document_start_time = time.time()

    for line_number, line in enumerated_lines:
        try:
            metadata_parser.parseString(line, line_number=line_number)
        except VersionFormatWarning as exc:
            _log_parse_exception(graph, exc)
            graph.add_warning(exc)
        except Exception as e:
            exc = MalformedMetadataException(line_number, line, 0)
            _log_parse_exception(graph, exc)
            raise exc from e

    for required in REQUIRED_METADATA:
        required_metadatum = metadata_parser.document_metadata.get(required)
        if required_metadatum is not None:
            continue

        required_metadatum_key = INVERSE_DOCUMENT_KEYS[required]
        # This has to be insert since it needs to go on the front!
        exc = MissingMetadataException.make(required_metadatum_key)
        graph.warnings.insert(0, (None, exc, {}))
        _log_parse_exception(graph, exc)

    graph.document.update(metadata_parser.document_metadata)

    logger.info('Finished parsing document section in %.02f seconds', time.time() - parse_document_start_time)
Parse the lines in the document section of a BEL script.
Parse the lines in the document section of a BEL script.
Parse the lines in the document section of a BEL script .
def parse_document(
    graph: BELGraph,
    enumerated_lines: Iterable[Tuple[int, str]],
    metadata_parser: MetadataParser,
) -> None:
    parse_document_start_time = time.time()
    for line_number, line in enumerated_lines:
        try:
            metadata_parser.parseString(line, line_number=line_number)
        except VersionFormatWarning as exc:
            _log_parse_exception(graph, exc)
            graph.add_warning(exc)
        except Exception as e:
            exc = MalformedMetadataException(line_number, line, 0)
            _log_parse_exception(graph, exc)
            raise exc from e
    for required in REQUIRED_METADATA:
        required_metadatum = metadata_parser.document_metadata.get(required)
        if required_metadatum is not None:
            continue
        required_metadatum_key = INVERSE_DOCUMENT_KEYS[required]
        exc = MissingMetadataException.make(required_metadatum_key)
        graph.warnings.insert(0, (None, exc, {}))
        _log_parse_exception(graph, exc)
    graph.document.update(metadata_parser.document_metadata)
    logger.info('Finished parsing document section in %.02f seconds', time.time() - parse_document_start_time)
def parse_document ( graph : BELGraph , enumerated_lines : Iterable [ Tuple [ int , str ] ] , metadata_parser : MetadataParser , ) -> None : parse_document_start_time = time . time ( ) for line_number , line in enumerated_lines : try : metadata_parser . parseString ( line , line_number = line_number ) except VersionFormatWarning as exc : _log_parse_exception ( graph , exc ) graph . add_warning ( exc ) except Exception as e : exc = MalformedMetadataException ( line_number , line , 0 ) _log_parse_exception ( graph , exc ) raise exc from e for required in REQUIRED_METADATA : required_metadatum = metadata_parser . document_metadata . get ( required ) if required_metadatum is not None : continue required_metadatum_key = INVERSE_DOCUMENT_KEYS [ required ] exc = MissingMetadataException . make ( required_metadatum_key ) graph . warnings . insert ( 0 , ( None , exc , { } ) ) _log_parse_exception ( graph , exc ) graph . document . update ( metadata_parser . document_metadata ) logger . info ( 'Finished parsing document section in %.02f seconds' , time . time ( ) - parse_document_start_time )
Parse the lines in the document section of a BEL script.
Parse the lines in the document section of a BEL script .
"""Parse the lines in the document section of a BEL script.""" # This has to be insert since it needs to go on the front!
graph
BELGraph
enumerated_lines
Iterable[Tuple[int, str]]
metadata_parser
MetadataParser