File python-django-waliki-use-raw-strings.patch of Package python-django-waliki

From 8e1be99d778804715c250bdd1b303b156f490b1d Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Mon, 21 Oct 2024 18:21:22 +0100
Subject: [PATCH] Fix invalid escape sequence warnings.

Using backslashes in regular expressions result in invalid escape
sequence warnings.

Fixing these warnings by using raw string literals.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 waliki/attachments/urls.py |  6 +++---
 waliki/git/urls.py         | 12 ++++++------
 waliki/rst2html5.py        |  2 +-
 waliki/settings.py         |  2 +-
 waliki/utils.py            |  4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/waliki/attachments/urls.py b/waliki/attachments/urls.py
index 980a30b..5521d45 100644
--- a/waliki/attachments/urls.py
+++ b/waliki/attachments/urls.py
@@ -11,11 +11,11 @@ from waliki.settings import WALIKI_SLUG_PATTERN
 from waliki.attachments.views import attachments, delete_attachment, get_file
 
 _pattern_list = [
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/attachments$', attachments,
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/attachments$', attachments,
         name='waliki_attachments'),
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/attachments/(?P<attachment_id_or_filename>.*)/delete$',
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/attachments/(?P<attachment_id_or_filename>.*)/delete$',
         delete_attachment, name='waliki_delete_attachment'),
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/attachment/((?P<attachment_id>\d+)/)?(?P<filename>.*)$',
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/attachment/((?P<attachment_id>\d+)/)?(?P<filename>.*)$',
         get_file,   name='waliki_attachment_file')
 ]
 
diff --git a/waliki/git/urls.py b/waliki/git/urls.py
index 417f7e8..336c50d 100644
--- a/waliki/git/urls.py
+++ b/waliki/git/urls.py
@@ -18,21 +18,21 @@ _pattern_list = [
 
     url(r'^_hooks/pull/(?P<remote>[a-zA-Z0-9]+)$',
         webhook_pull, name='waliki_webhook_pull'),
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/history/(?P<pag>\d+)$',
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/history/(?P<pag>\d+)$',
         history, name='waliki_history'),
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/history/$',
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/history/$',
         history, {'pag': '1'}, name='waliki_history'),
 
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/version/(?P<version>[0-9a-f\^]{4,40})/raw$', version, {'raw': True},
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/version/(?P<version>[0-9a-f\^]{4,40})/raw$', version, {'raw': True},
         name='waliki_version_raw'),
     url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + \
-        ')/version/(?P<version>[0-9a-f\^]{4,40})$', version, name='waliki_version'),
+        r')/version/(?P<version>[0-9a-f\^]{4,40})$', version, name='waliki_version'),
 
-    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/diff/(?P<old>[0-9a-f\^]{4,40})\.\.(?P<new>[0-9a-f\^]{4,40})/raw$',
+    url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + r')/diff/(?P<old>[0-9a-f\^]{4,40})\.\.(?P<new>[0-9a-f\^]{4,40})/raw$',
         diff, {'raw': True}, name='waliki_diff_raw'),
 
     url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + \
-        ')/diff/(?P<old>[0-9a-f\^]{4,40})\.\.(?P<new>[0-9a-f\^]{4,40})$', diff, name='waliki_diff'),
+        r')/diff/(?P<old>[0-9a-f\^]{4,40})\.\.(?P<new>[0-9a-f\^]{4,40})$', diff, name='waliki_diff'),
 ]
 
 
diff --git a/waliki/rst2html5.py b/waliki/rst2html5.py
index 70175ef..53626c7 100644
--- a/waliki/rst2html5.py
+++ b/waliki/rst2html5.py
@@ -750,7 +750,7 @@ class HTML5Translator(nodes.NodeVisitor):
             template = '\\begin{%s}\n%s\n\\end{%s}' % (math_env, math_code, math_env)
             elem = tag.div(template)
         else:  # equation
-            template = '\(%s\)' % math_code
+            template = r'\(%s\)' % math_code
             elem = tag.span(template)
         elem(class_='math')
         self.context.append(elem)
diff --git a/waliki/settings.py b/waliki/settings.py
index 4eaac27..876ff8f 100644
--- a/waliki/settings.py
+++ b/waliki/settings.py
@@ -68,7 +68,7 @@ WALIKI_AVAILABLE_MARKUPS = getattr(settings, 'WALIKI_AVAILABLE_MARKUPS', ['reStr
 WALIKI_DEFAULT_MARKUP = WALIKI_AVAILABLE_MARKUPS[0]
 
 
-WALIKI_SLUG_PATTERN = getattr(settings, 'WALIKI_SLUG_PATTERN', '[a-zA-Z0-9-_\/]+')
+WALIKI_SLUG_PATTERN = getattr(settings, 'WALIKI_SLUG_PATTERN', r'[a-zA-Z0-9-_\/]+')
 
 WALIKI_SLUGIFY_FUNCTION = getattr(settings, 'WALIKI_SLUGIFY_FUNCTION', 'waliki.utils.get_slug')
 
diff --git a/waliki/utils.py b/waliki/utils.py
index 2e232f9..1575a6e 100644
--- a/waliki/utils.py
+++ b/waliki/utils.py
@@ -26,8 +26,8 @@ def get_slug(text):
         """
         value = force_text(value)
         value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
-        value = re.sub('[^\w\s\/_-]', '', value).strip()
-        return mark_safe(re.sub('[-\s]+', '-', value))
+        value = re.sub(r'[^\w\s\/_-]', '', value).strip()
+        return mark_safe(re.sub(r'[-\s]+', '-', value))
 
     if PY2:
         from django.utils.encoding import force_unicode
-- 
2.47.0