to_dict can be called only once on PubMedArticle

Issue #15 resolved
xavier_robin
created an issue

Calling to_dict on a PubMedArticle works only once. If I call to_dict a second time, I get a KeyError. Here is an example:

import metapub
fetch = metapub.PubMedFetcher()
pmid = "16048924"
article = fetch.article_by_pmid(pmid)

article.to_dict() # works
article.to_dict() # doesn't work

Expected result: the same dictionary as returned by the first call.

Observed result:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zohixe92/python2.7/lib/python2.7/site-packages/metapub/pubmedarticle.py", line 132, in to_dict
    outd.pop('content')
KeyError: u'content'

Environment: Python 2.7.11, metapub.version u'0.4.3.5', Linux CentOS 7.5.1804, kernel 3.10.0-862.9.1.el7.x86_64.

Comments (2)

  1. Log in to comment