Changeset 4050
- Timestamp:
- 07/21/08 13:57:05 (1 month ago)
- Files:
-
- ticketboxmacro/0.10/TicketBox.py (modified) (7 diffs)
- ticketboxmacro/0.9/TicketBox.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ticketboxmacro/0.10/TicketBox.py
r4015 r4050 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 }}} … … 58 62 r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 59 63 r"(?P<width>\d+(pt|px|%))", 60 r"(?P<keyword>nosort|summary|inline )",64 r"(?P<keyword>nosort|summary|inline|ticket)(?:=(?P<kwarg>.*))?", 61 65 r"(?P<title1>'.*')", 62 66 r'(?P<title2>".*")'] 67 68 # default name of fields 69 default_summary_field = 'summary' 70 default_ticket_field = 'ticket' 63 71 64 72 def uniq(x): … … 77 85 txt = '' 78 86 items = [] 87 summary = None 88 ticket = default_ticket_field 79 89 summaries = {} 80 show_summary = False81 90 inline = False 82 91 nosort = False 83 92 title = "Tickets" 84 93 args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 85 for arg in [string.strip(s) for s in txt.split(',')]: 94 args = [string.strip(s) for s in txt.split(',')] 95 # process options first 96 for arg in args: 86 97 match = args_re.match(arg) 87 98 if not match: … … 94 105 elif match.group('width'): 95 106 styles['width'] = match.group('width') 96 elif match.group('tktnum'):97 items.append(int(match.group('tktnum')))98 107 elif match.group('keyword'): 99 108 kw = match.group('keyword').lower() 109 kwarg = match.group('kwarg') 100 110 if kw == 'summary': 101 s how_summary = True111 summary = kwarg or default_summary_field 102 112 elif kw == 'inline': 103 113 inline = True 104 114 elif kw == 'nosort': 105 115 nosort = True 116 # pick up ticket numbers and report numbers 117 for arg in args: 118 match = args_re.match(arg) 119 if not match: 120 continue 121 elif match.group('tktnum'): 122 items.append(int(match.group('tktnum'))) 106 123 elif match.group('rptnum') or match.group('rptnum2'): 107 124 num = match.group('rptnum') or match.group('rptnum2') … … 139 156 if rows: 140 157 descriptions = [desc[0] for desc in curs.description] 141 idx = descriptions.index('ticket') 142 summ = descriptions.index('summary') 158 try: 159 idx = descriptions.index(ticket) 160 except: 161 raise Exception('No such column for ticket: %r' 162 % ticket ) 163 if summary: 164 try: 165 sidx = descriptions.index(summary) 166 except: 167 raise Exception('No such column for summary: %r' 168 % summary) 143 169 for row in rows: 144 170 items.append(row[idx]) 145 summaries[row[idx]] = row[summ] 171 if summary: 172 summaries[row[idx]] = row[sidx] 146 173 finally: 147 174 if not hasattr(env, 'get_cnx_pool'): … … 154 181 html = '' 155 182 156 if s how_summary:183 if summary: 157 184 html = string.join([wiki_to_oneliner("%s (#%d)" % (summaries[n], n), 158 185 env, env.get_db_cnx()) for n in items], "<br>") ticketboxmacro/0.9/TicketBox.py
r4015 r4050 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 }}} … … 54 58 r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 55 59 r"(?P<width>\d+(pt|px|%))", 56 r"(?P<keyword>nosort|summary|inline )",60 r"(?P<keyword>nosort|summary|inline|ticket)(?:=(?P<kwarg>.*))?", 57 61 r"(?P<title1>'.*')", 58 62 r'(?P<title2>".*")'] 63 64 # default name of fields 65 default_summary_field = 'summary' 66 default_ticket_field = 'ticket' 59 67 60 68 def uniq(x): … … 73 81 txt = '' 74 82 items = [] 83 summary = None 84 ticket = default_ticket_field 75 85 summaries = {} 76 show_summary = False77 86 inline = False 78 87 nosort = False 79 88 title = "Tickets" 80 89 args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 81 for arg in [string.strip(s) for s in txt.split(',')]: 90 args = [string.strip(s) for s in txt.split(',')] 91 # process options first 92 for arg in args: 82 93 match = args_re.match(arg) 83 94 if not match: … … 90 101 elif match.group('width'): 91 102 styles['width'] = match.group('width') 92 elif match.group('tktnum'):93 items.append(int(match.group('tktnum')))94 103 elif match.group('keyword'): 95 104 kw = match.group('keyword').lower() 105 kwarg = match.group('kwarg') 96 106 if kw == 'summary': 97 s how_summary = True107 summary = kwarg or default_summary_field 98 108 elif kw == 'inline': 99 109 inline = True 100 110 elif kw == 'nosort': 101 111 nosort = True 112 # pick up ticket numbers and report numbers 113 for arg in args: 114 match = args_re.match(arg) 115 if not match: 116 continue 117 elif match.group('tktnum'): 118 items.append(int(match.group('tktnum'))) 102 119 elif match.group('rptnum') or match.group('rptnum2'): 103 120 num = match.group('rptnum') or match.group('rptnum2') … … 129 146 if rows: 130 147 descriptions = [desc[0] for desc in curs.description] 131 idx = descriptions.index('ticket') 132 summ = descriptions.index('summary') 148 try: 149 idx = descriptions.index(ticket) 150 except: 151 raise Exception('No such column for ticket: %r' 152 % ticket ) 153 if summary: 154 try: 155 sidx = descriptions.index(summary) 156 except: 157 raise Exception('No such column for summary: %r' 158 % summary) 133 159 for row in rows: 134 160 items.append(row[idx]) 135 summaries[row[idx]] = row[summ] 161 if summary: 162 summaries[row[idx]] = row[sidx] 136 163 finally: 137 164 if not hasattr(env, 'get_cnx_pool'): … … 144 171 html = '' 145 172 146 if s how_summary:173 if summary: 147 174 html = string.join([wiki_to_oneliner("%s (#%d)" % (summaries[n], n), 148 175 env, env.get_db_cnx()) for n in items], "<br>")
