[IGSTK-Developers] Extracting requirements from the bug tracker to latex file
Andy Cedilnik
andy.cedilnik at kitware.com
Mon Jul 18 08:33:12 EDT 2005
Hi All,
Latest version does all this. Attached is the latex file.
#!/usr/bin/env python
import MySQLdb
import sys
import string
HOST = '*****'
DATABASE = '*****'
USER = '*****'
PASSWORD = '*****'
def CleanString(str):
res = ""
for a in UnEncodeString(str):
if a == '_': res += "\\_"
elif a == '%': res += "\\%"
elif a == '{': res += "\\{"
elif a == '}': res += "\\}"
elif a == '[': res += "\\["
elif a == ']': res += "\\]"
elif a == '\\': res += "\\\\"
elif a == '\r': pass
else: res += a
return res
def UnEncodeString(str):
res = string.replace(str, """, "\"")
res = string.replace(res, "<", "<")
res = string.replace(res, ">", ">")
res = string.replace(res, "&", "\\&")
return res
sql = MySQLdb.connect(db=DATABASE, host=HOST, user=USER, passwd=PASSWORD)
cursor = sql.cursor()
cursor.execute("SELECT bug_id, title, description FROM phpbt_bug WHERE
project_id = 10;")
bugs = {}
comments = {}
while 1:
res = cursor.fetchone()
if not res:
break
if not bugs.has_key(res[1]):
bugs[res[1]] = res
else:
print "Problem!! Found two bugs with the same requirement:\n%s\n%s"
% (`res`, `bugs[res[1]]`)
sys.exit(1)
comments[res[1]] = []
ks = bugs.keys()
ks.sort()
print """\\documentclass[letter]{article}
\\begin{document}
\\begin{description}
"""
for a in ks:
if a.startswith("REQ"):
bug = bugs[a]
print "\item[%s - %d]" % (a, bug[0])
print "%s" % CleanString(bug[2])
print ""
cursor.execute("SELECT comment_text FROM phpbt_comment WHERE bug_id
= %d;" % bug[0])
while 1:
res = cursor.fetchone()
if not res:
break
print CleanString(res[0])
print """\\end{description}
\\end{document}"""
Andy
David Gobbi wrote:
> Hi Andy,
>
> The latex requirement document was discussed at the IGSTK t-con, and
> we decided to move ahead with it. The python script just needs to be
> completed so that it produces a complete latex document (see
> attached), and so that it runs pdflatex to produce a .pdf file and
> then posts that file somewhere on the web.
>
> The pdf file could go into the nightly doxygen documentation, into the
> nightly dashboard directory, or somewhere on the wiki.
>
> If you can dedicate the time, there was also an interest in adding
> section headings according to the attached taxonomy document. These
> were not considered to be absolutely necessary, but would be a very
> nice feature.
>
> - David
>
> Andy Cedilnik wrote:
>
>> Hi All,
>>
>> Here is script that I can run every night. It produces the attached
>> file. Let me know if the format is ok.
>>
>> Current problems:
>>
>> * Handle special characters
>> * Do something with NEW_REQ_TEXT
>>
>> #!/usr/bin/env python
>>
>> import MySQLdb
>> import sys
>>
>> HOST = '****'
>> DATABASE = '****'
>> USER = '****'
>> PASSWORD = '****'
>>
>>
>> sql = MySQLdb.connect(db=DATABASE, host=HOST, user=USER,
>> passwd=PASSWORD)
>> cursor = sql.cursor()
>> cursor.execute("SELECT bug_id, title, description FROM phpbt_bug WHERE
>> project_id = 10;")
>>
>> bugs = {}
>> comments = {}
>>
>> while 1:
>> res = cursor.fetchone()
>> if not res:
>> break
>> if not bugs.has_key(res[1]):
>> bugs[res[1]] = res
>> else:
>> print "Problem!! Found two bugs with the same requirement:\n%s\n%s"
>> % (`res`, `bugs[res[1]]`)
>> sys.exit(1)
>> comments[res[1]] = []
>>
>> ks = bugs.keys()
>> ks.sort()
>>
>> for a in ks:
>> if a.startswith("REQ"):
>> bug = bugs[a]
>> print "\section{%s - %d}" % (a, bug[0])
>> print "%s" % bug[2]
>> print ""
>> cursor.execute("SELECT comment_text FROM phpbt_comment WHERE bug_id
>> = %d;" % bug[0])
>> while 1:
>> res = cursor.fetchone()
>> if not res:
>> break
>> print res[0]
>>
>>
>>
--
Andy Cedilnik
Kitware Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: igstkRequirements.tex
Type: text/x-tex
Size: 11148 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/igstk-developers/attachments/20050718/f02b677c/attachment.tex>
More information about the IGSTK-Developers
mailing list