~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to utilities/XXXreport2html.py

  • Committer: Sidnei da Silva
  • Date: 2010-03-01 20:15:27 UTC
  • Revision ID: sidnei.da.silva@canonical.com-20100301201527-wswbuhwfpye7y0a8
- Remove utilities

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
##############################################################################
2
 
#
3
 
# Copyright (c) 2002 Zope Corporation and Contributors.
4
 
# All Rights Reserved.
5
 
#
6
 
# This software is subject to the provisions of the Zope Public License,
7
 
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
 
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
 
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
 
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
 
# FOR A PARTICULAR PURPOSE.
12
 
#
13
 
##############################################################################
14
 
"""Beautify a XXX report.
15
 
 
16
 
Creates a HTML file from a XXXReport file.
17
 
 
18
 
$Id: XXXreport2html.py 26446 2004-07-13 16:11:36Z philikon $
19
 
"""
20
 
 
21
 
import sys
22
 
import time
23
 
 
24
 
 
25
 
if len(sys.argv) < 3:
26
 
    print "Usage: beautifyXXX.py <input-filename> <output-filename>"
27
 
    sys.exit()
28
 
 
29
 
inputname = sys.argv[1]
30
 
outputname = sys.argv[2]
31
 
 
32
 
inputfile = open(inputname, "r")
33
 
outputfile = open(outputname, "w")
34
 
 
35
 
# Scan the inputfile. All lines that are "---" are used as delimiters
36
 
 
37
 
comments = []
38
 
# This is file, line, context
39
 
current = ["", 0, []]
40
 
for x in inputfile.readlines():
41
 
    if x == "--\n":
42
 
        print ".",
43
 
        comments.append(current)
44
 
        current = ["", 0, []]
45
 
        currentfile = None
46
 
        continue
47
 
 
48
 
    if not current[0]:
49
 
        splitted = x.split(":")
50
 
        current[0] = splitted[0]
51
 
        current[1] = splitted[1]
52
 
        x = ":".join(splitted[2:])
53
 
    else:
54
 
        splitted = x.split("-")
55
 
        x = "-".join(splitted[2:])
56
 
    current[2].append(x)
57
 
 
58
 
outputfile.write("""<html><head><title>XXX/TODO-Comment report for Zope 3</title>
59
 
</head>
60
 
 
61
 
<body>
62
 
<h1>Zope 3 - Developer report tools: XXX/TODO comments</h1>
63
 
<p>Generated on %(reporttime)s</p>
64
 
<hr>
65
 
<h3>Summary</h3>
66
 
<p>
67
 
 There are currently %(commentcount)s XXX/TODO comments.
68
 
</p>
69
 
<hr/>
70
 
<h3>Listing</h3>
71
 
<ol>""" % {"commentcount" : len(comments),
72
 
           "reporttime" : time.strftime("%a, %d %b %Y %H:%M:%S %Z", time.localtime())
73
 
          })
74
 
 
75
 
# Write the comments down
76
 
 
77
 
for x in comments:
78
 
    outputfile.write("""<li><b>File: %(filename)s:%(line)s</b><br/><pre>%(text)s</pre></li>""" % {'filename':x[0], 'line':x[1], 'text':"".join(x[2])})
79
 
 
80
 
outputfile.write("<ol></body></html>")
81
 
outputfile.flush()
82
 
outputfile.close()