From 8fd09bef92b899ad0ba839eb9eedf1073fce5cc7 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 23 Nov 2023 18:46:44 +0000 Subject: [PATCH] python 3.12 discovered syntax issues --- _deploy/xubuntu/os-trog.sh | 2 +- core/TESTS/test_parsers.py | 2 +- core/views/prospect.py | 2 +- parsers/logbooks.py | 2 +- parsers/people.py | 4 ++-- parsers/survex.py | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/_deploy/xubuntu/os-trog.sh b/_deploy/xubuntu/os-trog.sh index 8d9c0cd..8d55263 100755 --- a/_deploy/xubuntu/os-trog.sh +++ b/_deploy/xubuntu/os-trog.sh @@ -75,7 +75,7 @@ sudo ln -s /etc/alternatives/python /usr/bin/python3 sudo apt dist-upgrade -# install VS code +# install VS code - but ONLY on a native ubuntu install, NOT in WSL sudo apt install software-properties-common apt-transport-https wget gpg wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg diff --git a/core/TESTS/test_parsers.py b/core/TESTS/test_parsers.py index 8274f89..1c7b929 100644 --- a/core/TESTS/test_parsers.py +++ b/core/TESTS/test_parsers.py @@ -171,7 +171,7 @@ class ImportTest(TestCase): # f.write(content) expected = [ "Edit Logbook Entry on 1986-07-31", - "Other names \(comma separated\)", # regex so slashes need to be espcaped + r"Other names \(comma separated\)", # regex match so slashes need to be espcaped "Place: cave name, or 'plateau', 'topcamp' etc.", ] for ph in expected: diff --git a/core/views/prospect.py b/core/views/prospect.py index 561c6d3..cff53f5 100644 --- a/core/views/prospect.py +++ b/core/views/prospect.py @@ -129,7 +129,7 @@ for FONT in [ "/usr/share/fonts/truetype/freefont/FreeSans.ttf", "/usr/X11R6/lib/X11/fonts/truetype/arial.ttf", "/mnt/c/windows/fonts/arial.ttf", - "C:\WINNT\Fonts\ARIAL.TTF", + r"C:\WINNT\Fonts\ARIAL.TTF", ]: if os.path.isfile(FONT): break diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 9e92dfc..892066b 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -326,7 +326,7 @@ def parser_date(tripdate, year): def parser_html(year, expedition, txt, seq=""): - """This uses some of the more obscure capabilities of regular expressions, + r"""This uses some of the more obscure capabilities of regular expressions, see https://docs.python.org/3/library/re.html e.g. diff --git a/parsers/people.py b/parsers/people.py index 97793a6..fc83be2 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -68,13 +68,13 @@ def troggle_slugify(longname): This function copied intact to expoweb/scripts/make-folklist.py """ slug = longname.strip().lower().replace(" ","-") - slug = re.sub('\([^\)]*\)','',slug) # remove nickname in brackets + slug = re.sub(r'\([^\)]*\)','',slug) # remove nickname in brackets slug = slug.replace('é', 'e') slug = slug.replace('á', 'a') slug = slug.replace('ä', 'a') slug = slug.replace('&', '') # otherwise just remove the & slug = slug.replace(';', '') # otherwise just remove the ; - slug = re.sub('<[^>]*>','',slug) # remove + slug = re.sub(r'<[^>]*>','',slug) # remove if len(slug) > 40: # slugfield is 50 chars slug = slug[:40] diff --git a/parsers/survex.py b/parsers/survex.py index 4c0a6e5..5c59e6d 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -2428,9 +2428,9 @@ def FindAndLoadSurvex(): ff = survexblock.survexfile if comment: # print(f"FIX {survexblock} {altitude} {comment}") - if re.match("(?i)[^s]*srtm[\s\S]*", comment.lower()): + if re.match(r"(?i)[^s]*srtm[\s\S]*", comment.lower()): print(f"SRTM {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'") - if re.match("(?i)[^s]*radost[\s\S]*", comment.lower()): + if re.match(r"(?i)[^s]*radost[\s\S]*", comment.lower()): print(f"RDST {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'") svx_load = None