| 1 | """ |
|---|
| 2 | Lists all tickets matching a given regular expression |
|---|
| 3 | |
|---|
| 4 | This macro takes one parameter, the regexp |
|---|
| 5 | """ |
|---|
| 6 | |
|---|
| 7 | import time |
|---|
| 8 | import re |
|---|
| 9 | from StringIO import StringIO |
|---|
| 10 | from trac.util.html import escape |
|---|
| 11 | |
|---|
| 12 | def execute(hdf, args, env): |
|---|
| 13 | db = env.get_db_cnx() |
|---|
| 14 | cursor = db.cursor() |
|---|
| 15 | |
|---|
| 16 | regexp = 'ZZ' |
|---|
| 17 | if args: |
|---|
| 18 | argv = [arg.strip() for arg in args.split(',')] |
|---|
| 19 | if len(argv) > 0: |
|---|
| 20 | regexp = argv[0].replace("'", "''") |
|---|
| 21 | |
|---|
| 22 | sql = "SELECT id, owner, summary, description FROM ticket WHERE status IN ('new', 'assigned', 'reopened')" |
|---|
| 23 | |
|---|
| 24 | cursor.execute(sql) |
|---|
| 25 | |
|---|
| 26 | buf = StringIO() |
|---|
| 27 | while 1: |
|---|
| 28 | row = cursor.fetchone() |
|---|
| 29 | if row == None: |
|---|
| 30 | break |
|---|
| 31 | m = re.search(regexp,row[2]) |
|---|
| 32 | if m: |
|---|
| 33 | buf.write('<a href="%s" title="(%s) %s">[#%s(%s)]</a> ' % (env.href.ticket(row[0]), |
|---|
| 34 | escape(row[2]), |
|---|
| 35 | escape(row[3]), |
|---|
| 36 | row[0], |
|---|
| 37 | escape(row[1]))) |
|---|
| 38 | |
|---|
| 39 | return buf.getvalue() |
|---|
| 40 | |
|---|