mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 15:21:52 +00:00
Move code closer to related code
This commit is contained in:
parent
7aeffff00c
commit
83dc9e6c09
@ -901,118 +901,6 @@ class LoadingSurvex:
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="survex", message=message, url=url)
|
||||
|
||||
def TickSurvexQM(self, survexblock, qmtick):
|
||||
"""Interpret the specially formatted comment which is a QM TICKED statement"""
|
||||
# Now we need to find the correct QM object. It will be in the same block and have the same number.
|
||||
|
||||
try:
|
||||
qm = QM.objects.filter(block=survexblock, number=int(qmtick.group(1)))
|
||||
except:
|
||||
# raise
|
||||
message = f' ! QM TICK find FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" qmlist:"{qm}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
|
||||
print(message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
if len(qm) > 1:
|
||||
message = f' ! QM TICK MULTIPLE found FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
|
||||
print(message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
qm[0].ticked = True
|
||||
qm[0].save()
|
||||
|
||||
def LoadSurvexQM(self, survexblock, qmline):
|
||||
"""Interpret the specially formatted comment which is a QM definition"""
|
||||
insp = self.insp
|
||||
|
||||
qm_no = qmline.group(1) # this is NOT unique across multiple survex files
|
||||
|
||||
qm_grade = qmline.group(2).strip().upper() # [a-dA-DvVxX?]
|
||||
if qm_grade not in ["A", "B", "C", "D", "X", "V", "?"]:
|
||||
message = f" ! QM{qm_no} INVALID code '{qm_grade}' in '{survexblock.survexfile.path}'"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
|
||||
if qmline.group(3): # usual closest survey station
|
||||
qm_nearest = qmline.group(3)
|
||||
if qmline.group(4):
|
||||
qm_nearest = qm_nearest + "." + qmline.group(4)
|
||||
|
||||
if qmline.group(6) and qmline.group(6) != "-":
|
||||
qm_resolve_station = qmline.group(6)
|
||||
if qmline.group(7):
|
||||
qm_resolve_station = qm_resolve_station + "." + qmline.group(7)
|
||||
else:
|
||||
qm_resolve_station = ""
|
||||
qm_notes = qmline.group(8)
|
||||
# Spec of QM in SVX files:
|
||||
# ;Serial number grade(A/B/C/D/V/X) nearest-station resolution-station description
|
||||
# ;QM1 a hobnob_hallway_2.42 hobnob-hallway_3.42 junction of keyhole passage
|
||||
# ;QM1 a hobnob_hallway_2.42 - junction of keyhole passage
|
||||
|
||||
#;QM1 A B6 - see plan drawing there is definitely a QM
|
||||
|
||||
# NB none of the SurveyStations are in the DB now, so if we want to link to aSurvexStation
|
||||
# we would have to create one. But that is not obligatory and no QMs loaded from CSVs have one
|
||||
|
||||
# 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.
|
||||
|
||||
# create a short, hopefully-unique name for this block to be used in the QM id
|
||||
blockname = survexblock.name[:6] + survexblock.name[-1:]
|
||||
# logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
|
||||
|
||||
if survexblock.survexfile.cave:
|
||||
survexblock.survexfile.cave.slug()
|
||||
else:
|
||||
pass
|
||||
if survexblock.date:
|
||||
expoyear = str(survexblock.date.year)
|
||||
else:
|
||||
message = f" ! No survexblock.date in'{survexblock.survexfile.path}', setting to 1976"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
expoyear = "1976"
|
||||
try:
|
||||
qm = QM.objects.create(
|
||||
number=qm_no,
|
||||
# nearest_station=a_survex_station_object, # can be null
|
||||
nearest_station_description=qm_resolve_station,
|
||||
nearest_station_name=qm_nearest,
|
||||
grade=qm_grade.upper(),
|
||||
location_description=qm_notes,
|
||||
block=survexblock, # only set for survex-imported QMs
|
||||
blockname=blockname, # only set for survex-imported QMs
|
||||
expoyear=expoyear,
|
||||
cave=survexblock.survexfile.cave,
|
||||
)
|
||||
qm.save
|
||||
except:
|
||||
qms = QM.objects.filter(
|
||||
number=qm_no,
|
||||
# nearest_station=a_survex_station_object, # can be null
|
||||
nearest_station_description=qm_resolve_station,
|
||||
nearest_station_name=qm_nearest,
|
||||
grade=qm_grade.upper(),
|
||||
location_description=qm_notes,
|
||||
block=survexblock, # only set for survex-imported QMs
|
||||
blockname=blockname, # only set for survex-imported QMs
|
||||
expoyear=expoyear,
|
||||
cave=survexblock.survexfile.cave,
|
||||
)
|
||||
print(qms)
|
||||
message = f" ! QM{qm_no} FAIL to create {qm_nearest} in'{survexblock.survexfile.path}'"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
|
||||
def LoadSurvexDataNormal(self, survexblock, args):
|
||||
"""Sets the order for data elements in this and following blocks, e.g.
|
||||
*data normal from to compass clino tape
|
||||
@ -1306,6 +1194,118 @@ class LoadingSurvex:
|
||||
debugprint = False
|
||||
self.currentsurvexfile.save()
|
||||
self.currentsurvexfile = self.stacksvxfiles.pop()
|
||||
def TickSurvexQM(self, survexblock, qmtick):
|
||||
"""Interpret the specially formatted comment which is a QM TICKED statement"""
|
||||
# Now we need to find the correct QM object. It will be in the same block and have the same number.
|
||||
|
||||
try:
|
||||
qm = QM.objects.filter(block=survexblock, number=int(qmtick.group(1)))
|
||||
except:
|
||||
# raise
|
||||
message = f' ! QM TICK find FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" qmlist:"{qm}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
|
||||
print(message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
if len(qm) > 1:
|
||||
message = f' ! QM TICK MULTIPLE found FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
|
||||
print(message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
qm[0].ticked = True
|
||||
qm[0].save()
|
||||
|
||||
def LoadSurvexQM(self, survexblock, qmline):
|
||||
"""Interpret the specially formatted comment which is a QM definition"""
|
||||
insp = self.insp
|
||||
|
||||
qm_no = qmline.group(1) # this is NOT unique across multiple survex files
|
||||
|
||||
qm_grade = qmline.group(2).strip().upper() # [a-dA-DvVxX?]
|
||||
if qm_grade not in ["A", "B", "C", "D", "X", "V", "?"]:
|
||||
message = f" ! QM{qm_no} INVALID code '{qm_grade}' in '{survexblock.survexfile.path}'"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
|
||||
if qmline.group(3): # usual closest survey station
|
||||
qm_nearest = qmline.group(3)
|
||||
if qmline.group(4):
|
||||
qm_nearest = qm_nearest + "." + qmline.group(4)
|
||||
|
||||
if qmline.group(6) and qmline.group(6) != "-":
|
||||
qm_resolve_station = qmline.group(6)
|
||||
if qmline.group(7):
|
||||
qm_resolve_station = qm_resolve_station + "." + qmline.group(7)
|
||||
else:
|
||||
qm_resolve_station = ""
|
||||
qm_notes = qmline.group(8)
|
||||
# Spec of QM in SVX files:
|
||||
# ;Serial number grade(A/B/C/D/V/X) nearest-station resolution-station description
|
||||
# ;QM1 a hobnob_hallway_2.42 hobnob-hallway_3.42 junction of keyhole passage
|
||||
# ;QM1 a hobnob_hallway_2.42 - junction of keyhole passage
|
||||
|
||||
#;QM1 A B6 - see plan drawing there is definitely a QM
|
||||
|
||||
# NB none of the SurveyStations are in the DB now, so if we want to link to aSurvexStation
|
||||
# we would have to create one. But that is not obligatory and no QMs loaded from CSVs have one
|
||||
|
||||
# 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.
|
||||
|
||||
# create a short, hopefully-unique name for this block to be used in the QM id
|
||||
blockname = survexblock.name[:6] + survexblock.name[-1:]
|
||||
# logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}'
|
||||
|
||||
if survexblock.survexfile.cave:
|
||||
survexblock.survexfile.cave.slug()
|
||||
else:
|
||||
pass
|
||||
if survexblock.date:
|
||||
expoyear = str(survexblock.date.year)
|
||||
else:
|
||||
message = f" ! No survexblock.date in'{survexblock.survexfile.path}', setting to 1976"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
expoyear = "1976"
|
||||
try:
|
||||
qm = QM.objects.create(
|
||||
number=qm_no,
|
||||
# nearest_station=a_survex_station_object, # can be null
|
||||
nearest_station_description=qm_resolve_station,
|
||||
nearest_station_name=qm_nearest,
|
||||
grade=qm_grade.upper(),
|
||||
location_description=qm_notes,
|
||||
block=survexblock, # only set for survex-imported QMs
|
||||
blockname=blockname, # only set for survex-imported QMs
|
||||
expoyear=expoyear,
|
||||
cave=survexblock.survexfile.cave,
|
||||
)
|
||||
qm.save
|
||||
except:
|
||||
qms = QM.objects.filter(
|
||||
number=qm_no,
|
||||
# nearest_station=a_survex_station_object, # can be null
|
||||
nearest_station_description=qm_resolve_station,
|
||||
nearest_station_name=qm_nearest,
|
||||
grade=qm_grade.upper(),
|
||||
location_description=qm_notes,
|
||||
block=survexblock, # only set for survex-imported QMs
|
||||
blockname=blockname, # only set for survex-imported QMs
|
||||
expoyear=expoyear,
|
||||
cave=survexblock.survexfile.cave,
|
||||
)
|
||||
print(qms)
|
||||
message = f" ! QM{qm_no} FAIL to create {qm_nearest} in'{survexblock.survexfile.path}'"
|
||||
print(insp + message)
|
||||
stash_data_issue(
|
||||
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
|
||||
)
|
||||
|
||||
|
||||
def ProcessQM(self, survexblock, qml, comment):
|
||||
"""Process the line beginning
|
||||
|
Loading…
Reference in New Issue
Block a user