GitHub PullRequestReviewCommentEvent at 2014-05-30 11:19:09
Repository: invenio
Actor: pedrogaudencio
Payload: {"comment":{"url":"https://api.github.com/repos/jirikuncar/invenio/pulls/comments/13224797","id":13224797,"diff_hunk":"@@ -0,0 +1,67 @@\n+# -*- coding: utf-8 -*-\n+##\n+## This file is part of Invenio.\n+## Copyright (C) 2014 CERN.\n+##\n+## Invenio is free software; you can redistribute it and/or\n+## modify it under the terms of the GNU General Public License as\n+## published by the Free Software Foundation; either version 2 of the\n+## License, or (at your option) any later version.\n+##\n+## Invenio is distributed in the hope that it will be useful, but\n+## WITHOUT ANY WARRANTY; without even the implied warranty of\n+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+## General Public License for more details.\n+##\n+## You should have received a copy of the GNU General Public License\n+## along with Invenio; if not, write to the Free Software Foundation, Inc.,\n+## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.\n+\n+\"\"\"\n+API to get metadata in JSON format from http://export.arxiv.org using ArXiv ID\n+\"\"\"\n+\n+import requests\n+from lxml.etree import fromstring\n+\n+from invenio.utils.xmlhelpers import etree_to_dict\n+\n+\n+def get_arxiv_content(arxiv):\n+    \"\"\"Get ArXiv ID content from the http://export.arxiv.org page.\"\"\"\n+    # Clean the ArXiv ID\n+    arxiv = 'all:' + arxiv.strip()\n+\n+    # Getting the data from external source\n+    response = requests.get(\"http://export.arxiv.org/api/query\",\n+                            params=dict(search_query=arxiv,\n+                                        max_results=1))\n+\n+    return response\n+\n+\n+def get_json_for_arxiv(arxiv):\n+    \"\"\"Get ArXiv json data.\"\"\"\n+    response = get_arxiv_content(arxiv)\n+\n+    data = etree_to_dict(fromstring(response.content))\n+    query = {}\n+\n+    for d in data['feed']:\n+        query.update(dict(d.items()))\n+    del data['feed']\n+\n+    # Check if status=\"unresolved\" - this means the DOI was not found","path":"invenio/utils/arxiv.py","position":54,"original_position":54,"commit_id":"f3274806f7f5fcb1030921a51594fc6a05b52486","original_commit_id":"f3274806f7f5fcb1030921a51594fc6a05b52486","user":{"login":"pedrogaudencio","id":416548,"avatar_url":"https://avatars.githubusercontent.com/u/416548?","gravatar_id":"a2673c73ad83defc420ce4bd4c701bbf","url":"https://api.github.com/users/pedrogaudencio","html_url":"https://github.com/pedrogaudencio","followers_url":"https://api.github.com/users/pedrogaudencio/followers","following_url":"https://api.github.com/users/pedrogaudencio/following{/other_user}","gists_url":"https://api.github.com/users/pedrogaudencio/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrogaudencio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrogaudencio/subscriptions","organizations_url":"https://api.github.com/users/pedrogaudencio/orgs","repos_url":"https://api.github.com/users/pedrogaudencio/repos","events_url":"https://api.github.com/users/pedrogaudencio/events{/privacy}","received_events_url":"https://api.github.com/users/pedrogaudencio/received_events","type":"User","site_admin":false},"body":"Ups, forgot to change that.","created_at":"2014-05-30T11:19:09Z","updated_at":"2014-05-30T11:19:09Z","html_url":"https://github.com/jirikuncar/invenio/pull/289#discussion_r13224797","pull_request_url":"https://api.github.com/repos/jirikuncar/invenio/pulls/289","_links":{"self":{"href":"https://api.github.com/repos/jirikuncar/invenio/pulls/comments/13224797"},"html":{"href":"https://github.com/jirikuncar/invenio/pull/289#discussion_r13224797"},"pull_request":{"href":"https://api.github.com/repos/jirikuncar/invenio/pulls/289"}}}}