[wmlunits] Added per-addon log pages.
This commit is contained in:
parent
978beb556e
commit
80b2ae2cf2
4 changed files with 93 additions and 25 deletions
|
@ -20,6 +20,16 @@ html_header = '''
|
|||
</head>
|
||||
<body><div>'''.strip()
|
||||
|
||||
top_bar = '''
|
||||
<div class="header">
|
||||
<a href="http://www.wesnoth.org">
|
||||
<img src="%(path)swesnoth-logo.jpg" alt="Wesnoth logo"/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<a href="%(path)sindex.html">Wesnoth Units database</a>
|
||||
</div>'''.strip()
|
||||
|
||||
html_footer = '''
|
||||
<div id="footer">
|
||||
<p>%(generation_note)s</p>
|
||||
|
@ -283,16 +293,11 @@ class HTMLOutput:
|
|||
languages = self.wesnoth.languages_found
|
||||
langlist = languages.keys()
|
||||
langlist.sort()
|
||||
|
||||
write(top_bar % {"path" : "../../"})
|
||||
|
||||
write("""
|
||||
<div class="header">
|
||||
<a href="http://www.wesnoth.org">
|
||||
<img src="../../wesnoth-logo.jpg" alt="Wesnoth logo"/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<a href="../../index.html">Wesnoth Units database</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="navbar">
|
||||
""")
|
||||
|
@ -450,6 +455,10 @@ class HTMLOutput:
|
|||
write("</tr>")
|
||||
write("</table>")
|
||||
write("</div></li>\n")
|
||||
|
||||
write("<li><div> </div></li>")
|
||||
write("<li><div> </div></li>")
|
||||
write('<li><a class="unitmenu" href="../../overview.html">Overview</a></li>')
|
||||
|
||||
write("</ul>\n")
|
||||
|
||||
|
|
|
@ -3,25 +3,59 @@ import glob, os, sys, time
|
|||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||
import html_output
|
||||
|
||||
def write_addon_overview(folder, addon):
|
||||
out = open(os.path.join(folder, "index.html"), "wb")
|
||||
def w(x): out.write(x.encode("utf8") + "\n")
|
||||
|
||||
name = addon["name"]
|
||||
|
||||
path = "../"
|
||||
title = name + " Overview"
|
||||
generation_note = "generated on " + time.ctime()
|
||||
|
||||
w(html_output.html_header % locals())
|
||||
|
||||
w(html_output.top_bar % locals())
|
||||
|
||||
w('<div class="overview">')
|
||||
|
||||
eras = addon.get("eras", [])
|
||||
|
||||
w("<h2>" + name + "</h2>")
|
||||
|
||||
if eras:
|
||||
w("<h3>Eras</h3><ul>")
|
||||
for era in eras:
|
||||
epath = os.path.join("en_US", era["id"] + ".html")
|
||||
w('<li><a href="' + epath + '">' + era["name"] + '</a></li>')
|
||||
w("</ul>")
|
||||
|
||||
campaigns = addon.get("campaigns", [])
|
||||
if campaigns:
|
||||
w("<h3>Campaigns</h3><ul>")
|
||||
for campaign in campaigns:
|
||||
cpath = os.path.join("en_US", campaign["id"] + ".html")
|
||||
w('<li><a href="' + cpath + '">' + campaign["name"] + '</a></li>')
|
||||
w("</ul>")
|
||||
|
||||
w('</div> <!-- overview -->')
|
||||
|
||||
w(html_output.html_footer % locals())
|
||||
|
||||
|
||||
def main(folder):
|
||||
out = open(os.path.join(folder, "overview.html"), "wb")
|
||||
def w(x): out.write(x.encode("utf8") + "\n")
|
||||
|
||||
|
||||
path = ""
|
||||
title = "Wesnoth Unit Database Overview"
|
||||
generation_note = "generated on " + time.ctime()
|
||||
|
||||
w(html_output.html_header % locals())
|
||||
|
||||
w("""
|
||||
<div class="header">
|
||||
<a href="http://www.wesnoth.org">
|
||||
<img src="wesnoth-logo.jpg" alt="Wesnoth logo"/>
|
||||
</a>
|
||||
</div>
|
||||
<div class="topnav">
|
||||
<a href="index.html">Wesnoth Units database</a>
|
||||
</div>""")
|
||||
w(html_output.top_bar % locals())
|
||||
|
||||
w('<div class="overview">')
|
||||
|
||||
w('<table class="overview">')
|
||||
w("<tr><th>")
|
||||
|
@ -31,6 +65,7 @@ def main(folder):
|
|||
w("</th><th>")
|
||||
w("Error Log")
|
||||
w("</th></tr>")
|
||||
count = 0
|
||||
total_n = 0
|
||||
total_error_logs = 0
|
||||
for f in sorted(glob.glob(os.path.join(folder, "*"))):
|
||||
|
@ -46,27 +81,31 @@ def main(folder):
|
|||
|
||||
total_n += n
|
||||
|
||||
name = f[len(folder) + 1:]
|
||||
name = f[len(folder):].lstrip("/")
|
||||
error_name = os.path.join(name, "error.log")
|
||||
w('<tr><td>')
|
||||
w(name)
|
||||
w('<a href="' + os.path.join(name, "index.html") + '">' + name + '</a>')
|
||||
w('</td><td>')
|
||||
w(str(n))
|
||||
w('</td><td>')
|
||||
if os.path.exists(error_log):
|
||||
total_error_logs += 1
|
||||
w('<a href="%s">error.log</a>' % error_name)
|
||||
w('<a class="error" href="%s">error.log</a>' % error_name)
|
||||
w("</td></tr>")
|
||||
|
||||
count += 1
|
||||
|
||||
w("<tr><td>")
|
||||
w("Total:")
|
||||
w("Total (for %d addons):" % count)
|
||||
w("</td><td>")
|
||||
w(str(total_n))
|
||||
w("</td><td>")
|
||||
w(str(total_error_logs))
|
||||
w("</td></tr>")
|
||||
|
||||
|
||||
w("</table>")
|
||||
|
||||
w('</div> <!-- overview -->')
|
||||
|
||||
w(html_output.html_footer % locals())
|
||||
|
||||
|
|
|
@ -318,6 +318,15 @@ table.overview td + td {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
table.overview a {
|
||||
table.overview a.error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
div.overview {
|
||||
margin: 0 auto;
|
||||
background-color: #E7D9C0;
|
||||
max-width: 66em;
|
||||
width: auto;
|
||||
border-radius: 1em 1em 1em 1em;
|
||||
border: solid 1px white;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import wesnoth.wmlparser2 as wmlparser2
|
|||
import unit_tree.helpers as helpers
|
||||
import unit_tree.animations as animations
|
||||
import unit_tree.html_output as html_output
|
||||
import unit_tree.overview
|
||||
|
||||
def copy_images():
|
||||
print("Recolorizing pictures.")
|
||||
|
@ -264,6 +265,7 @@ def process_campaign_or_era(addon, cid, define, batchlist):
|
|||
break
|
||||
|
||||
html_output.generate_single_unit_reports(addon, isocode, wesnoth)
|
||||
|
||||
return n
|
||||
|
||||
def batch_process():
|
||||
|
@ -322,7 +324,13 @@ def batch_process():
|
|||
|
||||
yaml.safe_dump(batchlist, open(options.batch, "w"),
|
||||
encoding = "utf-8", default_flow_style = False)
|
||||
|
||||
|
||||
try:
|
||||
unit_tree.overview.write_addon_overview(os.path.join(options.output,
|
||||
name), addon)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
html_output.html_postprocess_all(batchlist)
|
||||
|
||||
def write_unit_ids_UNUSED():
|
||||
|
@ -402,6 +410,7 @@ if __name__ == '__main__':
|
|||
|
||||
html_output.options = options
|
||||
helpers.options = options
|
||||
unit_tree.overview.options = options
|
||||
|
||||
if not options.output:
|
||||
op.print_help()
|
||||
|
@ -444,6 +453,8 @@ if __name__ == '__main__':
|
|||
|
||||
if options.batch:
|
||||
batch_process()
|
||||
|
||||
unit_tree.overview.main(options.output)
|
||||
|
||||
if not options.nocopy:
|
||||
copy_images()
|
||||
|
|
Loading…
Add table
Reference in a new issue