mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-25 08:41:54 +00:00
More pythonic if
This commit is contained in:
parent
05b55391d6
commit
486ef4a633
@ -65,7 +65,7 @@ def exists_in_path(cmd):
|
|||||||
|
|
||||||
def chomp(s):
|
def chomp(s):
|
||||||
if not s: return s
|
if not s: return s
|
||||||
if(s[-1]=="\n"): return s[:-1]
|
if s[-1]=="\n": return s[:-1]
|
||||||
else: return s
|
else: return s
|
||||||
|
|
||||||
def find_effective_number(c):
|
def find_effective_number(c):
|
||||||
@ -77,24 +77,24 @@ def find_effective_number(c):
|
|||||||
|
|
||||||
def longnumber(c, number):
|
def longnumber(c, number):
|
||||||
"""Both numbers"""
|
"""Both numbers"""
|
||||||
if (c["Unofficial number"] and c["Unofficial number"] != number):
|
if c["Unofficial number"] and c["Unofficial number"] != number:
|
||||||
return number + " (" + c["Unofficial number"] + ")"
|
return number + " (" + c["Unofficial number"] + ")"
|
||||||
else:
|
else:
|
||||||
return number
|
return number
|
||||||
|
|
||||||
def find_location(cave):
|
def find_location(cave):
|
||||||
for fixtype in ["tag point in dataset", "other point in dataset", "exact entrance in dataset (drip line/highest enclosed contour)", "GPS post SA", "GPS pre SA"]:
|
for fixtype in ["tag point in dataset", "other point in dataset", "exact entrance in dataset (drip line/highest enclosed contour)", "GPS post SA", "GPS pre SA"]:
|
||||||
if(cave[fixtype]):
|
if cave[fixtype]:
|
||||||
return positions[cave[fixtype]]
|
return positions[cave[fixtype]]
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def is_explored(cave):
|
def is_explored(cave):
|
||||||
s = cave["Kat Status Code"]
|
s = cave["Kat Status Code"]
|
||||||
if(not s): return "<td></td>"
|
if not s: return "<td></td>"
|
||||||
s = s.replace("(?)","")
|
s = s.replace("(?)","")
|
||||||
if s[-1] == " ": s=s[:-1]
|
if s[-1] == " ": s=s[:-1]
|
||||||
if (not s):
|
if not s:
|
||||||
print "Rogue space in " + find_effective_number(cave)
|
print "Rogue space in " + find_effective_number(cave)
|
||||||
return "<td></td>"
|
return "<td></td>"
|
||||||
code = s[-1]
|
code = s[-1]
|
||||||
@ -124,16 +124,16 @@ def findability_color(cave):
|
|||||||
|
|
||||||
def is_underground_surveyed(cave):
|
def is_underground_surveyed(cave):
|
||||||
s = chomp(cave["Underground drawn survey"])
|
s = chomp(cave["Underground drawn survey"])
|
||||||
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
|
if cave["Multiple entrances"] not in ["", "yes"]: return "<td></td>"
|
||||||
if not s:
|
if not s:
|
||||||
return "<td class=\"awful\">None</td>"
|
return "<td class=\"awful\">None</td>"
|
||||||
if s and (s.find("<img") > -1 or s.find("<a") > -1):
|
if s.find("<img") > -1 or s.find("<a") > -1:
|
||||||
return "<td class=\"good\">Yes</td>"
|
return "<td class=\"good\">Yes</td>"
|
||||||
else:
|
else:
|
||||||
return "<td class=\"bad\">Missing</td>"
|
return "<td class=\"bad\">Missing</td>"
|
||||||
|
|
||||||
def have_survey_data(cave):
|
def have_survey_data(cave):
|
||||||
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
|
if cave["Multiple entrances"] not in ["", "yes"]: return "<td></td>"
|
||||||
s = chomp(cave["Underground centre line"])
|
s = chomp(cave["Underground centre line"])
|
||||||
if s: return "<td class=\"good\">Yes</td>"
|
if s: return "<td class=\"good\">Yes</td>"
|
||||||
s = chomp(cave["Survex file to get length and depth"])
|
s = chomp(cave["Survex file to get length and depth"])
|
||||||
@ -149,11 +149,11 @@ def have_survey_data(cave):
|
|||||||
|
|
||||||
def has_photo(cave):
|
def has_photo(cave):
|
||||||
s = chomp(cave["Photo of location"])
|
s = chomp(cave["Photo of location"])
|
||||||
if ((cave["Multiple entrances"] not in ["", "yes"]) and chomp(cave["Autogen file"]) == ""):
|
if (cave["Multiple entrances"] not in ["", "yes"]) and chomp(cave["Autogen file"]) == "":
|
||||||
return "<td></td>"
|
return "<td></td>"
|
||||||
if not s:
|
if not s:
|
||||||
return "<td class=\"awful\">None</td>"
|
return "<td class=\"awful\">None</td>"
|
||||||
if s and (s.find("<img") > -1 or s.find("<a") > -1):
|
if s.find("<img") > -1 or s.find("<a") > -1:
|
||||||
return "<td class=\"good\">Yes</td>"
|
return "<td class=\"good\">Yes</td>"
|
||||||
else:
|
else:
|
||||||
return "<td class=\"bad\">Missing</td>"
|
return "<td class=\"bad\">Missing</td>"
|
||||||
@ -165,7 +165,7 @@ def find_label(cave, number):
|
|||||||
else: t += cave["Unofficial Name"]
|
else: t += cave["Unofficial Name"]
|
||||||
try:
|
try:
|
||||||
n = number
|
n = number
|
||||||
if(n[-1] in string.lowercase): n = n[:-1]
|
if n[-1] in string.lowercase: n = n[:-1]
|
||||||
except:
|
except:
|
||||||
n = "NONE"
|
n = "NONE"
|
||||||
if lengths.has_key(n):
|
if lengths.has_key(n):
|
||||||
@ -392,7 +392,7 @@ cavestoplot = []
|
|||||||
for cave in cavetab:
|
for cave in cavetab:
|
||||||
if cave["Link file"]: continue
|
if cave["Link file"]: continue
|
||||||
number = find_effective_number(cave)
|
number = find_effective_number(cave)
|
||||||
if cave["Multiple entrances"] not in ["", "yes"]):
|
if cave["Multiple entrances"] not in ["", "yes"]:
|
||||||
number = "—" + cachednumber + cave["Entrances"]
|
number = "—" + cachednumber + cave["Entrances"]
|
||||||
shortnumber = cachednumber
|
shortnumber = cachednumber
|
||||||
if not cave["Area"]: cave["Area"] = cachedarea
|
if not cave["Area"]: cave["Area"] = cachedarea
|
||||||
@ -560,7 +560,7 @@ for area in areas:
|
|||||||
htmlfile.write(has_photo(cave))
|
htmlfile.write(has_photo(cave))
|
||||||
|
|
||||||
htmlfile.write(locn)
|
htmlfile.write(locn)
|
||||||
if(cave["Findability"] != "Surveyed" and cave["Multiple entrances"] != "yes"):
|
if cave["Findability"] != "Surveyed" and cave["Multiple entrances"] != "yes":
|
||||||
htmlfile.write("<td class=\"locn\">%s %s</td>" % (cave["Location"], cave["Bearings"]))
|
htmlfile.write("<td class=\"locn\">%s %s</td>" % (cave["Location"], cave["Bearings"]))
|
||||||
htmlfile.write("</tr>\n")
|
htmlfile.write("</tr>\n")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user