Xbench: makes QA better and faster v1.1

2021-02-20 我的時光穿梭機
import re,osimport win32com.clientfrom datetime import datetimefrom openpyxl import load_workbookfrom openpyxl.styles import PatternFillmdic={"Jan":"01","Feb":"02","Mar":"03","Apr":"04","May":"05","Jun":"06","Jul":"07","Aug":"08","Sep":"09","Oct":"10","Nov":"11","Dec":"12","January":"01","February":"02","March":"03","April":"04","May":"05","June":"06","July":"07","August":"08","September":"09","October":"10","November":"11","December":"12"}def norm_endate(instr):    year = str(datetime.now().timetuple()[0])    matches=re.search('(\d{1,2})(-|/| )*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| |, ?)*(\d{4}|\d{2})',instr,re.I)    if matches:         mg = matches.groups()        d,m,y = mg[0],mg[2],mg[4]        d = d if len(d)==2 else '0'+d        m = m[0].upper()+m[1:].lower()        m = mdic[m]        if len(y)==2:            y = '19'+y if int(y) > int(year[2:]) else '20'+y        return '{}{}{}'.format(y,m,d)    matches=re.search('(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{1,2})(-|/|, ?)(\d{4}|\d{2})',instr,re.I)    if matches:         mg = matches.groups()        m,d,y = mg[0],mg[2],mg[4]        d = d if len(d)==2 else '0'+d        m = m[0].upper()+m[1:].lower()        m = mdic[m]        if len(y)==2:            y = '19'+y if int(y) > int(year[2:]) else '20'+y        return '{}{}{}'.format(y,m,d)    matches=re.search('(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{4})',instr,re.I)    if matches:         mg = matches.groups()        m,y = mg[0],mg[2]        m = m[0].upper()+m[1:].lower()        m = mdic[m]        return '{}{}'.format(y,m)    matches=re.search('(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{1,2})',instr,re.I)    if matches:         mg = matches.groups()        m,d = mg[0],mg[2]        d = d if len(d)==2 else '0'+d        m = m[0].upper()+m[1:].lower()        m = mdic[m]        return '{}{}'.format(m,d)    matches=re.search('(\d{1,2})(-|/| )(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}',instr,re.I)    if matches:         mg = matches.groups()        d,m = mg[0],mg[2]        d = d if len(d)==2 else '0'+d        m = m[0].upper()+m[1:].lower()        m = mdic[m]        return '{}{}'.format(m,d)    matches=re.search('\d+',instr)    if matches:         return matches.group()def norm_cndate(instr):    matches=re.search('(\d{4}) *年 *(\d{1,2}) *月 *(\d{1,2}) *日',instr)    if matches:         y,m,d = matches.groups()        m = m if len(m)==2 else '0'+m        d = d if len(d)==2 else '0'+d        return '{}{}{}'.format(y,m,d)    matches=re.search('(\d{4}) *年 *(\d{1,2}) *月',instr)    if matches:         y,m = matches.groups()        m = m if len(m)==2 else '0'+m        return '{}{}'.format(y,m)    matches=re.search('(\d{1,2}) *月 *(\d{1,2}) *日',instr)    if matches:         m,d = matches.groups()        m = m if len(m)==2 else '0'+m        d = d if len(d)==2 else '0'+d        return '{}{}'.format(m,d)    matches=re.search('\d+',instr)    if matches:         return matches.group()def reconc(src,tgt,srcptn,tgtptn):    slst=[]    tlst=[]    ptn1=re.compile(srcptn,re.I)    ptn2=re.compile(tgtptn)    for m in re.finditer(ptn1,src):        dat=norm_endate(m.group())        slst.append(dat)    for m in re.finditer(ptn2,tgt):        dat=norm_cndate(m.group())        tlst.append(dat)    slst.sort()    tlst.sort()    return slst==tlstdef xls2xlsx(path):    excel = win32com.client.gencache.EnsureDispatch('Excel.Application')    excel.DisplayAlerts = False    wbxls = excel.Workbooks.Open(path)    outpath = path+'x'    wbxls.SaveAs(outpath,51)    wbxls.Close()    excel.DisplayAlerts = True    excel.Application.Quit()    return outpathdef date2txt(src):    src='{}/{}/{}'.format(src.year,src.month,src.day)    return datetime.strptime(src, "%Y/%m/%d").strftime("%Y%m%d")def color(wks,cell,clrindex):    pattern = PatternFill(start_color=clrindex,                      end_color=clrindex,                      fill_type='solid')    wks[cell].fill = patterndef chkxls(path):    if path.split('.')[-1]=='xls':        path=xls2xlsx(path)    p1x=['(\d{1,2})(-|/| )*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| |, ?)*(\d{4}|\d{2})',     '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{1,2})(-|/|, ?)(\d{4}|\d{2})',     '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{4})',     '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}(-|/| )*(\d{1,2})',     '(\d{1,2})(-|/| )(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]{0,6}',     '\d+'        ]    p1='|'.join(['({})'.format(p) for p in p1x])    p2x=['(\d{4}) *年 *(\d{1,2}) *月 *(\d{1,2}) *日',     '(\d{4}) *年 *(\d{1,2}) *月',     '(\d{1,2}) *月 *(\d{1,2}) *日',     '\d+'        ]    p2='|'.join(['({})'.format(p) for p in p2x])    wb = load_workbook(path)    ws = wb.worksheets[0]    lrow,lcol = ws.max_row,ws.max_column    for r in range(1,lrow+1):        src = ws.cell(r,3).value        tgt = ws.cell(r,4).value        if isinstance(src,datetime):            src=date2txt(src)        if isinstance(tgt,datetime):            tgt=date2txt(tgt)        out = reconc(str(src),str(tgt),p1,p2)        if out == False:            print("Err row: %s"%(r))            color(ws,'C'+str(r),'FFFFC000')            color(ws,'D'+str(r),'FFFFC000')    wb.save(path)    wb.closecurdir=os.path.dirname(os.path.realpath(__file__))for f in os.listdir(curdir):    if f.split('.')[-1] == 'xls':        path = curdir+'\\'+f        chkxls(path)

