diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-07-06 17:35:08 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-07-06 17:35:08 +0300 |
commit | d3572e18c34c20c661eb61c7f8c46358f7223d37 (patch) | |
tree | 5bfddf3a5271e2b44313ef5866f7dee36c344b57 /parsers/QMs.py | |
parent | 7dc3cc3b91e0c8dff87ccc09a73421ab64c2a919 (diff) | |
download | troggle-d3572e18c34c20c661eb61c7f8c46358f7223d37.tar.gz troggle-d3572e18c34c20c661eb61c7f8c46358f7223d37.tar.bz2 troggle-d3572e18c34c20c661eb61c7f8c46358f7223d37.zip |
QM reports all working
Diffstat (limited to 'parsers/QMs.py')
-rw-r--r-- | parsers/QMs.py | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py index ab9ec0f..2aa9bbf 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -27,7 +27,11 @@ def parseCaveQMs(cave,inputFile): have the passage name, e.g. in 204/qm.csv C2000-204-39 B Tree Pitch in Cave Tree treeumphant.28 Gosser Streamway The CSV file does not have the exact date for the QM, only the year, so links to - survex files might be ambiguous. But potentially useful?""" + survex files might be ambiguous. But potentially useful? + + Much of this code assumes that QMs are edited using troggle. This is not done so this code can be deleted. + All QMs are created afresh and this is all only run once on import on a fresh database. + """ if cave=='204-steinBH': try: @@ -59,7 +63,7 @@ def parseCaveQMs(cave,inputFile): return nqms #qmPath = settings.EXPOWEB+inputFile - qmPath = os.path.join(settings.EXPOWEB, inputFile) + qmPath = os.path.join(settings.EXPOWEB, inputFile) # why not use the pathlib stuff ? qmCSVContents = open(qmPath,'rU') dialect=csv.Sniffer().sniff(qmCSVContents.read()) @@ -73,20 +77,22 @@ def parseCaveQMs(cave,inputFile): n += 1 year=int(line[0][1:5]) logslug = f'PH_{int(year)}_{int(n):02d}' + # logbook placeholder code was previously here. No longer needed. #check if placeholder exists for given year, create it if not - message = " ! - "+ str(year) + " logbook: placeholder entry for '" + cave + "' created. DUMMY EXPEDITION ID. Should be re-attached to the actual trip." - if cave=='204-steinBH': - placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="204", title="placeholder for QMs in 204", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date(year, 1, 1),"cave_slug":str(steinBr), "slug": logslug}) - elif cave=='234-Hauch': - placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="234", title="placeholder for QMs in 234", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date(year, 1, 1),"cave_slug":str(hauchHl)}) - # if hadToCreate: - # print(message) - # DataIssue.objects.create(parser='QMs', message=message) + # message = " ! - "+ str(year) + " logbook: placeholder entry for '" + cave + "' created. DUMMY EXPEDITION ID. Should be re-attached to the actual trip." + # if cave=='204-steinBH': + # placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="204", title="placeholder for QMs in 204", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date(year, 1, 1),"cave_slug":str(steinBr), "slug": logslug}) + # elif cave=='234-Hauch': + # placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="234", title="placeholder for QMs in 234", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date(year, 1, 1),"cave_slug":str(hauchHl)}) + # # if hadToCreate: + # # print(message) + # # DataIssue.objects.create(parser='QMs', message=message) QMnum=re.match(r".*?-\d*?-X?(?P<numb>\d*)",line[0]).group("numb") newQM = QM() - newQM.found_by=placeholder + # newQM.found_by=placeholder newQM.number=QMnum newQM.cave = caveid + newQM.blockname = "" if line[1]=="Dig": newQM.grade="D" else: @@ -94,12 +100,12 @@ def parseCaveQMs(cave,inputFile): newQM.area=line[2] newQM.location_description=line[3] - # Troggle checks if QMs are completed by checking if they have a ticked_off_by trip. + # Troggle will in future (?! - written in 2006) check if QMs are completed by checking if they have a ticked_off_by trip. # In the table, completion is indicated by the presence of a completion discription. newQM.completion_description=line[4] newQM.nearest_station_description=line[5] - if newQM.completion_description: - newQM.ticked_off_by=placeholder + # if newQM.completion_description: + # newQM.ticked_off_by=placeholder newQM.comment=line[6] try: @@ -139,15 +145,16 @@ def parse_KH_QMs(kh, inputFile): if res: res=res.groupdict() year=int(res['year']) + # logbook placeholder code was previously here. No longer needed. #check if placeholder exists for given year, create it if not - message = " ! - "+ str(year) + " logbook: placeholder entry for '161 KH' created. DUMMY EXPEDITION ID. Should be re-attached to the actual trip." - placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="161", title="placeholder for QMs in 161", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date((year), 1, 1),"cave_slug":str(kh)}) - # if hadToCreate: + # message = " ! - "+ str(year) + " logbook: placeholder entry for '161 KH' created. DUMMY EXPEDITION ID. Should be re-attached to the actual trip." + # placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, place="161", title="placeholder for QMs in 161", text=message, entry_type="DUMMY", expedition_id=1, defaults={"date": date((year), 1, 1),"cave_slug":str(kh)}) + # # if hadToCreate: # print(message) # DataIssue.objects.create(parser='QMs', message=message) lookupArgs={ - # inadequate now that the sequence numbers are not unique for survex-parsed QMs - 'found_by':placeholder, + #'found_by':placeholder, + 'blockname': "", 'expoyear':year, 'number':res['number'], 'cave': kh, @@ -158,10 +165,10 @@ def parse_KH_QMs(kh, inputFile): 'location_description':res['description'] } instance, created = save_carefully(QM,lookupArgs,nonLookupArgs) - if created: - message = " ! - "+ instance.code() + " QM entry for '161 KH' created. " - print(message) - DataIssue.objects.create(parser='QMs', message=message) + # if created: + # message = " ! - "+ instance.code() + " QM entry for '161 KH' created. " + # print(message) + # DataIssue.objects.create(parser='QMs', message=message) nqms += 1 return nqms |