From d6db00bb155cd06c3f06a736aa2b88df9459308d Mon Sep 17 00:00:00 2001 From: Emile Date: Tue, 8 Dec 2020 09:21:26 +0100 Subject: [PATCH 1/5] update with path and repath --- django2_url_robots/utils.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/django2_url_robots/utils.py b/django2_url_robots/utils.py index 52878d8..0efe307 100644 --- a/django2_url_robots/utils.py +++ b/django2_url_robots/utils.py @@ -1,6 +1,9 @@ +import django import sre_parse from sre_constants import LITERAL, AT, AT_END +_NEWEST_DJANGO = float(django.get_version()) >= float(2.0) + try: # Python 3 from urllib.parse import quote, unquote @@ -9,13 +12,12 @@ # Python 2 from urllib import quote, unquote -from django.conf.urls import url - try: from django.core.urlresolvers import get_urlconf, get_resolver, RegexURLResolver + from django.conf.urls import url except ImportError: - from django.urls import get_urlconf, get_resolver - from django.urls import URLResolver + from django.urls import get_urlconf, get_resolver, URLResolver + from django.urls import path, re_path def robots_decorator(url_function): @@ -31,7 +33,11 @@ def url_extended(regex, view, kwargs=None, name=None, robots_allow=None): return url_extended -url = robots_decorator(url) +if _NEWEST_DJANGO is True: + path = robots_decorator(path) + re_path = robots_decorator(path) +else: + url = robots_decorator(url) def create_rules(urlconf=None): From 51e1ac949e2a0550e183acd4a5b1775ffe6c5aa1 Mon Sep 17 00:00:00 2001 From: Emile Date: Tue, 8 Dec 2020 10:13:21 +0100 Subject: [PATCH 2/5] Update utils.py --- django2_url_robots/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django2_url_robots/utils.py b/django2_url_robots/utils.py index 0efe307..1ebb5b8 100644 --- a/django2_url_robots/utils.py +++ b/django2_url_robots/utils.py @@ -35,7 +35,7 @@ def url_extended(regex, view, kwargs=None, name=None, robots_allow=None): if _NEWEST_DJANGO is True: path = robots_decorator(path) - re_path = robots_decorator(path) + re_path = robots_decorator(re_path) else: url = robots_decorator(url) @@ -138,4 +138,4 @@ def clean_pattern(pattern): else: rule += star - return rule \ No newline at end of file + return rule From 6d86f2168c8d69cd9676770578ecabf713699420 Mon Sep 17 00:00:00 2001 From: Emile Date: Tue, 8 Dec 2020 14:51:00 +0100 Subject: [PATCH 3/5] update --- .DS_Store | Bin 10244 -> 10244 bytes .gitignore | 1 + django2_url_robots/utils.py | 7 +++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.DS_Store b/.DS_Store index e39d0f00388681c45f267693d4cc28122bdc094c..58487c74903218714c903f6567ec413568b6a958 100644 GIT binary patch delta 83 zcmZn(XbISmCdPPra=KUpk5qNFk&%gxf}w$_!Q_nsa*VSl3yRA#&e?1zewAZ0yFxr0 L0fmzd#V-K>G-nv+ delta 37 ncmZn(XbISmCN^1B;N0X%GOC-S#Mg3cW>ZLDgNaOz5?>7f34sli diff --git a/.gitignore b/.gitignore index fa440f6..70d592c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.pyc .tox/ +.DS_Store diff --git a/django2_url_robots/utils.py b/django2_url_robots/utils.py index 1ebb5b8..2a9eac5 100644 --- a/django2_url_robots/utils.py +++ b/django2_url_robots/utils.py @@ -1,12 +1,14 @@ -import django import sre_parse +from django import get_version +from distutils.version import StrictVersion from sre_constants import LITERAL, AT, AT_END -_NEWEST_DJANGO = float(django.get_version()) >= float(2.0) +_NEWEST_DJANGO = StrictVersion(get_version()) >= StrictVersion('2.0') try: # Python 3 from urllib.parse import quote, unquote + unichr = chr except ImportError: # Python 2 @@ -24,6 +26,7 @@ def robots_decorator(url_function): """ Decorator for django.conf.urls.url """ + def url_extended(regex, view, kwargs=None, name=None, robots_allow=None): resolver_or_pattern = url_function(regex, view, kwargs=kwargs, name=name) From 27725d5b3ddebcc5e142bb6e86057e291bf8ce31 Mon Sep 17 00:00:00 2001 From: MaximeK Date: Tue, 8 Dec 2020 16:08:00 +0100 Subject: [PATCH 4/5] Update .gitignore --- .gitignore | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 70d592c..225469f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ - .idea/ *.pyc .tox/ -.DS_Store + +build/* + +dist/* + +env/* + +.DS_Store \ No newline at end of file From 3164d19efc98b379499dde41ad8f739c4b3d1db8 Mon Sep 17 00:00:00 2001 From: Emile Date: Tue, 8 Dec 2020 16:17:02 +0100 Subject: [PATCH 5/5] Delete .DS_Store --- .DS_Store | Bin 10244 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 58487c74903218714c903f6567ec413568b6a958..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMU2GLa6h7xt=uG+BR{j>a_ChJCaFMovEeLq~BTx!Lye%!im%VqFc6Ga3?(V%8 zs5OnjzeJ7kCni8NhBq-LJ{ToF`WuJ|F&HI=2YvC;Xf*N3cxGoWp@ka417MsG0gZuw5%38r!BtQx5dmuIZK9y@G4{;W}xl zV2m@K(e#m#=H}L9qP3-UG?^G_YHD1UOgz-OW^|OZ`Snekx(*K=KQZ#u=+md9TNr&B zVD^zWbLB`J2)=yQL8WE+DGhwNl(Ai zGsTK#sL^ZnddBvP@s7MjwH)RR`UfeD z#v|zAFy_(65j=^{;tTj9zJ{mq48D!;;0O3IeuC%mGyELC!Eft|#p@;;hte+Duvy@0wJ%*V9@^AFD|iI4S?$ zh4lei9Bhhj;D^uD~4$q8jBJ#p