mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
make compatible with python 3.11 as well as 3.10
This commit is contained in:
parent
725c5ad0cd
commit
4514eda311
@ -18,9 +18,13 @@ from troggle.core.utils import save_carefully
|
|||||||
for tunnel and therion files
|
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):
|
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
|
'''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
|
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:
|
if scansfile:
|
||||||
dwgfile.scans.add(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]
|
name = os.path.split(path)[1]
|
||||||
rdwgfilel = DrawingFile.objects.filter(dwgname=name)
|
rdwgfilel = DrawingFile.objects.filter(dwgname=name)
|
||||||
if len(rdwgfilel):
|
if len(rdwgfilel):
|
||||||
|
@ -81,20 +81,23 @@ def set_trip_id(year, seq):
|
|||||||
tid= f"{year}_s{seq:02d}"
|
tid= f"{year}_s{seq:02d}"
|
||||||
return tid
|
return tid
|
||||||
|
|
||||||
|
rx_tripperson = re.compile(r'(?i)<u>(.*?)</u>$')
|
||||||
|
rx_round_bracket = re.compile(r"[\(\[].*?[\)\]]")
|
||||||
|
|
||||||
|
|
||||||
def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
|
def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
|
||||||
res = [ ]
|
res = [ ]
|
||||||
author = None
|
author = None
|
||||||
round_bracket_regex = re.compile(r"[\(\[].*?[\)\]]")
|
|
||||||
#print(f'# {tid}')
|
#print(f'# {tid}')
|
||||||
|
|
||||||
for tripperson in re.split(r",|\+|&|&(?!\w+;)| and ", trippeople):
|
for tripperson in re.split(r",|\+|&|&(?!\w+;)| and ", trippeople):
|
||||||
tripperson = tripperson.strip()
|
tripperson = tripperson.strip()
|
||||||
mul = re.match(r"<u>(.*?)</u>$(?i)", tripperson)
|
# mul = re.match(r"(?i)<u>(.*?)</u>$", tripperson)
|
||||||
|
mul = rx_tripperson.match(tripperson)
|
||||||
if mul:
|
if mul:
|
||||||
tripperson = mul.group(1).strip()
|
tripperson = mul.group(1).strip()
|
||||||
if tripperson and tripperson[0] != '*':
|
if tripperson and tripperson[0] != '*':
|
||||||
tripperson = re.sub(round_bracket_regex, "", tripperson).strip()
|
tripperson = re.sub(rx_round_bracket, "", tripperson).strip()
|
||||||
|
|
||||||
if tripperson =="Wiggy":
|
if tripperson =="Wiggy":
|
||||||
tripperson = "Phil Wigglesworth"
|
tripperson = "Phil Wigglesworth"
|
||||||
@ -134,6 +137,7 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_
|
|||||||
DataIssue.objects.create(parser='logbooks', message=message)
|
DataIssue.objects.create(parser='logbooks', message=message)
|
||||||
logdataissues["title"]=message
|
logdataissues["title"]=message
|
||||||
print(message)
|
print(message)
|
||||||
|
raise
|
||||||
return
|
return
|
||||||
|
|
||||||
if not author:
|
if not author:
|
||||||
|
@ -118,6 +118,8 @@ class LoadingSurvex():
|
|||||||
other survex files.
|
other survex files.
|
||||||
A 'scanswallet' is what we today call a "survey scans folder" or a "wallet".
|
A 'scanswallet' is what we today call a "survey scans folder" or a "wallet".
|
||||||
"""
|
"""
|
||||||
|
# python regex flags (?i) means case-insentitive, (?s) means . matches newline too
|
||||||
|
# see https://docs.python.org/3/library/re.html
|
||||||
rx_begin = re.compile(r'(?i)begin')
|
rx_begin = re.compile(r'(?i)begin')
|
||||||
rx_end = re.compile(r'(?i)end$')
|
rx_end = re.compile(r'(?i)end$')
|
||||||
rx_title = re.compile(r'(?i)title$')
|
rx_title = re.compile(r'(?i)title$')
|
||||||
|
Loading…
Reference in New Issue
Block a user