当前位置: 首页>>代码示例>>Python>>正文


Python TicketSystem.keys方法代码示例

本文整理汇总了Python中trac.ticket.api.TicketSystem.keys方法的典型用法代码示例。如果您正苦于以下问题:Python TicketSystem.keys方法的具体用法?Python TicketSystem.keys怎么用?Python TicketSystem.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trac.ticket.api.TicketSystem的用法示例。


在下文中一共展示了TicketSystem.keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_tickets

# 需要导入模块: from trac.ticket.api import TicketSystem [as 别名]
# 或者: from trac.ticket.api.TicketSystem import keys [as 别名]
 def _get_tickets(self, filename):
     fieldsLabels = TicketSystem(self.env).get_ticket_field_labels()
     fieldsLabels['id'] = 'id'
     
     invFieldsLabels = {}
     for k in fieldsLabels.keys():
         invFieldsLabels[fieldsLabels[k]] = k
     
     book = xlrd.open_workbook(filename)
     sh = book.sheet_by_index(0)
     columns = [unicode(sh.cell_value(0, c)) for c in range(sh.ncols)]
     
     # columns "id" and "summary" are needed
     if 'id' not in columns and fieldsLabels['id'] not in columns:
         raise TracError('Column "id" not found')
     if 'summary' not in columns and fieldsLabels['summary'] not in columns:
         raise TracError('Column "summary" not found')
     
     fieldsImport = self._get_fields_import()
     
     importFields = []
     columnsIds = {}
     idx = 0
     idIndex = 0
     summaryIndex = 0
     creationIndex = None
     modificationIndex = None
     for c in columns:
         if c not in fieldsLabels.keys() and c in fieldsLabels.values():
             columnsIds[idx] = invFieldsLabels[c]
             if fieldsImport[invFieldsLabels[c]]:
                 importFields.append({'name':invFieldsLabels[c], 'label':c})
         elif c in fieldsLabels.keys() and c not in fieldsLabels.values():
             columnsIds[idx] = c
             if fieldsImport[c]:
                 importFields.append({'name':c, 'label':fieldsLabels[c]})
         else:
             columnsIds[idx] = None
         if columnsIds[idx] == 'id':
             idIndex = idx
         if columnsIds[idx] == 'summary':
             summaryIndex = idx
         if columnsIds[idx] == 'time':
             creationIndex = idx
         if columnsIds[idx] == 'changetime':
             modificationIndex = idx
         idx += 1
                   
     fieldsFormat = self._get_fields_format( importFields + [{'name':'id', 'label':'id'}, {'name':'summary', 'label':fieldsLabels['summary']}] )
     
     warnings = []
     preview = []
     for r in range(1, sh.nrows):
         tid = self.formats['number'].restore( sh.cell_value(r, idIndex) )
         summary = self.formats['text'].restore( sh.cell_value(r, summaryIndex) )
         if tid == '' or tid == None:
             ticket = Ticket(self.env)
             for k in fieldsLabels.keys():
                 defaultValue = ticket.get_value_or_default(k)
                 if defaultValue != None:
                     ticket[k] = defaultValue
             ticket['summary'] = summary
         else:
             ticket = Ticket(self.env, tkt_id=tid)
             if ticket['summary'] != summary:
                 warnings.append('You cannot modify the summary for the ticket #'+unicode(tid))
         
         for idx in columnsIds.keys():
             col = columnsIds[idx]
             if col != None and idx not in [idIndex, summaryIndex, creationIndex, modificationIndex] and col in fieldsFormat.keys():
                 converterId = fieldsFormat[col]
                 converter = self.formats[converterId];
                 value = sh.cell_value(r, idx)
                 value = converter.restore( value )
                 if converter.convert( value ) != converter.convert( ticket[col] ) and converter.convert( value ) != unicode('--'):
                     ticket[col] = value
         preview.append(ticket)
         
     return (preview, importFields, warnings)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:81,代码来源:admin_ui.py


注:本文中的trac.ticket.api.TicketSystem.keys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。