mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
2to3 sort comparison key change
This commit is contained in:
parent
50d753a87b
commit
0a864c7f87
@ -37,19 +37,11 @@ def padnumber(x):
|
||||
def numericalcmp(x, y):
|
||||
return cmp(padnumber(x), padnumber(y))
|
||||
|
||||
|
||||
|
||||
def caveCmp(x, y):
|
||||
if x.kataster_number:
|
||||
if y.kataster_number:
|
||||
return numericalcmp(x.kataster_number, y.kataster_number) # Note that cave kataster numbers are not generally integers.
|
||||
else:
|
||||
return -1
|
||||
else:
|
||||
if y.kataster_number:
|
||||
return 1
|
||||
else:
|
||||
return numericalcmp(x.unofficial_number, y.unofficial_number)
|
||||
def caveKey(x):
|
||||
"""python3 function for sort.
|
||||
Note that cave kataster numbers are not generally integers
|
||||
"""
|
||||
return x.kataster_number
|
||||
|
||||
def caveindex(request):
|
||||
caves = Cave.objects.all()
|
||||
@ -57,8 +49,9 @@ def caveindex(request):
|
||||
notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ]
|
||||
caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
|
||||
caves1626 = list(Cave.objects.filter(area__short_name = "1626"))
|
||||
caves1623.sort(caveCmp)
|
||||
caves1626.sort(caveCmp)
|
||||
#python2 to python3 issue https://realpython.com/python-sort/
|
||||
caves1623.sort(key=caveKey)
|
||||
caves1626.sort(key=caveKey)
|
||||
return render(request,'caveindex.html', {'caves1623': caves1623, 'caves1626': caves1626, 'notablecaves':notablecaves, 'cavepage': True})
|
||||
|
||||
def millenialcaves(request):
|
||||
|
Loading…
Reference in New Issue
Block a user