配置:
1. 关于 Excel 读/写的时候可能会遇到的问题(基于Python 2.7)——
import xlwt
ImportError: No module named xlwt
Python 表示没有 xlwt (xlrd) 模块,怎么办?自己下啊! (下好了请解压到 Python 目录下 )
自己安装啊!{ #这个仅仅只是一个步骤
win + r
cmd
cd C:\Python27\xlwt-1.0.0
python setup.py install #实际上就是运行该文件夹下面的 setup.py 文件
}
理想程序框架:
虽然是个小程序,但是为了确保自己的思路不在风中凌乱,分为下面的几个层次
Excel info 获取:
因为遍历n 张sheet 使用的是连续的 sheet 编号,所以在遍历每个表的时候最好检查一下表的名字:
print 'The current sheet name is: %s, and sheet num is %d' % (excelfile.sheet_names()[sheetnum],sheetnum)
excelfile.sheet_names()[sheetnum] 得到表名
for i in issuekeyset:
if isinstance(i, float):
self.__issuekey.append( int(i) )
(之所以将 i 转换为 int 类型是因为后面在网页上抓取信息的搜索关键字需要使用 int 类型)
isinstance()方法是一个built-in function,所以查看 python 的官方文档就可以了解用法,当然,对于这种简单的判断是否是 float 的实例实际上可以使用type()
当遍历每个 sheet 的要求列并且写入到对应列表,必然会产生一些重复,要去重:
issuekeyset = set(self.__issuekey) #duplicate removal
Web info 获取:
主要依赖于 JIRA 提供的 API 获取 issue 的相关数据。
逻辑处理
主要是将获得的信息进行处理,将它变成 Excel 报告中希望的样子,主要包括:
——时间的格式(见下 Issue Arise & Solution during scripting):
if ( td.AmPm(createtime.hour) == td.AmPm(now.hour) ) and ( createtime.date() == now.date() ):
crashdetail[4] = 'new'
elif ( td.AmPm(updatetime.hour) == td.AmPm(now.hour) ) and ( updatetime.date() == now.date() ):