Changeset 4049
- Timestamp:
- 07/21/08 12:31:03 (3 months ago)
- Files:
-
- ticketboxmacro/0.11/TicketBox.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ticketboxmacro/0.11/TicketBox.py
r3958 r4049 12 12 [[TicketBox([report:1])]] ... alternate format of report 13 13 [[TicketBox([report:9?name=val])]] ... report with dynamic variable 14 [[TicketBox({1 ),#50,{2},100)]] ... convination of above14 [[TicketBox({1},#50,{2},100)]] ... convination of above 15 15 [[TicketBox(500pt,{1})]] ... with box width as 50 point 16 16 [[TicketBox(200px,{1})]] ... with box width as 200 pixel … … 19 19 [[TicketBox(\"Other Title\",#1,#2)]] ... likewise 20 20 [[TicketBox('%d tickets',#1,#2)]] ... embed ticket count in title 21 [[TicketBox({1}, inline)]] ... display the box as block element. 22 [[TicketBox({1}, summary)]] ... display with summary per line 23 [[TicketBox({1}, summary=Titre)]] ... specify field name of summary 24 [[TicketBox({1}, ticket=ID)]] ... specify field name of ticket num. 21 25 [[TicketBox({1}, nosort)]] ... display numbers without sort 22 26 }}} … … 48 52 r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 49 53 r"(?P<width>\d+(pt|px|%))", 50 r"(?P<keyword>nosort|summary|inline )",54 r"(?P<keyword>nosort|summary|inline|ticket)(?:=(?P<kwarg>.*))?", 51 55 r"(?P<title1>'.*')", 52 56 r'(?P<title2>".*")'] 57 58 # default name of fields 59 default_summary_field = 'summary' 60 default_ticket_field = 'ticket' 53 61 54 62 def uniq(x): … … 70 78 txt = '' 71 79 items = [] 80 summary = None 81 ticket = default_ticket_field 72 82 summaries = {} 73 show_summary = False74 83 inline = False 75 84 nosort = False 76 85 title = "Tickets" 77 86 args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 78 for arg in [string.strip(s) for s in txt.split(',')]: 87 args = [string.strip(s) for s in txt.split(',')] 88 # process options first 89 for arg in args: 79 90 match = args_re.match(arg) 80 91 if not match: … … 87 98 elif match.group('width'): 88 99 styles['width'] = match.group('width') 89 elif match.group('tktnum'):90 items.append(int(match.group('tktnum')))91 100 elif match.group('keyword'): 92 101 kw = match.group('keyword').lower() 102 kwarg = match.group('kwarg') 93 103 if kw == 'summary': 94 s how_summary = True104 summary = kwarg or default_summary_field 95 105 elif kw == 'inline': 96 106 inline = True 97 107 elif kw == 'nosort': 98 108 nosort = True 109 # pick up ticket numbers and report numbers 110 for arg in args: 111 match = args_re.match(arg) 112 if not match: 113 continue 114 elif match.group('tktnum'): 115 items.append(int(match.group('tktnum'))) 99 116 elif match.group('rptnum') or match.group('rptnum2'): 100 117 num = match.group('rptnum') or match.group('rptnum2') … … 125 142 if rows: 126 143 descriptions = [desc[0] for desc in curs.description] 127 idx = descriptions.index('ticket') 128 summ = descriptions.index('summary') 144 try: 145 idx = descriptions.index(ticket) 146 except: 147 raise Exception('No such column for ticket: %r' 148 % ticket ) 149 if summary: 150 try: 151 sidx = descriptions.index(summary) 152 except: 153 raise Exception('No such column for summary: %r' 154 % summary) 129 155 for row in rows: 130 156 items.append(row[idx]) 131 summaries[row[idx]] = row[summ] 157 if summary: 158 summaries[row[idx]] = row[sidx] 132 159 finally: 133 160 if not hasattr(env, 'get_cnx_pool'): … … 139 166 items.sort() 140 167 html = '' 141 if s how_summary:168 if summary: 142 169 html = string.join([wiki_to_oneliner("%s (#%d)" % (summaries[n],n), 143 170 env,
