diff options
author | Sam Wenham <sam@wenhams.co.uk> | 2019-03-31 15:39:53 +0100 |
---|---|---|
committer | Sam Wenham <sam@wenhams.co.uk> | 2019-03-31 15:39:53 +0100 |
commit | 9df91b221b4992d29b90caa30ae5a417d5b750d0 (patch) | |
tree | dfd69110a1af8ce3442c47f590bb129ee323a3f1 /parsers/QMs.py | |
parent | 64a4842dcbcbe10c5edb057c0000659f2809c1f9 (diff) | |
download | troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.tar.gz troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.tar.bz2 troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.zip |
Support html and wiki logbook entrys
Move nearest_station to nearest_station_name and make nearest_station a foreign
key to SurvexStation
Lots of tidying
Diffstat (limited to 'parsers/QMs.py')
-rw-r--r-- | parsers/QMs.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py index efc8cd6..602b7af 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -17,19 +17,19 @@ def parseCaveQMs(cave,inputFile): try: steinBr=Cave.objects.get(official_name="Steinbrückenhöhle") except Cave.DoesNotExist: - print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first." + print("Steinbruckenhoehle is not in the database. Please run parsers.cavetab first.") return elif cave=='hauch': try: hauchHl=Cave.objects.get(official_name="Hauchhöhle") except Cave.DoesNotExist: - print "Hauchhoele is not in the database. Please run parsers.cavetab first." + print("Hauchhoele is not in the database. Please run parsers.cavetab first.") return elif cave =='kh': try: kh=Cave.objects.get(official_name="Kaninchenhöhle") except Cave.DoesNotExist: - print "KH is not in the database. Please run parsers.cavetab first." + print("KH is not in the database. Please run parsers.cavetab first.") parse_KH_QMs(kh, inputFile=inputFile) return @@ -48,7 +48,7 @@ def parseCaveQMs(cave,inputFile): elif cave=='hauch': placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, title="placeholder for QMs in 234", text="QMs temporarily attached to this should be re-attached to their actual trips", defaults={"date": date(year, 1, 1),"cave":hauchHl}) if hadToCreate: - print cave+" placeholder logbook entry for " + str(year) + " added to database" + print(cave + " placeholder logbook entry for " + str(year) + " added to database") QMnum=re.match(r".*?-\d*?-X?(?P<numb>\d*)",line[0]).group("numb") newQM = QM() newQM.found_by=placeholder @@ -71,19 +71,18 @@ def parseCaveQMs(cave,inputFile): if preexistingQM.new_since_parsing==False: #if the pre-existing QM has not been modified, overwrite it preexistingQM.delete() newQM.save() - print "overwriting " + str(preexistingQM) +"\r", - + print("overwriting " + str(preexistingQM) +"\r") else: # otherwise, print that it was ignored - print "preserving "+ str(preexistingQM) + ", which was edited in admin \r", + print("preserving " + str(preexistingQM) + ", which was edited in admin \r") except QM.DoesNotExist: #if there is no pre-existing QM, save the new one newQM.save() - print "QM "+str(newQM) + ' added to database\r', + print("QM "+str(newQM) + ' added to database\r') except KeyError: #check on this one continue except IndexError: - print "Index error in " + str(line) + print("Index error in " + str(line)) continue def parse_KH_QMs(kh, inputFile): @@ -104,7 +103,7 @@ def parse_KH_QMs(kh, inputFile): } nonLookupArgs={ 'grade':res['grade'], - 'nearest_station':res['nearest_station'], + 'nearest_station_name':res['nearest_station'], 'location_description':res['description'] } @@ -115,3 +114,4 @@ parseCaveQMs(cave='stein',inputFile=r"1623/204/qm.csv") parseCaveQMs(cave='hauch',inputFile=r"1623/234/qm.csv") parseCaveQMs(cave='kh', inputFile="1623/161/qmtodo.htm") #parseCaveQMs(cave='balkonhoehle',inputFile=r"1623/264/qm.csv") + |