From b7ca2b50f904f0d0342da97564fa5f6ea09fd510 Mon Sep 17 00:00:00 2001 From: Pierre-Claver Koko Banywerha Date: Thu, 12 Dec 2019 09:47:33 +0200 Subject: [PATCH 1/2] Added Django2.x support --- .gitignore | 2 +- README.rst | 5 ++++- favicon/urls.py | 9 +++++---- setup.py | 42 +++++++++++++++++++++++++----------------- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index aef50ce..345efef 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,5 @@ .tox *.egg-info/* docs/_build/* -dist/* +dist/ .idea/* diff --git a/README.rst b/README.rst index 8a20579..6490190 100644 --- a/README.rst +++ b/README.rst @@ -19,9 +19,12 @@ Add "favicon" to your INSTALLED_APPS in settings.py:: Add favicon URL patterns to urls.py:: + # from django.conf.urls import url, include + from django.urls import path, include urlpatterns = patterns('', ... - url(r'^', include('favicon.urls')), + # url(r'^', include('favicon.urls')), + path ('', include('favicon.urls')) ) Usage diff --git a/favicon/urls.py b/favicon/urls.py index c3fb632..dd2e931 100644 --- a/favicon/urls.py +++ b/favicon/urls.py @@ -1,7 +1,8 @@ -from django.conf.urls import url +try: + from django.conf.urls import url +except ImportError: + from django.urls import re_path as url from django.views.generic import TemplateView, RedirectView from . import conf -urlpatterns = [ - url(r'^favicon\.ico$', RedirectView.as_view(url=conf.FAVICON_PATH, permanent=True), name='favicon'), -] +urlpatterns = [url(r"^favicon\.ico$", RedirectView.as_view(url=conf.FAVICON_PATH, permanent=True), name="favicon")] diff --git a/setup.py b/setup.py index ae330ea..be87a3a 100644 --- a/setup.py +++ b/setup.py @@ -9,30 +9,38 @@ def read_file(filename): try: return open(filepath).read() except IOError: - return '' + return "" setup( - name='django-favicon', - version=__import__('favicon').__version__, - author='Evgeny Demchenko', - author_email='little_pea@list.ru', + name="django-favicon", + version=__import__("favicon").__version__, + author="Evgeny Demchenko", + author_email="little_pea@list.ru", packages=find_packages(), include_package_data=True, - url='https://github.com/littlepea/django-favicon', - license='BSD', - description=u' '.join(__import__('favicon').__doc__.splitlines()).strip(), + url="https://github.com/littlepea/django-favicon", + license="BSD", + description=u" ".join(__import__("favicon").__doc__.splitlines()).strip(), classifiers=[ - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - 'Intended Audience :: Developers', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Framework :: Django', - 'Development Status :: 4 - Beta', - 'Operating System :: OS Independent', + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 2.6", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Framework :: Django", + "Framework :: Django :: 1.11", + "Framework :: Django :: 2.0", + "Framework :: Django :: 2.1", + "Framework :: Django :: 2.2", + "Development Status :: 4 - Beta", + "Operating System :: OS Independent", ], - long_description=read_file('README.rst'), + long_description=read_file("README.rst"), test_suite="runtests.runtests", zip_safe=False, ) From ad9878dea42f3c790a8d7560b7b071321fb1db2c Mon Sep 17 00:00:00 2001 From: Pierre-Claver Koko Banywerha Date: Wed, 17 Jun 2020 08:38:17 +0200 Subject: [PATCH 2/2] Removed double quotes inserted by editor --- README.rst | 4 ++-- favicon/urls.py | 2 +- setup.py | 54 ++++++++++++++++++++++++------------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.rst b/README.rst index 6490190..e01871c 100644 --- a/README.rst +++ b/README.rst @@ -19,11 +19,11 @@ Add "favicon" to your INSTALLED_APPS in settings.py:: Add favicon URL patterns to urls.py:: - # from django.conf.urls import url, include + # from django.conf.urls import url, include # Django < 2.0 from django.urls import path, include urlpatterns = patterns('', ... - # url(r'^', include('favicon.urls')), + # url(r'^', include('favicon.urls')), # Django < 2.0 path ('', include('favicon.urls')) ) diff --git a/favicon/urls.py b/favicon/urls.py index dd2e931..2eda9a5 100644 --- a/favicon/urls.py +++ b/favicon/urls.py @@ -5,4 +5,4 @@ from django.views.generic import TemplateView, RedirectView from . import conf -urlpatterns = [url(r"^favicon\.ico$", RedirectView.as_view(url=conf.FAVICON_PATH, permanent=True), name="favicon")] +urlpatterns = [url(r'^favicon\.ico$', RedirectView.as_view(url=conf.FAVICON_PATH, permanent=True), name='favicon')] diff --git a/setup.py b/setup.py index be87a3a..fd2e9de 100644 --- a/setup.py +++ b/setup.py @@ -3,44 +3,44 @@ def read_file(filename): - """Read a file into a string""" + '''Read a file into a string''' path = os.path.abspath(os.path.dirname(__file__)) filepath = os.path.join(path, filename) try: return open(filepath).read() except IOError: - return "" + return '' setup( - name="django-favicon", - version=__import__("favicon").__version__, - author="Evgeny Demchenko", - author_email="little_pea@list.ru", + name='django-favicon', + version=__import__('favicon').__version__, + author='Evgeny Demchenko', + author_email='little_pea@list.ru', packages=find_packages(), include_package_data=True, - url="https://github.com/littlepea/django-favicon", - license="BSD", - description=u" ".join(__import__("favicon").__doc__.splitlines()).strip(), + url='https://github.com/littlepea/django-favicon', + license='BSD', + description=u' '.join(__import__('favicon').__doc__.splitlines()).strip(), classifiers=[ - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 2.6", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Framework :: Django", - "Framework :: Django :: 1.11", - "Framework :: Django :: 2.0", - "Framework :: Django :: 2.1", - "Framework :: Django :: 2.2", - "Development Status :: 4 - Beta", - "Operating System :: OS Independent", + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Intended Audience :: Developers', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Framework :: Django', + 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.0', + 'Framework :: Django :: 2.1', + 'Framework :: Django :: 2.2', + 'Development Status :: 4 - Beta', + 'Operating System :: OS Independent', ], - long_description=read_file("README.rst"), - test_suite="runtests.runtests", + long_description=read_file('README.rst'), + test_suite='runtests.runtests', zip_safe=False, )