File: ris.py-Use-raw-strings-for-all-regexes.patch

package info (click to toggle)
python-ilorest 5.2.0.0%2Bds-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 3,236 kB
  • sloc: python: 10,654; makefile: 375; sh: 3
file content (60 lines) | stat: -rw-r--r-- 2,884 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From: Carsten Schoenert <c.schoenert@t-online.de>
Date: Sat, 3 Feb 2024 18:56:27 +0100
Subject: ris.py: Use raw strings for all regexes

Python 3.12 adds a warning for invalid escape sequences (although
they were deprecated since 3.6). Using raw strings in all regexes
avoids it.
---
 src/redfish/ris/ris.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/redfish/ris/ris.py b/src/redfish/ris/ris.py
index ffa50d3..efd3fbf 100644
--- a/src/redfish/ris/ris.py
+++ b/src/redfish/ris/ris.py
@@ -736,7 +736,7 @@ class RisMonolith(Dictable):
         jsonpath_expr = jsonpath_rw.parse('$.."$ref"')
         matches = jsonpath_expr.find(resp.dict)
         respcopy = resp.dict
-        typeregex = "([#,@].*?\.)"
+        typeregex = r"([#,@].*?\.)"
         if matches:
             for match in matches:
                 fullpath = str(match.full_path)
@@ -850,7 +850,7 @@ class RisMonolith(Dictable):
                     if not jsonfile:
                         replacepath = jsonpointer.JsonPointer(jsonpath)
                         schemapath = schemapath.replace("/$ref", "")
-                        if re.search("\[\d]", schemapath):
+                        if re.search(r"\[\d]", schemapath):
                             schemapath = schemapath.translate(str.maketrans("", "", "[]"))
                         schemapath = jsonpointer.JsonPointer(schemapath)
                         data = replacepath.resolve(respcopy)
@@ -911,7 +911,7 @@ class RisMonolith(Dictable):
                     newval = {"$ref": maxsch}
 
             itempath = "/" + getval(match.full_path)
-            if re.search("\[\d+]", itempath):
+            if re.search(r"\[\d+]", itempath):
                 itempath = itempath.translate(str.maketrans("", "", "[]"))
             itempath = jsonpointer.JsonPointer(itempath)
             del itempath.parts[-1]
@@ -947,7 +947,7 @@ class RisMonolith(Dictable):
                         if "anyOf" not in schemapath:
                             raise SchemaValidationError()
                         continue
-                    if re.search("\[\d+]", itempath):
+                    if re.search(r"\[\d+]", itempath):
                         itempath = itempath.translate(str.maketrans("", "", "[]"))
                     itempath = jsonpointer.JsonPointer(itempath)
                     del itempath.parts[-1]
@@ -960,7 +960,7 @@ class RisMonolith(Dictable):
 
                 if jsonpath:
                     schemapath = schemapath.replace("/$ref", "")
-                    if re.search("\[\d+]", schemapath):
+                    if re.search(r"\[\d+]", schemapath):
                         schemapath = schemapath.translate(str.maketrans("", "", "[]"))
                     if not jsonfile:
                         replacepath = jsonpointer.JsonPointer(jsonpath)