相關焦點

  • Xbench: makes QA better and faster
    # Recheck false postive nummeric errors (mostly dates) in the QA report from xbench.# Convert the following forms of date into standard form 'yyyymmdd' using norm_endate and norm_endate
  • New role for Gay: No. 1 option on Spurs' second u
    A starter in 47 of the first 50 games of the season, Gay has come off the bench in each of the past three for the Spurs as Popovich seeks to find better balance between his first and second units
  • Easy Image X v1.52 (2015.01.21更新)
    有沒有人想過,我們何不把傳統的Ghost和流行的ImageX合二為一?再配以清晰明了的圖形界面?那會是怎樣一種景象?我們的想法,在 Easy Image X 中得以實現! 更新日誌[2015.1.20] v1.521、修正在UEFI+GPT模式下,當存在WRE分區時,導致無法正常獲取分區列表的問題(感謝@PspL 、@liuqj1228 、@Devil1027 的反饋)2、修正BIOS+MBR模式下對NT6「系統保留」分區的識別3、修正UEFI+GPT模式下對
  • 工作檯租賃 Bench Rental
    How to rent a jewellery benchSan W Studio has a full-equipped jewellery metal studio which is designed and decorated by the director of Jamfactory’s jewellery department
  • 【生肉】Ox Of Agonas Is Better Than Bedlam Reveler Ever Was
    If a cardwants you to fill your graveyard and rewards you with drawing cards and clockingyour opponent on the cheap, it will typically perform better in older formatswhere meeting the conditions isn’t
  • 英文歌曲推薦:復仇女神之歌|《Better Than Revenge》
    她卻出現,帶走了他,聽聽那喝採She took him faster than you could say sabotage.還來不及反抗她就將他拐走I never saw it coming, wouldn't have suspected it.
  • 4.1 QA E-75和E-50M很快將會高清
    以上信息譯自StatusReport源地址:http://ritastatusreport.live/2016/03/30/30032016-qa/坦克世界資料庫,每天最新坦克資訊。若喜歡我們,請推薦給你的「炮友」。資料庫歡迎你的關注和批評!
  • 世界德牧:阿萊克斯的女兒 SG1 Nina v. Ljulin
    精彩點擊SG1 Nina
  • 強大的Win10系統工具:Qwins v1.3.6
    >  Qwins系統工具集成部分開源程序包含:ESD-Decrypter-Wimlib (ESD轉換程序,Dism++提供內核支持)ESEDatabase (ESD連結抓取支持)KMS_VL_ALL (KMS激活腳本,系統體驗激活服務)Retail2VLoffice (Office轉VOL支持)新版變化:2016.07.08 v1.3.5
  • 聽歌學英語:《Better in Time》
    the longest winter迄今為止最長的寒冬without you卻無你的陪伴I didn't know where to turn to我不知道該去往何方See somehow i can't forget you只明白無論如何我都不能忘記你After all that we've
  • 連載 上 | Smarter Faster Better: The Secrets of Being Productive in
    [Charles] Duhigg s skill as a storyteller makes his book so engaging to read.
  • 【英】Better NPM'ing, Tips and Tricks using NPM
    Solution 1 (best): updtr update one dependency, then run the tests, then repeat$ npx updtrSolution 2: npm-check show a pretty menu of all updates$ npx npm-check -u
  • PSP WE2014 v1.0完全中文版發布
    B- 編輯模式-編輯球隊,翻頁過快會出現死機情況,原因同上,解決方法很簡單,放慢翻頁的速度。C- 部分球隊默認陣型的個別位置球員存在出入,這是由於v1.0新增球員過多,分布到部分球隊後無法數據移植,暫時無解。
  • 靈魂歌曲:《better man》(中英版)感動到淚流......
    1.戳上面藍色字,關注「妙音天籟」,可把妙音天籟公眾號置頂,隨時享受妙音; 2.音樂時長:7分12秒,音頻和視頻
  • 植物大戰殭屍2高清版 pvz2hd v1.7.1 內購破解版(安卓)