From 4514eda311451aefd684c587300774501ef20afb Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 18 Nov 2022 20:42:03 +0000 Subject: make compatible with python 3.11 as well as 3.10 --- parsers/drawings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'parsers/drawings.py') diff --git a/parsers/drawings.py b/parsers/drawings.py index b3ce8c8..1ef03a9 100644 --- a/parsers/drawings.py +++ b/parsers/drawings.py @@ -18,9 +18,13 @@ from troggle.core.utils import save_carefully for tunnel and therion files ''' -todo='''Rename functions more consistently between tunnel and therion variants +todo='''- Rename functions more consistently between tunnel and therion variants + +- Recode rx_valid_ext to use profile suffix() function ''' +rx_valid_ext = re.compile(r'(?i)\.(?:png|jpg|pdf|jpeg|gif|txt)$') + def find_dwg_file(dwgfile, path): '''Is given a line of text 'path' which may or may not contain a recognisable name of a scanned file which we have already seen when we imported all the files we could find in the surveyscans direstories @@ -54,7 +58,7 @@ def find_dwg_file(dwgfile, path): if scansfile: dwgfile.scans.add(scansfile) - elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg|gif|txt)$(?i)", path): + elif path and not rx_valid_ext.search(path): name = os.path.split(path)[1] rdwgfilel = DrawingFile.objects.filter(dwgname=name) if len(rdwgfilel): -- cgit v1.2.3