fix QM regex for number and rearrange url code

This commit is contained in:
Philip Sargent
2022-07-20 17:02:38 +03:00
parent 549c1649b4
commit a215ebd62c
4 changed files with 17 additions and 25 deletions

View File

@@ -119,9 +119,9 @@ class LoadingSurvex():
instruments = "(waiting_patiently|slacker|Useless|nagging|unknown|Inst|instrument|rig|rigger|rigging|helper|something| compass|comp|clino|Notes|sketch|book|Tape|Dog|Pics|photo|drawing|Helper|GPS|Disto|Distox|Distox2|topodroid|point|Consultant|nail|polish|nail_polish_bitch|nail_polish_monkey|varnish|nail_polish|nail_varnish|bitch|monkey|PowerDrill|drill)"
rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)"+instruments+"?(?:es|s)?$")
rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$")
rx_qm = re.compile(r'(?i)^\s*QM(\d)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$')
rx_qm = re.compile(r'(?i)^\s*QM(\d+)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$')
# does not recognise non numeric suffix survey point ids
rx_qm0 = re.compile(r'(?i)^\s*QM(\d)\s+(.+)$')
rx_qm0 = re.compile(r'(?i)^\s*QM(\d+)\s+(.+)$')
# remember there is also QM_PATTERN used in views.other and set in settings.py
rx_tapelng = re.compile(r'(?i).*(tape|length).*$')
@@ -539,28 +539,15 @@ class LoadingSurvex():
# Older troggle/CSV assumes a logbook entry 'found_by' for each QM, with a date.
# We don't need this anymore so we don't need to create a placeholder logbook entry.
qmyear = str(survexblock.date)[:4]
blockname = survexblock.name[:7]
logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
blockname = survexblock.name[:6] + survexblock.name[-1:]
#logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
if survexblock.survexfile.cave:
caveslug = survexblock.survexfile.cave.slug()
place = survexblock.survexfile.cave
else:
caveslug = None
place = None
# message = f' ! - logbook dummy "{logslug}" {str(survexblock.date)[:11]} for cave "{caveslug}" created.'
# placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=qmyear,
# place=place,
# title="placeholder for survex QM",
# text=message,
# entry_type="DUMMY",
# expedition_id=1,
# defaults={"date": survexblock.date,"cave_slug":caveslug, "slug": logslug})
# print(insp+message)
# DataIssue.objects.create(parser='survex', message=message)
try:
qm = QM.objects.create(number=qm_no,
# nearest_station=a_survex_station_object, # can be null
@@ -570,13 +557,13 @@ class LoadingSurvex():
location_description=qm_notes,
block = survexblock, # only set for survex-imported QMs
blockname = blockname, # only set for survex-imported QMs
# found_by = placeholder,
expoyear = str(survexblock.date.year),
cave = survexblock.survexfile.cave)
qm.save
# message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)
# print(insp+message)
# DataIssue.objects.create(parser='survex', message=message)
if survexblock.survexfile.cave.kataster_number == "359":
message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)
print(insp+message)
DataIssue.objects.create(parser='survex', message=message)
except:
message = " ! QM{} FAIL to create {} in'{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)
print(insp+message)
@@ -834,7 +821,7 @@ class LoadingSurvex():
if qmline:
self.LoadSurvexQM(survexblock, qmline)
else:
message = f' ! QM Unrecognised as a valid QM in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)}'
message = f' ! QM Unrecognised as valid in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)} : non-numeric station name?'
print(message)
DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx')