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

    :param manager: A database manager
    :param citation: A citation model
    :param p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
    """
    if 'error' in p:
        logger.warning('Error downloading PubMed')
        return False

    citation.title = p['title']
    citation.journal = p['fulljournalname']
    citation.volume = p['volume']
    citation.issue = p['issue']
    citation.pages = p['pages']
    citation.first = manager.get_or_create_author(p['sortfirstauthor'])
    citation.last = manager.get_or_create_author(p['lastauthor'])
    pubtypes = p['pubtype']
    if pubtypes:
        citation.article_type = pubtypes[0]

    if 'authors' in p:
        for author in p['authors']:
            author_model = manager.get_or_create_author(author['name'])
            if author_model not in citation.authors:
                citation.authors.append(author_model)

    publication_date = p['pubdate']
    try:
        sanitized_publication_date = sanitize_date(publication_date)
    except ValueError:
        logger.warning('could not parse publication date %s for pubmed:%s', publication_date, citation.db_id)
        sanitized_publication_date = None

    if sanitized_publication_date:
        citation.date = datetime.strptime(sanitized_publication_date, '%Y-%m-%d')
    else:
        logger.info('result had date with strange format: %s', publication_date)

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

    :param manager: A database manager
    :param citation: A citation model
    :param p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
    
Enrich a citation model with the information from PubMed.
Enrich a citation model with the information from PubMed .
def enrich_citation_model(manager: Manager, citation: models.Citation, p: Mapping[str, Any]) -> bool:
    if 'error' in p:
        logger.warning('Error downloading PubMed')
        return False
    citation.title = p['title']
    citation.journal = p['fulljournalname']
    citation.volume = p['volume']
    citation.issue = p['issue']
    citation.pages = p['pages']
    citation.first = manager.get_or_create_author(p['sortfirstauthor'])
    citation.last = manager.get_or_create_author(p['lastauthor'])
    pubtypes = p['pubtype']
    if pubtypes:
        citation.article_type = pubtypes[0]
    if 'authors' in p:
        for author in p['authors']:
            author_model = manager.get_or_create_author(author['name'])
            if author_model not in citation.authors:
                citation.authors.append(author_model)
    publication_date = p['pubdate']
    try:
        sanitized_publication_date = sanitize_date(publication_date)
    except ValueError:
        logger.warning('could not parse publication date %s for pubmed:%s', publication_date, citation.db_id)
        sanitized_publication_date = None
    if sanitized_publication_date:
        citation.date = datetime.strptime(sanitized_publication_date, '%Y-%m-%d')
    else:
        logger.info('result had date with strange format: %s', publication_date)
    return True
def enrich_citation_model ( manager : Manager , citation : models . Citation , p : Mapping [ str , Any ] ) -> bool : if 'error' in p : logger . warning ( 'Error downloading PubMed' ) return False citation . title = p [ 'title' ] citation . journal = p [ 'fulljournalname' ] citation . volume = p [ 'volume' ] citation . issue = p [ 'issue' ] citation . pages = p [ 'pages' ] citation . first = manager . get_or_create_author ( p [ 'sortfirstauthor' ] ) citation . last = manager . get_or_create_author ( p [ 'lastauthor' ] ) pubtypes = p [ 'pubtype' ] if pubtypes : citation . article_type = pubtypes [ 0 ] if 'authors' in p : for author in p [ 'authors' ] : author_model = manager . get_or_create_author ( author [ 'name' ] ) if author_model not in citation . authors : citation . authors . append ( author_model ) publication_date = p [ 'pubdate' ] try : sanitized_publication_date = sanitize_date ( publication_date ) except ValueError : logger . warning ( 'could not parse publication date %s for pubmed:%s' , publication_date , citation . db_id ) sanitized_publication_date = None if sanitized_publication_date : citation . date = datetime . strptime ( sanitized_publication_date , '%Y-%m-%d' ) else : logger . info ( 'result had date with strange format: %s' , publication_date ) return True
Enrich a citation model with the information from PubMed.
Enrich a citation model with the information from PubMed .
"""Enrich a citation model with the information from PubMed.

    :param manager: A database manager
    :param citation: A citation model
    :param p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
    """
manager
Manager
A database manager
A database manager
citation
models.Citation
A citation model
A citation model
p
Mapping[str, Any]
The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
The dictionary from PubMed E - Utils corresponding to d [ " result " ] [ pmid ]