2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-13 22:17:07 +00:00

Convert codebase for python3 usage

This commit is contained in:
Philip Sargent
2020-05-24 01:57:06 +01:00
committed by Wookey
parent 35f85c55f1
commit 50d753a87b
38 changed files with 288 additions and 261 deletions

View File

@@ -38,7 +38,7 @@ def parseCaveQMs(cave,inputFile):
dialect=csv.Sniffer().sniff(qmCSVContents.read())
qmCSVContents.seek(0,0)
qmReader = csv.reader(qmCSVContents,dialect=dialect)
qmReader.next() # Skip header row
next(qmReader) # Skip header row
for line in qmReader:
try:
year=int(line[0][1:5])
@@ -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,9 +71,9 @@ 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()
@@ -82,7 +82,7 @@ def parseCaveQMs(cave,inputFile):
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):