From 4d9e3f7c50e2adb3800eb3f00aaaa123f083ef80 Mon Sep 17 00:00:00 2001 From: Christian Hill Date: Thu, 13 Feb 2020 15:48:42 +0100 Subject: [PATCH] Move to Django 2 --- notebooks/References Notebook 2020.ipynb | 144 +++-------------------- pyref/pyref/urls.py | 6 +- pyref/refs/urls.py | 10 +- requirements.txt | 39 +++--- 4 files changed, 45 insertions(+), 154 deletions(-) diff --git a/notebooks/References Notebook 2020.ipynb b/notebooks/References Notebook 2020.ipynb index f5d6e50..90809a4 100644 --- a/notebooks/References Notebook 2020.ipynb +++ b/notebooks/References Notebook 2020.ipynb @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -90,17 +90,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Enter DOI Here: 10.1016/j.jqsrt.2019.106711\n" - ] - } - ], + "outputs": [], "source": [ "# Enter your token here: You need this for using step 2 and 3\n", "# A token can only be used once you have an account on NASA/ADS https://ui.adsabs.harvard.edu/. \n", @@ -121,17 +113,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Bibcode: 2020JQSRT.24106711C\n" - ] - } - ], + "outputs": [], "source": [ "def get_citeproc_authors(cpd_author):\n", " if cpd_author is None:\n", @@ -267,25 +251,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "authors: Conway, E. K., I. E. Gordon, A. A. Kyuberis, O. L. Polyansky, J. Tennyson, and N. F. Zobov\n", - "title: Calculated line lists for H216O and H218O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database\n", - "journal: Journal of Quantitative Spectroscopy and Radiative Transfer\n", - "volume: 241\n", - "start-page: 106711\n", - "end-page: %P\n", - "year: 2020\n", - "doi: 10.1016/j.jqsrt.2019.106711\n", - "bibcode: https://ui.adsabs.harvard.edu/abs/2020JQSRT.24106711C\n" - ] - } - ], + "outputs": [], "source": [ "# HTML with the characters &, <, >, and “ included\n", "payload = {\"bibcode\": [\"{}\".format(Bibcode)],\n", @@ -326,25 +294,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "authors: Conway, E.~K., I.~E. Gordon, A.~A. Kyuberis, O.~L. Polyansky, J. Tennyson, and N.~F. Zobov\n", - "title: Calculated line lists for H$_{2}$$^{16}$O and H$_{2}$$^{18}$O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database\n", - "journal: Journal of Quantitative Spectroscopy and Radiative Transfer\n", - "volume: 241\n", - "start-page: 106711\n", - "end-page: %P\n", - "year: 2020\n", - "doi: 10.1016/j.jqsrt.2019.106711\n", - "bibcode: https://ui.adsabs.harvard.edu/abs/2020JQSRT.24106711C\n" - ] - } - ], + "outputs": [], "source": [ "# BibTeX Reference\n", "payload = {\"bibcode\": [\"{}\".format(Bibcode)],\n", @@ -389,25 +341,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "authors: Conway, E. K., I. E. Gordon, A. A. Kyuberis, O. L. Polyansky, J. Tennyson, and N. F. Zobov\n", - "title: Calculated line lists for H<SUB>2</SUB><SUP>16</SUP>O and H<SUB>2</SUB><SUP>18</SUP>O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database\n", - "journal: Journal of Quantitative Spectroscopy and Radiative Transfer\n", - "volume: 241\n", - "start-page: 106711\n", - "end-page: %P\n", - "year: 2020\n", - "doi: 10.1016/j.jqsrt.2019.106711\n", - "bibcode: https://ui.adsabs.harvard.edu/abs/2020JQSRT.24106711C\n" - ] - } - ], + "outputs": [], "source": [ "# HTML with the characters &, <, >, and “ are converted to &, <, >, and ", respectively.\n", "payload = {\"bibcode\": [\"{}\".format(Bibcode)],\n", @@ -450,26 +386,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Authors: E. K. Conway, I. E. Gordon, A. A. Kyuberis, O. L. Polyansky, J. Tennyson, N. F. Zobov \n", - "Title: Calculated line lists for H216O and H218O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database \n", - "Journal: Journal of Quantitative Spectroscopy and Radiative Transfer \n", - "Volume: 241 \n", - "Year: 2020 \n", - "Page Start: 106711 \n", - "Page End: \n", - "Article Number: 106711 \n", - "DOI: 10.1016/j.jqsrt.2019.106711 \n", - "URL: http://dx.doi.org/10.1016/j.jqsrt.2019.106711 \n" - ] - } - ], + "outputs": [], "source": [ "#doi = input(\"Enter doi Here: \")\n", "doi_fetched = get_source_from_doi('{}'.format(doi))\n", @@ -500,20 +419,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'('E. K. Conway, I. E. Gordon, A. A. Kyuberis, O. L. Polyansky, J. Tennyson, N. F. Zobov', 'Calculated line lists for H216O and H218O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database', 'Journal of Quantitative Spectroscopy and Radiative Transfer', '241', 2020, '106711', '', '10.1016/j.jqsrt.2019.106711', 'http://dx.doi.org/10.1016/j.jqsrt.2019.106711', '106711')'" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Here is the populated output from the urllib method\n", "# This will replace (\"\"\"& < \" '> \"\"\" ) with (& < " ' >)\n", @@ -531,25 +439,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "@article{conway2020calculated,\n", - " title={Calculated line lists for H216O and H218O with extensive comparisons to theoretical and experimental sources including the HITRAN2016 database},\n", - " author={Conway, Eamon K and Gordon, Iouli E and Kyuberis, Aleksandra A and Polyansky, Oleg L and Tennyson, Jonathan and Zobov, Nikolai F},\n", - " journal={Journal of Quantitative Spectroscopy and Radiative Transfer},\n", - " volume={241},\n", - " pages={106711},\n", - " year={2020},\n", - " publisher={Elsevier}\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "\"\"\"Library to query Google Scholar.\n", "Call the method query with a string which contains the full search\n", @@ -690,7 +582,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.6.10" } }, "nbformat": 4, diff --git a/pyref/pyref/urls.py b/pyref/pyref/urls.py index 9e760db..4a798e5 100644 --- a/pyref/pyref/urls.py +++ b/pyref/pyref/urls.py @@ -13,12 +13,12 @@ 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url, include +from django.urls import path, include from django.contrib import admin import refs.urls urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^refs/', include(refs.urls)), + path('admin/', admin.site.urls), + path('refs/', include(refs.urls)), ] diff --git a/pyref/refs/urls.py b/pyref/refs/urls.py index c274f5c..2d3e854 100644 --- a/pyref/refs/urls.py +++ b/pyref/refs/urls.py @@ -1,10 +1,10 @@ -from django.conf.urls import include, url +from django.urls import include, path, re_path from . import views app_name = 'refs' urlpatterns = [ - url(r'^$', views.ref_list, name='ref_list'), - url(r'^resolve/(?:(?P\d+))?$', views.resolve, name='resolve'), - url(r'^delete/(?P\d+)$', views.delete, name='delete'), - url(r'^edit/(?:(?P\d+))?$', views.edit, name='edit'), + path('', views.ref_list, name='ref_list'), + re_path(r'^resolve/(?:(?P\d+))?$', views.resolve, name='resolve'), + re_path(r'^delete/(?P\d+)$', views.delete, name='delete'), + re_path(r'^edit/(?:(?P\d+))?$', views.edit, name='edit'), ] diff --git a/requirements.txt b/requirements.txt index e2af4ab..708d122 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,50 +6,49 @@ certifi==2019.11.28 chardet==3.0.4 decorator==4.4.1 defusedxml==0.6.0 -Django==1.11.8 +Django==1.11.28 entrypoints==0.3 idna==2.8 -importlib-metadata==1.3.0 -ipykernel==5.1.3 -ipython==7.10.2 +importlib-metadata==1.5.0 +ipykernel==5.1.4 +ipython==7.12.0 ipython-genutils==0.2.0 ipywidgets==7.5.1 -jedi==0.15.1 -Jinja2==2.10.3 +jedi==0.16.0 +Jinja2==2.11.1 jsonschema==3.2.0 jupyter==1.0.0 jupyter-client==5.3.4 -jupyter-console==5.2.0 -jupyter-core==4.6.1 +jupyter-console==6.1.0 +jupyter-core==4.6.2 MarkupSafe==1.1.1 mistune==0.8.4 -more-itertools==7.2.0 mysqlclient==1.4.6 nbconvert==5.6.1 -nbformat==4.4.0 -notebook==6.0.2 +nbformat==5.0.4 +notebook==6.0.3 pandocfilters==1.4.2 -parso==0.5.2 -pexpect==4.7.0 +parso==0.6.1 +pexpect==4.8.0 pickleshare==0.7.5 prometheus-client==0.7.1 -prompt-toolkit==3.0.2 +prompt-toolkit==3.0.3 ptyprocess==0.6.0 Pygments==2.5.2 -pyrsistent==0.15.6 +pyrsistent==0.15.7 python-dateutil==2.8.1 pytz==2019.3 -pyzmq==18.1.0 +pyzmq==18.1.1 qtconsole==4.6.0 requests==2.22.0 Send2Trash==1.5.0 -six==1.13.0 +six==1.14.0 terminado==0.8.3 testpath==0.4.4 tornado==6.0.3 traitlets==4.3.3 -urllib3==1.25.7 -wcwidth==0.1.7 +urllib3==1.25.8 +wcwidth==0.1.8 webencodings==0.5.1 widgetsnbextension==3.5.1 -zipp==0.6.0 +zipp==2.2.0