mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-01-31 15:32:35 +00:00
import diagnostics
This commit is contained in:
parent
5d7d2b82b2
commit
87fd260051
@ -55,8 +55,8 @@ def parseCaveQMs(cave,inputFile):
|
||||
message = f' ! - {qmPath} KH is not in the database. Please run cave parser'
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='QMs', message=message)
|
||||
parse_KH_QMs(kh, inputFile=inputFile)
|
||||
return
|
||||
nqms = parse_KH_QMs(kh, inputFile=inputFile)
|
||||
return nqms
|
||||
|
||||
#qmPath = settings.EXPOWEB+inputFile
|
||||
qmPath = os.path.join(settings.EXPOWEB, inputFile)
|
||||
@ -67,6 +67,7 @@ def parseCaveQMs(cave,inputFile):
|
||||
qmReader = csv.reader(qmCSVContents,dialect=dialect)
|
||||
next(qmReader) # Skip header row
|
||||
n = 0
|
||||
nqms = 0
|
||||
for line in qmReader:
|
||||
try:
|
||||
n += 1
|
||||
@ -111,7 +112,7 @@ def parseCaveQMs(cave,inputFile):
|
||||
|
||||
except QM.DoesNotExist: #if there is no pre-existing QM, save the new one
|
||||
newQM.save()
|
||||
|
||||
nqms += 1
|
||||
except KeyError: #check on this one
|
||||
message = f' ! - {qmPath} KeyError {str(line)} '
|
||||
print(message)
|
||||
@ -122,12 +123,14 @@ def parseCaveQMs(cave,inputFile):
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='QMs', message=message)
|
||||
continue
|
||||
return nqms
|
||||
|
||||
def parse_KH_QMs(kh, inputFile):
|
||||
"""import QMs from the 1623-161 (Kaninchenhohle) html pages, different format
|
||||
"""
|
||||
khQMs=open(os.path.join(settings.EXPOWEB, inputFile),'r')
|
||||
khQMs=khQMs.readlines()
|
||||
nqms = 0
|
||||
for line in khQMs:
|
||||
res=re.search(r'name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a> (?P<grade>[ABDCV])<dd>(?P<description>.*)\[(?P<nearest_station>.*)\]',line)
|
||||
if res:
|
||||
@ -151,10 +154,16 @@ def parse_KH_QMs(kh, inputFile):
|
||||
}
|
||||
|
||||
save_carefully(QM,lookupArgs,nonLookupArgs)
|
||||
nqms += 1
|
||||
return nqms
|
||||
|
||||
|
||||
def Load_QMs():
|
||||
deleteQMs()
|
||||
parseCaveQMs(cave='204-steinBH',inputFile=r"1623/204/qm.csv")
|
||||
parseCaveQMs(cave='234-Hauch',inputFile=r"1623/234/qm.csv")
|
||||
parseCaveQMs(cave='161-KH', inputFile="1623/161/qmtodo.htm")
|
||||
n204 = parseCaveQMs(cave='204-steinBH',inputFile=r"1623/204/qm.csv")
|
||||
n234 = parseCaveQMs(cave='234-Hauch',inputFile=r"1623/234/qm.csv")
|
||||
n161 = parseCaveQMs(cave='161-KH', inputFile="1623/161/qmtodo.htm")
|
||||
#parseCaveQMs(cave='balkonhoehle',inputFile=r"1623/264/qm.csv")
|
||||
print(f" - Imported: {n204} QMs for 204, {n234} QMs for 234, {n161} QMs for 161.")
|
||||
|
||||
print ()
|
||||
|
Loading…
Reference in New Issue
Block a user