[svn r7650] Length, depth + extent fields in cave pages now calculated from

lengths.dat (which is in turn calculated from dataset).
This commit is contained in:
dave
2007-02-21 16:31:51 +01:00
parent 0c7d3bf30c
commit c8cccbe7bb
6 changed files with 224 additions and 181 deletions

View File

@@ -50,7 +50,7 @@ caves</a></p>
<tr><td>41</td><td class="name"><a href="smkridge/41.htm">Stellerwegh&ouml;hle</a></td><td>8087.9</td><td>356.4</td><td>437.9</td></tr>
<tr><td>76</td><td class="name"><a href="plateau/76/76.htm">Eislufth&ouml;hle</a></td><td>2332.1</td><td>297.2</td><td>234.8</td></tr>
<tr><td>78</td><td class="name"><a href="noinfo/smkridge/78.htm">Schwaben(schacht)h&ouml;hle</a></td><td>7781.4</td><td>328.1</td><td>506.6</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>364.3</td><td>218.0</td><td>108.7</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>384.3</td><td>236.3</td><td>108.7</td></tr>
<tr><td>88</td><td class="name"><a href="noinfo/smkridge/88.htm">L&auml;rchenschacht</a></td><td>1776.7</td><td>216.3</td><td>401.4</td></tr>
<tr><td>90</td><td class="name"><a href="plateau/90/90.html">Br&auml;u Schacht 90</a></td><td>13.0</td><td>12.6</td><td>3.4</td></tr>
<tr><td>91</td><td class="name"><a href="plateau/91/91.html">Br&auml;u Schacht 91</a></td><td>15.0</td><td>14.5</td><td>3.9</td></tr>
@@ -141,8 +141,8 @@ caves</a></p>
<tr><td>2005-96</td><td class="name"><a href="plateau/2005-96/2005-96.html">Schlotschacht</a></td><td>9.1</td><td>7.9</td><td>2.5</td></tr>
<tr><td>2005-99</td><td class="name"><a href="plateau/2005-99/2005-99.html">Ohne Mantel H&ouml;hle</a></td><td>16.1</td><td>4.5</td><td>7.2</td></tr>
<tr><td>2006-04</td><td class="name"><a href="smkridge/2006-04/2006-04.html">Tunnockschacht</a></td><td>506.1</td><td>135.2</td><td>105.7</td></tr>
<tr><td>2006-08</td><td class="name">?</td><td><i>12.1</i></td><td><i>9.0</td><td><i>8.1</i></td></tr>
<tr><td>2006-09</td><td class="name"><a href="smkridge/2006-09/2006-09.html">Random H&ouml;hle</a></td><td>14.0</td><td>13.1</td><td>2.8</td></tr>
<tr><td>2006-08</td><td class="name"><a href="smkridge/2006-08/2006-08.html">Knackered Tacklesack Cave</a></td><td>12.1</td><td>9.0</td><td>8.1</td></tr>
<tr><td>2006-09</td><td class="name"><a href="smkridge/2006-09/2006-09.html">Random Schacht</a></td><td>14.0</td><td>13.1</td><td>2.8</td></tr>
<tr><td>2006-71</td><td class="name"><a href="plateau/2006-71/2006-71.html">?</a></td><td>13.8</td><td>11.9</td><td>6.9</td></tr>
<tr><td>2006-72</td><td class="name"><a href="plateau/2006-72/2006-72.html">?</a></td><td>13.3</td><td>3.1</td><td>10.9</td></tr>
</table>
@@ -165,7 +165,7 @@ caves</a></p>
<tr><td>182</td><td class="name"><a href="plateau/182/182.html">Bovistundpuderzuckerh&ouml;hle</a></td><td>1176.7</td><td>292.3</td><td>301.9</td></tr>
<tr><td>107</td><td class="name"><a href="plateau/107.htm">Gemsh&ouml;hle</a></td><td>593.1</td><td>283.4</td><td>76.5</td></tr>
<tr><td>40</td><td class="name"><a href="noinfo/smkridge/40.htm">Schwarzmooskogeleish&ouml;hle</a></td><td>5258.1</td><td>262.1</td><td>791.8</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>364.3</td><td>218.0</td><td>108.7</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>384.3</td><td>236.3</td><td>108.7</td></tr>
<tr><td>88</td><td class="name"><a href="noinfo/smkridge/88.htm">L&auml;rchenschacht</a></td><td>1776.7</td><td>216.3</td><td>401.4</td></tr>
<tr><td>113</td><td class="name"><a href="smkridge/113.htm">Sonnenstrahlh&ouml;hle</a></td><td>841.9</td><td>206.0</td><td>116.1</td></tr>
<tr><td>131</td><td class="name"><a href="noinfo/remote/131.htm">Thomas-Eish&ouml;hle</a></td><td>1016.9</td><td>192.6</td><td>234.1</td></tr>
@@ -204,7 +204,7 @@ caves</a></p>
<tr><td>LA34</td><td class="name"><a href="1626/la34.htm">R&auml;tselh&ouml;hle</a></td><td>533.1</td><td>425.0</td><td>136.9</td></tr>
<tr><td>2006-04</td><td class="name"><a href="smkridge/2006-04/2006-04.html">Tunnockschacht</a></td><td>506.1</td><td>135.2</td><td>105.7</td></tr>
<tr><td>239</td><td class="name"><a href="smkridge/239/239.html">Rock'n'Roll H&ouml;hle</a></td><td>503.2</td><td>40.4</td><td>172.4</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>364.3</td><td>218.0</td><td>108.7</td></tr>
<tr><td>82</td><td class="name"><a href="plateau/82.htm">Br&auml;uningh&ouml;hle</a></td><td>384.3</td><td>236.3</td><td>108.7</td></tr>
<tr><td>LA12</td><td class="name"><a href="1626/la12.htm">Sternloch</a></td><td>341.5</td><td>331.0</td><td>74.7</td></tr>
<tr><td>31</td><td class="name"><a href="noinfo/smkridge/31.htm">Elchh&ouml;hle</a></td><td>262.7</td><td>26.6</td><td>84.6</td></tr>
<tr><td>158</td><td class="name"><a href="smkridge/158.htm">Donner und Blitzen H&ouml;hle</a></td><td>255.3</td><td>118.0</td><td>47.7</td></tr>

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
import sys,csv,os,cStringIO
CS_BINARY = "cavestats"
N = 30
N = 30 # Number to include in "N longest" and "N deepest" lists
# Utility functions
@@ -35,7 +35,7 @@ def print_caveline(number, l, d, w, cave):
if cave["Autogen file"]: # single caves
dplong.write("""<td class="name"><a href="%s">%s</a></td>""" % (cave["Autogen file"], find_name(cave)))
dplong.write("""<td>%.1f</td><td>%.1f</td><td>%.1f</td></tr>\n""" % (l,d,w))
dump.write("%s\t%d\t%d\n" % (number, l, d))
dump.write("%s\t%d\t%d\t%d\n" % (number, l, d, w))
else: # virtual entries for cave systems
dplong.write("""<td class="name">%s</td>""" % find_name(cave))
dplong.write("""<td><i>%.1f</i></td><td><i>%.1f</td><td><i>%.1f</i></td></tr>\n""" % (l,d,w))
@@ -55,7 +55,7 @@ def parse_csvfile():
# Gratuitiously complicated progress bar widget.
k = 0
m = 1
L = 437 #L = len(cavetabfile.readlines()) doesn't work
L = 498 #L = len(cavetabfile.readlines()) doesn't work
print "0"+50*"-"+"100%\n|",
for cave in cavetab:
if((50*m)/L > k):
@@ -82,7 +82,7 @@ def parse_csvfile():
except:
print "Error on", number
raise
print "|\nWriting output file"
print "|%d\nWriting output file" % m
return caveslist
# Main routine:
@@ -90,7 +90,7 @@ def parse_csvfile():
caveslist = parse_csvfile()
dplong = file("dplong.htm", "w")
dump = file("noinfo/prospecting_guide_scripts/lengths.dat", "w")
dump = file("noinfo/lengths.dat", "w")
dplong.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
@@ -149,6 +149,9 @@ dplong.write("""</table>
<tr>
<th>Kat. Nr.</th><th>Name</th><th>Length (m)</th><th>Depth (m)</th><th>Extent (m)</th></tr>""" % N)
dump.close()
dump = cStringIO.StringIO() # just throw it away!
caveslist.sort(lambda u, v: cmp(v[2],u[2]))
for cave in caveslist[:N]:
print_caveline(*cave)
@@ -189,3 +192,4 @@ caves.</p>
</body>
</html>""")
dump.close()

100
noinfo/lengths.dat Normal file
View File

@@ -0,0 +1,100 @@
31 262 26 84
40 5258 262 791
41 8087 356 437
76 2332 297 234
78 7781 328 506
82 384 236 108
88 1776 216 401
90 12 12 3
91 15 14 3
103 30 30 0
105 40 38 4
107 593 283 76
108 27 26 6
113 841 206 116
115 4720 738 1047
116 221 39 60
131 1016 192 234
135 21 20 1
136 3432 442 774
138 46 42 5
139 20 20 0
143 181 124 35
144 2281 309 574
145 1108 401 354
147 73 11 54
148 91 39 48
158 255 117 47
161 21594 522 901
162 159 32 56
163 57 17 35
172 20 2 19
174 30 30 0
175 20 20 0
176 30 30 0
182 1176 292 301
183 106 70 19
185 94 63 20
193 20 9 8
195 44 37 7
196 27 13 14
199 86 29 34
200 60 40 10
201 15 15 0
202 69 51 25
203 41 35 13
204 12104 544 645
205 90 38 37
206 53 16 43
207 8 1 6
208 15 9 6
209 16 16 3
215 48 10 21
216 104 26 59
220 8 5 6
225 12 12 0
228 29 9 18
229 55 15 30
231 226 26 51
234 1002 120 151
238 49 24 18
239 503 40 172
240 50 43 11
241 53 13 36
242 17 10 5
243 52 30 27
244 156 51 51
245 134 18 47
246 57 46 6
248 132 109 28
249 63 6 51
250 10 6 7
251 169 36 64
LA11 642 375 159
LA12 341 331 74
LA34 533 425 136
2002-W-02 22 9 13
2002-07 41 34 15
2002-08 21 14 10
2002-XX 15 12 4
2003-01 25 9 12
2004-01 14 3 11
2004-03 37 3 17
2004-08 78 7 31
2004-14 22 13 18
2004-15 43 9 33
2004-19 106 21 34
2004-20 9 9 0
2005-01 60 21 15
2005-07 15 8 7
2005-92 20 18 3
2005-93 10 8 4
2005-94 8 7 1
2005-95 19 9 2
2005-96 9 7 2
2005-99 16 4 7
2006-04 506 135 105
2006-08 12 8 8
2006-09 14 13 2
2006-71 13 11 6
2006-72 13 3 10

View File

@@ -10,7 +10,7 @@ use Getopt::Long;
((my $progname = $0) =~ s/^.*\///ig); # basename $0
my $warnings; # set this if we have non fatal problems
my $cvsdirectories = ':'; # this gets filled with directories that should have
# my $cvsdirectories = ':'; # this gets filled with directories that should have
# cvsignores generated in a later pass
# Parse options
@@ -41,17 +41,13 @@ if ($_ ne "noinfo") {
open (CSV, "< $ARGV[0]") or print STDERR "That filename could not be opened. Exiting.\n" and die $!;
open (LENGTHS, "< lengths.dat") or print STDERR "No length data available! Exiting.\n" and die $!;
my %lhash = munge_lengths();
# Go down a directory
chdir "..";
# Clean out old .cvsignore files, and make the new ones ignore themselves...
find(\&wanted , '.');
# Start writing index file, and .cvsignore it
open CI, "> .cvsignore" or die $!;
print CI ".cvsignore\n";
print CI "indxal.htm\n";
close CI;
open INDXAL, "> indxal.htm" or die $!;
print INDXAL << "END";
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -125,9 +121,6 @@ END
close INDXAL;
# Now generate some .cvsignores where we have (possibly) created directories
make_cvsignores();
#print "Information: Making area indices\n";
#make_indices();
@@ -140,31 +133,6 @@ unless ($no_verbose_progress) {
}
print "\n";
# Function to find and remove old .cvsignore files
sub wanted {
/^\.cvsignore\z/s && unlink($_);
}
# Function to determine if a directory has not got files in CVS
# Returns 0 if the directory does have files in CVS
# Returns 1 if the directory's contents has been deleted in CVS
# Returns 2 if the directory is not in CVS
sub notincurrentcvs {
if (-d "$_[0]/CVS") {
open(ENTRIES, "$_[0]/CVS/Entries") or die $!;
my $d;
if (read(ENTRIES, $d, 3) == 2) {
if ($d eq "D\n") {
close(ENTRIES);
return 1;
}
}
close(ENTRIES);
return 0;
}
return 2;
}
# Process a line of the CSV file
# First argument is contents of line to process
# 2nd arg is the Kataster number of the cave an entrance belongs to (optional)
@@ -213,7 +181,23 @@ sub do_this_line {
$linkid =~ s/ /_/;
$linkid = lc($linkid);
# Determine the number of directorys deep the cave's main page is, in order to link to area descriptions and indxal
my $dslen = ($lhash{$linkid}[0] or "");
my $dsdepth = ($lhash{$linkid}[1] or "");
my $dsext = ($lhash{$linkid}[2] or "");
if ($dslen ne "") { $dslen = $dslen."m" };
if ($dsdepth ne "") { $dsdepth = $dsdepth."m" };
if ($dsext ne "") { $dsext = $dsext."m" };
if ($dslen and $length) { $dslen = "$dslen ($length)";};
if ($dsdepth and $depth) { $dsdepth = "$dsdepth ($depth)";};
if ($dsext and $extent) { $dsext = "$dsext ($extent)";};
if ($dslen eq "") { $dslen = $length };
if ($dsdepth eq "") { $dsdepth = $depth };
if ($dsext eq "") { $dsext = $extent };
# Determine the number of directories deep the cave's main page is, in order to link to area descriptions and indxal
my $toroot = 'Q'; # hey; it's magic
my $counter = ($file =~ tr/\///);
while ($counter) {
@@ -278,34 +262,8 @@ sub do_this_line {
my $path = $file;
$path =~ s/\/$fn//g;
# Make the directory that the file is in, in case it doesn't exist yet, and ref count it, so we can later tell if we should cvsignore it.
# Make the directory that the file is in, in case it doesn't exist yet
mkpath($path);
if (my $ret = notincurrentcvs("$path")) {
my $deleted = '';
$cvsdirectories =~ /:$path=(\d+)(D?):/;
if ($1) {
my $count = $1 + 1;
$deleted = 'D' if ($2);
$cvsdirectories =~ s/:$path=$1$deleted:/:/;
$cvsdirectories = join('', $cvsdirectories, "$path=$count$deleted:");
} else {
my $init = 1;
if ($ret eq 1) {
$deleted = 'D';
$init = 2; # initial value of '2' as one-off count of 'CVS'
}
$cvsdirectories = join('', $cvsdirectories, "$path=$init$deleted:");
}
}
# Add created files to a .cvsignore
open CI, ">> $path\/.cvsignore" or die $!;
if (tell(CI) == 0) {
print CI ".cvsignore\n";
}
print CI "$fn\n";
close CI;
# Open the file and start writing to it
open FILE, "> $file" or die $!;
@@ -351,19 +309,19 @@ END
}
print FILE "</th><th id=\"status\">$kat_status</th></tr>\n</table>"; # if no $kat_status, no problem
if ($length or $depth or $extent) {
if ($dslen or $dsdepth or $dsext) {
print FILE "\n\n<p>";
}
if ($length) {
print FILE "<b>Length:</b> $length ";
if ($dslen) {
print FILE "<b>Length:</b> ${dslen} ";
}
if ($depth) {
print FILE "<b>Depth:</b> $depth ";
if ($dsdepth) {
print FILE "<b>Depth:</b> ${dsdepth} ";
}
if ($extent) {
print FILE "<b>Extent:</b> $extent ";
if ($dsext) {
print FILE "<b>Extent:</b> ${dsext} ";
}
if ($length or $depth or $extent) {
if ($dslen or $dsdepth or $dsext) {
print FILE "</p>";
}
@@ -818,36 +776,6 @@ EOF
exit(0);
}
# While generating the XHTML, we noted whenever we made files in a directory that was not in CVS. Now, we see if there are more files in the directory than there would be if we where the only ones using it - if there are not, cvsignore it
sub make_cvsignores {
foreach $_ (split(/:/, $cvsdirectories)) {
next unless $_;
/(.+)=(\d+)/;
my $path = $1;
my $number = $2;
my $count = -3; # offset for a .cvsignore, a '.' and a '..'
opendir(DIR, $path) or die $!;
while (readdir(DIR)) {
$count++;
}
closedir(DIR);
if ($number ne $count) {
print STDERR "Warning: $path has non-autogenerated files, and is not in CVS\n\n";
next; # no cvsignore for you today.
}
open CI, ">> $path\/..\/.cvsignore" or die $!;
if (tell(CI) == 0) {
print CI ".cvsignore\n";
}
($_ = $path) =~ s/^.*\///ig;
print CI "$_\n";
close CI;
}
}
# Parent function for making per area tables from CAVETAB2, which may then be included in some fashion
# Returns nothing
sub make_indices {
@@ -944,3 +872,14 @@ sub area_grep {
}
return(@return);
}
sub munge_lengths {
print "Munging lengths\n";
my %return;
while (<LENGTHS>) {
chomp;
my ($id, $len, $depth, $ext) = split("\t", $_);
$return{"id".lc($id)} = [$len, $depth, $ext];
}
return (%return);
}

View File

@@ -298,7 +298,7 @@ fieldnames=chomp(cavetabfile.next()).replace('"','').split(",")
cavetab = csv.DictReader(cavetabfile, fieldnames)
print "Munging lengths.dat"
lengthsfile = file("lengths.dat")
lengthsfile = file("../lengths.dat")
lengths = {}
for l in lengthsfile:
t = l.replace("\"","").replace("\n", "").split("\t")