src/pybel/manager/citation_utils.py
def enrich_citation_model_from_pmc(manager: Manager, citation: models.Citation, csl: Mapping[str, Any]) -> bool:
    """Enrich a citation model with the information from PubMed Central.

    :param manager: A database manager
    :param citation: A citation model
    :param dict csl: The dictionary from PMC
    """
    citation.title = csl.get('title')
    citation.journal = csl.get('container-title')
    citation.volume = csl.get('volume')
    # citation.issue = csl['issue']
    citation.pages = csl.get('page')
    citation.article_type = csl.get('type')

    for author in csl.get('author', []):
        try:
            author_name = f'{author["given"]} {author["family"]}'
        except KeyError:
            print(f'problem with author in pmc:{citation.db_id}', author)
            continue
        author_model = manager.get_or_create_author(author_name)
        if author_model not in citation.authors:
            citation.authors.append(author_model)

    if citation.authors:
        citation.first = citation.authors[0]
        citation.last = citation.authors[-1]

    issued = csl.get('issued')
    if issued is not None:
        date_parts = issued['date-parts'][0]
        if len(date_parts) == 3:
            citation.date = date(year=date_parts[0], month=date_parts[1], day=date_parts[2])
        elif len(date_parts) == 2:
            citation.date = date(year=date_parts[0], month=date_parts[1], day=1)
        elif len(date_parts) == 1:
            citation.date = date(year=date_parts[0], month=1, day=1)
        else:
            logger.warning('not sure about date parts: %s', date_parts)

    return True
Enrich a citation model with the information from PubMed Central.

    :param manager: A database manager
    :param citation: A citation model
    :param dict csl: The dictionary from PMC
    
Enrich a citation model with the information from PubMed Central.
Enrich a citation model with the information from PubMed Central .
def enrich_citation_model_from_pmc(manager: Manager, citation: models.Citation, csl: Mapping[str, Any]) -> bool:
    citation.title = csl.get('title')
    citation.journal = csl.get('container-title')
    citation.volume = csl.get('volume')
    citation.pages = csl.get('page')
    citation.article_type = csl.get('type')
    for author in csl.get('author', []):
        try:
            author_name = f'{author["given"]} {author["family"]}'
        except KeyError:
            print(f'problem with author in pmc:{citation.db_id}', author)
            continue
        author_model = manager.get_or_create_author(author_name)
        if author_model not in citation.authors:
            citation.authors.append(author_model)
    if citation.authors:
        citation.first = citation.authors[0]
        citation.last = citation.authors[-1]
    issued = csl.get('issued')
    if issued is not None:
        date_parts = issued['date-parts'][0]
        if len(date_parts) == 3:
            citation.date = date(year=date_parts[0], month=date_parts[1], day=date_parts[2])
        elif len(date_parts) == 2:
            citation.date = date(year=date_parts[0], month=date_parts[1], day=1)
        elif len(date_parts) == 1:
            citation.date = date(year=date_parts[0], month=1, day=1)
        else:
            logger.warning('not sure about date parts: %s', date_parts)
    return True
def enrich_citation_model_from_pmc ( manager : Manager , citation : models . Citation , csl : Mapping [ str , Any ] ) -> bool : citation . title = csl . get ( 'title' ) citation . journal = csl . get ( 'container-title' ) citation . volume = csl . get ( 'volume' ) citation . pages = csl . get ( 'page' ) citation . article_type = csl . get ( 'type' ) for author in csl . get ( 'author' , [ ] ) : try : author_name = f'{author["given"]} {author["family"]}' except KeyError : print ( f'problem with author in pmc:{citation.db_id}' , author ) continue author_model = manager . get_or_create_author ( author_name ) if author_model not in citation . authors : citation . authors . append ( author_model ) if citation . authors : citation . first = citation . authors [ 0 ] citation . last = citation . authors [ - 1 ] issued = csl . get ( 'issued' ) if issued is not None : date_parts = issued [ 'date-parts' ] [ 0 ] if len ( date_parts ) == 3 : citation . date = date ( year = date_parts [ 0 ] , month = date_parts [ 1 ] , day = date_parts [ 2 ] ) elif len ( date_parts ) == 2 : citation . date = date ( year = date_parts [ 0 ] , month = date_parts [ 1 ] , day = 1 ) elif len ( date_parts ) == 1 : citation . date = date ( year = date_parts [ 0 ] , month = 1 , day = 1 ) else : logger . warning ( 'not sure about date parts: %s' , date_parts ) return True
Enrich a citation model with the information from PubMed Central.
Enrich a citation model with the information from PubMed Central .
"""Enrich a citation model with the information from PubMed Central.

    :param manager: A database manager
    :param citation: A citation model
    :param dict csl: The dictionary from PMC
    """ # citation.issue = csl['issue']
manager
Manager
A database manager
A database manager
citation
models.Citation
A citation model
A citation model
csl
Mapping[str, Any]
The dictionary from PMC
The dictionary from PMC