本文整理汇总了Python中trac.ticket.query.Query.get_columns方法的典型用法代码示例。如果您正苦于以下问题:Python Query.get_columns方法的具体用法?Python Query.get_columns怎么用?Python Query.get_columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.ticket.query.Query
的用法示例。
在下文中一共展示了Query.get_columns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_export
# 需要导入模块: from trac.ticket.query import Query [as 别名]
# 或者: from trac.ticket.query.Query import get_columns [as 别名]
def _process_export(self, req):
fields = [ {'name':'id', 'label':'id'} ]
fields.extend( TicketSystem(self.env).get_ticket_fields() )
fieldsFormat = self._get_fields_format(fields)
fieldsExport = self._get_fields_export(fields)
fieldsWeight = self._get_fields_weight(fields)
comment_changeset = req.args.get('export.changeset') and req.args.get('export.changeset') == 'True'
fields = [c for c in fields if fieldsExport[ c['name'] ] ]
fieldnames = [c['name'] for c in fields]
fields.sort( lambda a, b : fieldsWeight[a['name']]-fieldsWeight[b['name']] )
# ticket #8805 : unavailable for python 2.4 or 2.5
#content = BytesIO()
content = cStringIO.StringIO()
headerStyle = xlwt.easyxf('font: bold on; pattern: pattern solid, fore-colour grey25; borders: top thin, bottom thin, left thin, right thin')
wb = xlwt.Workbook()
sheetName = ( 'Tickets - %s' % self.config.get('project','name', '') );
try:
ws = wb.add_sheet( sheetName )
except:
# Project name incompatible with sheet name constraints.
sheetName = 'Tickets'
ws = wb.add_sheet( sheetName )
colIndex = {}
c = 0
for f in fields:
ws.write(0, c, unicode(f['label']),headerStyle)
colIndex[f['name']] = c
c += 1
if comment_changeset:
ws.write(0, c, unicode('Comments in change log'),headerStyle)
constraints = {}
if req.args.get('filter.type') and len(req.args['filter.type']) > 0 :
if type( req.args['filter.type'] ) == list :
constraints['type'] = req.args['filter.type']
else:
constraints['type'] = [ req.args['filter.type'] ]
if req.args.get('filter.version') and len(req.args['filter.version']) > 0 :
if type( req.args['filter.version'] ) == list :
constraints['version'] = req.args['filter.version']
else:
constraints['version'] = [ req.args['filter.version'] ]
if req.args.get('filter.milestone') and len(req.args['filter.milestone']) > 0 :
if type( req.args['filter.milestone'] ) == list :
constraints['milestone'] = req.args['filter.milestone']
else:
constraints['milestone'] = [ req.args['filter.milestone'] ]
if req.args.get('filter.component') and len(req.args['filter.component']) > 0 :
if type( req.args['filter.component'] ) == list :
constraints['component'] = req.args['filter.component']
else:
constraints['component'] = [ req.args['filter.component'] ]
if req.args.get('filter.status') and len(req.args['filter.status']) > 0 :
if type( req.args['filter.status'] ) == list :
constraints['status'] = req.args['filter.status']
else:
constraints['status'] = [ req.args['filter.status'] ]
if req.args.get('filter.priority') and len(req.args['filter.priority']) > 0 :
if type( req.args['filter.priority'] ) == list :
constraints['priority'] = req.args['filter.priority']
else:
constraints['priority'] = [ req.args['filter.priority'] ]
if req.args.get('filter.severity') and len(req.args['filter.severity']) > 0 :
if type( req.args['filter.severity'] ) == list :
constraints['severity'] = req.args['filter.severity']
else:
constraints['severity'] = [ req.args['filter.severity'] ]
if req.args.get('filter.resolution') and len(req.args['filter.resolution']) > 0 :
if type( req.args['filter.resolution'] ) == list :
constraints['resolution'] = req.args['filter.resolution']
else:
constraints['resolution'] = [ req.args['filter.resolution'] ]
query = Query(self.env, cols=fieldnames, order='id', max=sys.maxint, constraints=constraints)
results = query.execute(req)
r = 0
cols = query.get_columns()
for result in results:
r += 1
for col in cols:
value = result[col]
format = self.formats[ fieldsFormat[col] ]
value = format.convert(value)
style = format.get_style(value)
ws.write(r, colIndex[col], value, style)
if comment_changeset:
#.........这里部分代码省略.........