#!/usr/bin/python #-*- coding:utf-8 –*- import os import sys import re import shutil import xlrd import xlwt from xlutils.copy import copy ''' 提取相关RELEASE信息,追加“SW Release Note.xls” 运行命令 ./gen_release.py "Modified reason" ''' def fun_genRelease(): list = [] curLine = "" book = xlrd.open_workbook(r'./mergedir/SW Release Note.xls',formatting_info=True) sheet = book.sheet_by_index(0) newBook = copy(book) newSheet = newBook.get_sheet(0) list.append(sheet.nrows-1) with open("./drivers/include/project.h", "r") as mFile: proData = mFile.read() with open("./aps/include/common_patch.h","r") as comFile: comData = comFile.read() modeId = re.search(".*DEFAULT_MODE_IDs+(d+).*",comData).group(1) pat = re.compile(".*?(d+).*{.*"((d+)_.*)",s+&w+[d+],s+/*(.*?)*/s+&w+[d+],s+/*(.*)*/.*") list.append(re.search(".*CONFIG_APP_FOLDER_NAME.*"(.*)"", proData).group(1)) board = re.search(".*CONFIG_MODEL_BOARD_NAMEs+"(w+)"",proData).group(1) with open("./aps/customer/radisson/%s/adaptable/model_data.c" %board,"r") as modeFile: modeList = modeFile.readlines() for line in modeList: if pat.search(line) and pat.search(line).group(1) == modeId: curLine = line break list.append(pat.search(curLine).group(2)) list.append(pat.search(curLine).group(3)) list.append(pat.search(curLine).group(4)) list.append(pat.search(curLine).group(5)) list.append("LL" if "LL" in pat.search(curLine).group(2) else "NON LL") list.append("" if len(sys.argv) ==1 else sys.argv[1]) with open("./aps/include/timestamp.h","r") as verFile: verData = verFile.read() list.append("%s%s" %(board,re.search(".*TIME_VERSIONs+"(w+)".*",verData).group(1))) list.append("") list.append("") list.append("bjornLee") #写EXCEL #for col in range(sheet.ncols): col = 0 for cell in list: newSheet.write(sheet.nrows,col,cell) col = col+1 #newSheet.write(sheet.nrows,col,"test") newBook.save(r'./mergedir/SW Release Note.xls') print " ",list," " def main(): fun_genRelease() if __name__ == '__main__': main()