[svn r7423] Use CSS to implement the non-colouring of caves which aren't our fault, which

allows smaller HTML output and a simpler script.
Fix "notours" handling of caves with more than one entrance.
This commit is contained in:
olly
2006-06-26 22:05:11 +02:00
parent ebed87265e
commit fbdda01150
2 changed files with 197 additions and 229 deletions

View File

@@ -1,8 +1,6 @@
# Script to create a slightly more useful attempt
# at a prospecting guide.
import re
areas = ['', '1a','1b','1c','1d', '2a', '2b', '2c', '2d', '3', '4', '5', '6','7', '8a', '8b', '8c', '8d', '9', '10', '11']
areanames = {
@@ -44,8 +42,6 @@ areacolours = {
'7' : '#808080'
}
#Regular Expression for comparing to CUCC
REcucc = re.compile('CUCC')
cavelists={}
for a in areas: cavelists[a]=[]
@@ -86,13 +82,10 @@ def is_explored(cave):
print "Rogue space in " + find_effective_number(cave)
return "<td></td>"
code = s[-1]
if REcucc.search(cave['Explorers']):
if code == '+': status = "good"
elif code in ['=', 'x']: status = "bad"
elif code in ['-', '?']: status = "awful"
else: return "<td>%s</td>" % code
else:
status = 'notCUCCsfault'
if code == '+': status = "good"
elif code in ['=', 'x']: status = "bad"
elif code in ['-', '?']: status = "awful"
else: return "<td>%s</td>" % code
return "<td class=\"%s\">%s</td>" % (status, code)
def is_tagged(cave):
@@ -100,92 +93,54 @@ def is_tagged(cave):
s = re.sub(r'\s+(?:\(\?\))?$', "", s)
if not s and cave["Multiple entrances"] in ["yes", "entrance", "last entrance"]:
return "<td></td>"
if REcucc.search(cave['Explorers']):
if s == "Tag": return "<td class=\"good\">%s</td>" % s
if s in ["Retag", "Paint", "Spit"]: return "<td class=\"bad\">%s</td>" % s
if s == "Unmarked": return "<td class=\"awful\">None</td>"
if s == "": return "<td class=\"awful\"></td>"
else:
if s == "Tag": return "<td class=\"notCUCCsfault\">%s</td>" % s
if s in ["Retag", "Paint", "Spit"]: return "<td class=\"notCUCCsfault\">%s</td>" % s
if s == "Unmarked": return "<td class=\"notCUCCsfault\">None</td>"
if s == "": return "<td class=\"notCUCCsfault\"></td>"
if s == "Tag": return "<td class=\"good\">%s</td>" % s
if s in ["Retag", "Paint", "Spit"]: return "<td class=\"bad\">%s</td>" % s
if s == "Unmarked": return "<td class=\"awful\">None</td>"
if s == "": return "<td class=\"awful\"></td>"
print "Unrecognised marking status on %s: %s" % (find_effective_number(cave), repr(s))
return "<td>ERROR</td>"
def findability_color(cave):
if REcucc.search(cave['Explorers']):
if cave["Findability"] == "Surveyed": return "good"
elif cave["Findability"] == "Refindable": return "bad"
elif cave["Findability"] == "Lost": return "awful"
else: return ""
else:
return "notCUCCsfault"
if cave["Findability"] == "Surveyed": return "good"
elif cave["Findability"] == "Refindable": return "bad"
elif cave["Findability"] == "Lost": return "awful"
else: return ""
def is_underground_surveyed(cave):
s = chomp(cave["Underground drawn survey"])
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
if REcucc.search(cave['Explorers']):
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"good\">Yes</td>"
else:
return "<td class=\"bad\">Missing</td>"
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"good\">Yes</td>"
else:
if not s:
return "<td class=\"notCUCCsfault\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"notCUCCsfault\">Yes</td>"
else:
return "<td class=\"notCUCCsfault\">Missing</td>"
return "<td class=\"bad\">Missing</td>"
def have_survey_data(cave):
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
s = chomp(cave["Underground centre line"])
if REcucc.search(cave['Explorers']):
if s: return "<td class=\"good\">Yes</td>"
s = chomp(cave["Survex file to get length and depth"])
if s: return "<td class=\"good\">Yes</td>"
if cave["Kat Status Code"] and cave["Kat Status Code"][0] == '1':
# Cave < 50m deep and < 50m long...
# Sadly this band includes caves we really ought to have data for as
# well as caves small enough that a grade 1 sketch is justifiable.
return "<td class=\"bad\"><small>&lt;50m</small></td>"
s = chomp(cave["Underground drawn survey"])
if s: return "<td class=\"bad\">Missing</td>"
return "<td class=\"awful\">None</td>"
else:
if s: return "<td class=\"notCUCCsfault\">Yes</td>"
s = chomp(cave["Survex file to get length and depth"])
if s: return "<td class=\"notCUCCsfault\">Yes</td>"
if cave["Kat Status Code"] and cave["Kat Status Code"][0] == '1':
# Cave < 50m deep and < 50m long...
# Sadly this band includes caves we really ought to have data for as
# well as caves small enough that a grade 1 sketch is justifiable.
return "<td class=\"notCUCCsfault\"><small>&lt;50m</small></td>"
s = chomp(cave["Underground drawn survey"])
if s: return "<td class=\"notCUCCsfault\">Missing</td>"
return "<td class=\"notCUCCsfault\">None</td>"
if s: return "<td class=\"good\">Yes</td>"
s = chomp(cave["Survex file to get length and depth"])
if s: return "<td class=\"good\">Yes</td>"
if cave["Kat Status Code"] and cave["Kat Status Code"][0] == '1':
# Cave < 50m deep and < 50m long...
# Sadly this band includes caves we really ought to have data for as
# well as caves small enough that a grade 1 sketch is justifiable.
return "<td class=\"bad\"><small>&lt;50m</small></td>"
s = chomp(cave["Underground drawn survey"])
if s: return "<td class=\"bad\">Missing</td>"
return "<td class=\"awful\">None</td>"
def has_photo(cave):
s = chomp(cave["Photo of location"])
if ((cave["Multiple entrances"] not in ["", "yes"]) and chomp(cave["Autogen file"]) == ""):
return "<td></td>"
if REcucc.search(cave['Explorers']):
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"good\">Yes</td>"
else:
return "<td class=\"bad\">Missing</td>"
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"good\">Yes</td>"
else:
if not s:
return "<td class=\"notCUCCsfault\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
return "<td class=\"notCUCCsfault\">Yes</td>"
else:
return "<td class=\"notCUCCsfault\">Missing</td>"
return "<td class=\"bad\">Missing</td>"
def find_label(cave, number):
t = longnumber(cave, number) + " "
@@ -361,7 +316,7 @@ for fnm in ("all.3d", "alltracks.3d"):
draw = draws[mapcode]
lastx, lasty = 0, 0
for l in file3d:
match = re.match(r'^(MOVE|LINE|NODE)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(?:[^[]*\[(.*)\] ?([^]]*)$)?', l)
match = re.match(r'(MOVE|LINE|NODE)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(?:[^[]*\[(.*)\] ?([^]]*)$)?', l)
if not match: continue
act,E,N,alt,name,flags = match.groups()
@@ -377,8 +332,8 @@ for fnm in ("all.3d", "alltracks.3d"):
x,y = map(int, mungecoord(E, N, mapcode))
if act == "LINE":
if re.match(r'\bSURFACE\b', flags):
if re.match(repath, name):
if re.search(r'\bSURFACE\b', flags):
if re.search(repath, name):
draw.line([lastx, lasty, x, y], fill='#008000')
else:
draw.line([lastx, lasty, x, y], fill='#808080')
@@ -437,7 +392,9 @@ htmlfile.write("""
.bad { background-color: #ff9955; text-align: center }
.good { background-color: #99ff99; text-align: center }
.awful { background-color: #ff5555; text-align: center }
.notCUCCsfault { background-color: #ffffff; text-align: center }
.notours .good { background-color: #ffffff; }
.notours .bad { background-color: #ffffff; }
.notours .awful { background-color: #ffffff; }
</style></head>""")
htmlfile.write("<body><h1>Prospecting Guide</h1>")
htmlfile.write("<p><small>Generated " + time.strftime("%x %X") + " by " + sys.argv[0] + "</small></p>\n")
@@ -530,10 +487,18 @@ for area in areas:
htmlfile.write("<tr><th>Cave Number</th><th>Name</th><th>Finished</th><th>Survey<br>Data</th><th>Survey<br>Drawn</th><th>Marked</th><th>Photo</th><th>E</th><th>N</th><th>Alt</th><th>Location</th>")
for (number, cave, locn) in cavelists[area]:
if cave["Autogen file"]:
htmlfile.write("<tr><td><a href=\"../%s\">%s</a></td><td><a id=\"id%s\">%s</a></td>" % (cave["Autogen file"], longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
# We only check the "oursness" for the first entrance.
if cave["Multiple entrances"] in ["", "yes"]:
notours = not re.search(r'\bCUCC\b', cave['Explorers'])
if notours:
htmlfile.write("<tr class=\"notours\">")
else:
htmlfile.write("<tr><td>%s</td><td><a id=\"id%s\">%s</a></td>" % (longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
htmlfile.write("<tr>")
if cave["Autogen file"]:
htmlfile.write("<td><a href=\"../%s\">%s</a></td><td><a id=\"id%s\">%s</a></td>" % (cave["Autogen file"], longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
else:
htmlfile.write("<td>%s</td><td><a id=\"id%s\">%s</a></td>" % (longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
htmlfile.write(is_explored(cave))
htmlfile.write(have_survey_data(cave))