Pubmed search appears to work in command line output, but document metadata is not updated

Bug #196174 reported by Charlotte Curtis
2
Affects Status Importance Assigned to Milestone
Referencer
Fix Released
Undecided
Unassigned

Bug Description

I added a random pdf that I had on my hard drive, and from the command line output it seemed to retrieve the data from Pubmed. However, the document metadata was not updated. I attached a copy of the command line output, but I'm not sure if I'm allowed to upload the PDF (since it is not freely available). If you think it's okay/necessary, I'll upload the article as well.

Revision history for this message
Charlotte Curtis (c-f-curtis) wrote :
Revision history for this message
John S (jcspray) wrote :

The <MedLinePgn/> element was confusing the pubmed's parsing code. Looks like it's a pre-print article and thus doesn't have a page number, but they for some reason put that tag in there anyway.

Regardless, I have committed a fix to the parsing code to tolerate this situation.

Index: plugins/pubmed.py
===================================================================
--- plugins/pubmed.py (revision 705)
+++ plugins/pubmed.py (revision 706)
@@ -73,7 +73,10 @@
        if len(value) == 0:
                return ""
        else:
- return value[0].childNodes[0].data.encode("utf-8")
+ if (len(value[0].childNodes) == 0):
+ return ""
+ else:
+ return value[0].childNodes[0].data.encode("utf-8")

 def text_output(xml):
@@ -131,7 +134,7 @@
        pages = get_field (xmldoc, "MedlinePgn")
        output.append (["pages", pages])

- output2 = [];
+ output2 = []
        for pair in output:
                if len(pair[1]) > 0:
                        output2.append(pair)
@@ -145,12 +148,14 @@
                elif (method == "pubmed"):
                        xml = get_citation_from_pmid (doc.get_field ("pmid"))
        except:
+ print "pubmed.py:resolve_metadata: Got no metadata"
                # Couldn't get any metadata
                return False

        try:
                items = text_output (xml)
        except:
+ print "pubmed.py:resolve_metadata: Couldn't parse metadata"
                # Couldn't parse XML
                return False

Changed in referencer:
status: New → Fix Committed
Revision history for this message
John S (jcspray) wrote :
Revision history for this message
Charlotte Curtis (c-f-curtis) wrote :

Fantastic, thanks again!

Changed in referencer:
milestone: none → 1.2.0
Changed in referencer:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.