Back to index

plone3  3.1.7
XXXreport2html.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2002 Zope Corporation and Contributors.
00004 # All Rights Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00008 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00009 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00010 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00011 # FOR A PARTICULAR PURPOSE.
00012 #
00013 ##############################################################################
00014 """Beautify a XXX report.
00015 
00016 Creates a HTML file from a XXXReport file.
00017 
00018 """
00019 
00020 import sys
00021 import time
00022 
00023 
00024 if len(sys.argv) < 3:
00025     print "Usage: beautifyXXX.py <input-filename> <output-filename>"
00026     sys.exit()
00027 
00028 inputname = sys.argv[1]
00029 outputname = sys.argv[2]
00030 
00031 inputfile = open(inputname, "r")
00032 outputfile = open(outputname, "w")
00033 
00034 # Scan the inputfile. All lines that are "---" are used as delimiters
00035 
00036 comments = []
00037 # This is file, line, context
00038 current = ["", 0, []]
00039 for x in inputfile.readlines():
00040     if x == "--\n":
00041         print ".",
00042         comments.append(current)
00043         current = ["", 0, []]
00044         currentfile = None
00045         continue
00046 
00047     if not current[0]:
00048         splitted = x.split(":")
00049         current[0] = splitted[0]
00050         current[1] = splitted[1]
00051         x = ":".join(splitted[2:])
00052     else:
00053         splitted = x.split("-")
00054         x = "-".join(splitted[2:])
00055     current[2].append(x)
00056 
00057 outputfile.write("""<html><head><title>XXX/TODO/BBB-Comment report for ATContentTypes</title>
00058 </head>
00059 
00060 <body>
00061 <h1>ATContentTypes - Developer report tools: XXX/TODO/BBB comments</h1>
00062 <p>Generated on %(reporttime)s</p>
00063 <hr>
00064 <h3>Summary</h3>
00065 <p>
00066  There are currently %(commentcount)s XXX/TODO/BBB comments.
00067 </p>
00068 <hr />
00069 <h3>Listing</h3>
00070 <ol>""" % {"commentcount" : len(comments),
00071            "reporttime" : time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime())
00072           })
00073 
00074 # Write the comments down
00075 
00076 for x in comments:
00077     outputfile.write("""<li><b>File: %(filename)s:%(line)s</b><br /><pre>%(text)s</pre></li>""" % {'filename':'ATContentTypes'+x[0][5:], 'line':x[1], 'text':"".join(x[2])})
00078 
00079 outputfile.write("<ol></body></html>")
00080 outputfile.flush()
00081 outputfile.close()