esc-reporting/esc-analyze.py | 36 +++++++++------------- esc-reporting/esc-automate.py | 1 esc-reporting/esc-collect.py | 45 ++++++++++++---------------- esc-reporting/esc-report.py | 62 ++++++--------------------------------- esc-reporting/esc-tocsv.py | 11 +----- esc-reporting/license-analyze.py | 14 ++------ 6 files changed, 53 insertions(+), 116 deletions(-)
New commits: commit 2b6eaae44ac519ffd5f0236ca5089ff4149e8e69 Author: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> AuthorDate: Fri Jul 12 13:33:15 2024 +0300 Commit: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> CommitDate: Tue Jul 16 12:30:51 2024 +0200 esc-reporting: fix issues found by Ruff linter remove unused method DUMP_report() Change-Id: I42b5e6716b6815fb3465e33d59c074e170116f1f Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/170404 Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py index 8289fceb..d2ac1c8e 100755 --- a/esc-reporting/esc-analyze.py +++ b/esc-reporting/esc-analyze.py @@ -46,13 +46,9 @@ import common import sys -import csv -import io import os -import operator import datetime import json -import xmltodict import re import gzip from shutil import copyfile @@ -138,7 +134,7 @@ def util_build_period_stat(xDate, email, base, peopleTarget=None, dataTarget=Non def util_load_data_file(fileName): rawList = util_load_file(fileName) - if rawList == None: + if rawList is None: exit(-1) return rawList @@ -263,7 +259,7 @@ def util_check_mail(name, xmail): if mail in statList['aliases']: mail = statList['aliases'][mail] - if not mail in statList['people']: + if mail not in statList['people']: statList['people'][mail] = util_create_person_gerrit(name, mail) if mail == '*dummy*': statList['people'][mail]['licenseOK'] = True @@ -277,10 +273,10 @@ def util_check_mail(name, xmail): def util_build_diff(newList, oldList): result = {} for i in newList: - if not i in oldList: + if i not in oldList: oldList[i] = newList[i] if type(newList[i]) is dict: - if not type(oldList[i]) is dict: + if type(oldList[i]) is not dict: result[i] = 0 else: result[i] = util_build_diff(newList[i], oldList[i]) @@ -383,7 +379,7 @@ def analyze_mentoring(): statNewDate = cfg['1yearDate'] statOldDate = cfg['nowDate'] for key, row in bugzillaData['bugs'].items(): - if row['status'] == 'RESOLVED' or row['status'] == 'VERIFIED' or not 'easyHack' in row['keywords']: + if row['status'] == 'RESOLVED' or row['status'] == 'VERIFIED' or 'easyHack' not in row['keywords']: continue xDate = datetime.datetime.strptime(row['last_change_time'], "%Y-%m-%dT%H:%M:%SZ") @@ -427,7 +423,7 @@ def analyze_ui(): if xDate > cfg['cutDate']: continue - if not 'topicUI' in row['keywords'] and not 'needsUXEval' in row['keywords']: + if 'topicUI' not in row['keywords'] and 'needsUXEval' not in row['keywords']: continue for change in row['comments']: @@ -594,7 +590,7 @@ def analyze_esc(): fixer = statList['aliases'][fixer] if fixer in statList['people']: fixer = statList['people'][fixer]['name'] - if not fixer in bug_fixers: + if fixer not in bug_fixers: bug_fixers[fixer] = 0 bug_fixers[str(fixer)] += 1 @@ -603,7 +599,7 @@ def analyze_esc(): confirmer = statList['aliases'][confirmer] if confirmer in statList['people']: confirmer = statList['people'][confirmer]['name'] - if not confirmer in bug_confirmers: + if confirmer not in bug_confirmers: bug_confirmers[confirmer] = 0 bug_confirmers[str(confirmer)] += 1 @@ -665,7 +661,6 @@ def analyze_reports(): print("reports: analyze", flush=True) mailedDate = cfg['3monthDate'] - datetime.timedelta(days=90) - zeroDate = datetime.datetime(year=2001, month=1, day=1) statList['reportList'] = {'award_1st_email': [], 'pending_license': [], 'missing_license': [], @@ -698,7 +693,7 @@ def analyze_reports(): automateList['mail']['we_miss_you_email'][entry['email']] = entry['name'] automateData['reminder'][id] = automateNow x = row['commits']['1month']['owner'] - if x != 0 and row['commits']['total'] == x and not id in automateData['award']: + if x != 0 and row['commits']['total'] == x and id not in automateData['award']: automateList['mail']['award_1st_email'][entry['email']] = entry['name'] automateData['award'][entry['email']] = automateNow if row['licenseText'].startswith('PENDING'): @@ -814,22 +809,22 @@ def analyze_reports(): if not email == 'aniste...@gmail.com' and not email == 'mentor...@documentfoundation.org' and 'reviewName' in statList['people'][ownerEmail]['gerrit']: reviewEmail = email break - except Exception as e: + except Exception: pass x = statList['people'][reviewEmail] automateList['gerrit']['to_review'][rowTmp['id']] = {'name': statList['people'][reviewEmail]['gerrit']['reviewName'], 'patchset': rowTmp['patchset'], 'id': rowTmp['id']} for key, row in bugzillaData['bugs'].items(): - if not 'cc' in row: + if 'cc' not in row: row['cc'] = [] - if not 'keywords' in row: + if 'keywords' not in row: row['keywords'] = [] if row['status'] == 'RESOLVED' or row['status'] == 'VERIFIED': continue - if not 'easyHack' in row['keywords']: + if 'easyHack' not in row['keywords']: if 'mentoring' in row['cc']: automateList['bugzilla']['remove_cc'][key] = 0 continue @@ -842,9 +837,9 @@ def analyze_reports(): statList['reportList']['needinfo'].append(key) if len(row['comments']) >= 5: statList['reportList']['too_many_comments'].append(key) - if not 'mentor...@documentfoundation.org' in row['cc']: + if 'mentor...@documentfoundation.org' not in row['cc']: automateList['bugzilla']['missing_cc'][key] = 0 - if row['comments'][-1]['creator'] == 'libreoffice-comm...@lists.freedesktop.org' and not key in cfg['bugzilla']['close_except']: + if row['comments'][-1]['creator'] == 'libreoffice-comm...@lists.freedesktop.org' and key not in cfg['bugzilla']['close_except']: statList['reportList']['to_be_closed'].append(key) cDate = datetime.datetime.strptime(row['creation_time'], "%Y-%m-%dT%H:%M:%SZ") if cDate >= cfg['1weekDate'] or (len(row['history']) > 0 and 'easyhack' in row['history'][-1]['changes'][0]['added']): @@ -892,7 +887,6 @@ def analyze_myfunc(): def buildTrend(xType, xTarget, xDate, xNum): if xNum == 0: return - xStr = str(xNum) if xNum in statList['data']['trend'][xType][xTarget][xDate]: statList['data']['trend'][xType][xTarget][xDate][xNum] += 1 else: diff --git a/esc-reporting/esc-automate.py b/esc-reporting/esc-automate.py index e8c54e54..307c5d89 100755 --- a/esc-reporting/esc-automate.py +++ b/esc-reporting/esc-automate.py @@ -26,7 +26,6 @@ import os import datetime import json import requests -from requests.auth import HTTPDigestAuth from shlex import quote from subprocess import check_call import unidecode diff --git a/esc-reporting/esc-collect.py b/esc-reporting/esc-collect.py index 2ad9cc36..719cdd13 100755 --- a/esc-reporting/esc-collect.py +++ b/esc-reporting/esc-collect.py @@ -30,10 +30,8 @@ import common import sys -import csv import io import os -import operator import datetime import json import xmltodict @@ -66,8 +64,8 @@ def util_load_url(url, useDict=False, useRaw=False, useSkipJSON=False, uUser=Non if useDict: try: - rawData = xmltodict.parse(x) - except Exception as e: + rawData = xmltodict.parse(r) + except Exception: rawData = {'response': {'result': {'project': {}, 'contributor_fact': {}}}} elif useRaw: @@ -77,7 +75,7 @@ def util_load_url(url, useDict=False, useRaw=False, useSkipJSON=False, uUser=Non else: rawData = r.json() r.close() - except Exception as e: + except Exception: raise return rawData @@ -88,7 +86,7 @@ def util_dump_file(fileName, rawList): fp = open(fileName, 'w', encoding='utf-8') json.dump(rawList, fp, ensure_ascii=False, indent=4, sort_keys=True) fp.close() - except Exception as e: + except Exception: os.remove(fileName) raise @@ -96,7 +94,7 @@ def util_dump_file(fileName, rawList): def util_load_data_file(cfg, fileName, funcName, rawListProto): rawList = util_load_file(fileName) - if rawList == None: + if rawList is None: rawList = rawListProto rawList['newest-entry'] = (datetime.datetime.now() - datetime.timedelta(days=365)).strftime("%Y-%m-%d 00") print('retrieving full year of ' + funcName + ', take a coffee') @@ -141,7 +139,6 @@ def get_bugzilla(cfg): searchDate, rawList = util_load_data_file(cfg, fileName, 'bugzilla', {'bugs': {}}) print("Updating bugzilla dump from " + rawList['newest-entry']) - searchData = searchDate - datetime.timedelta(days=2) url = 'https://bugs.documentfoundation.org/rest/bug?' \ 'f2=delta_ts&o2=greaterthaneq&query_format=advanced&v2=' + searchDate.strftime("%Y-%m-%d") + \ '&limit=200&offset=' @@ -158,9 +155,9 @@ def get_bugzilla(cfg): for row in newList: id = str(row['id']) - if not 'cc' in row: + if 'cc' not in row: row['cc'] = [] - if not 'keywords' in row: + if 'keywords' not in row: row['keywords'] = [] tmp = util_load_url(urlH.format(id)) row['history'] = tmp['bugs'][0]['history'] @@ -220,7 +217,6 @@ def do_ESC_QA_STATS_UPDATE(): curLineIndex += 1 # third loop, collect single element - curItemIndex = -1 tmpList = [] while True: startIndex = tmp.find('<td', startIndex) @@ -483,7 +479,7 @@ def get_esc_bugzilla(cfg): rawList['ESC_COMPONENT_UPDATE']['high'][comp]['count'], \ rawList['ESC_COMPONENT_UPDATE']['high'][comp]['list'] = do_ESC_counting(bz, url) - for os in ['Linux (All)', 'Windows (All)', 'macOS (All)', 'All']: + for opsys in ['Linux (All)', 'Windows (All)', 'macOS (All)', 'All']: url = '&keywords=regression' \ '&bug_status=NEW' \ '&bug_status=ASSIGNED' \ @@ -491,10 +487,10 @@ def get_esc_bugzilla(cfg): '&bug_status=PLEASETEST' \ '&bug_severity=blocker' \ '&bug_severity=critical' \ - '&op_sys=' + os - rawList['ESC_COMPONENT_UPDATE']['os'][os] = {} - rawList['ESC_COMPONENT_UPDATE']['os'][os]['count'], \ - rawList['ESC_COMPONENT_UPDATE']['os'][os]['list'] = do_ESC_counting(bz, url) + '&op_sys=' + opsys + rawList['ESC_COMPONENT_UPDATE']['os'][opsys] = {} + rawList['ESC_COMPONENT_UPDATE']['os'][opsys]['count'], \ + rawList['ESC_COMPONENT_UPDATE']['os'][opsys]['list'] = do_ESC_counting(bz, url) url = '&bug_status=UNCONFIRMED' \ '&bug_status=NEW' \ @@ -575,18 +571,18 @@ def get_gerrit(cfg): tmp = util_load_url(url + str(offset), useSkipJSON=True) for row in tmp: for i in 'email', 'username', 'name': - if not i in row['owner']: + if i not in row['owner']: row['owner'][i] = '*dummy*' for x in row['messages']: - if not 'author' in x: + if 'author' not in x: x['author'] = {} for i in 'email', 'username', 'name': - if not i in x['author']: + if i not in x['author']: x['author'][i] = '*dummy*' for i in 'Verified', 'Code-Review': - if not i in row['labels']: + if i not in row['labels']: row['labels'][i] = {} - if not 'all' in row['labels'][i]: + if 'all' not in row['labels'][i]: row['labels'][i]['all'] = [] for x in row['labels'][i]['all']: if 'name' not in x: @@ -602,7 +598,7 @@ def get_gerrit(cfg): xDate = datetime.datetime.strptime(row['updated'], "%Y-%m-%d %H:%M:%S.%f000") if xDate > searchDate: searchDate = xDate - if '_more_changes' in tmp[-1] and tmp[-1]['_more_changes'] == True: + if '_more_changes' in tmp[-1] and tmp[-1]['_more_changes'] is True: rawList['offset'] = offset offset += len(tmp) del rawList['patch'][str(row['_number'])]['_more_changes'] @@ -621,7 +617,6 @@ def get_git(cfg): fileName = cfg['homedir'] + 'dump/git_dump.json' searchDate, rawList = util_load_data_file(cfg, fileName, 'git', {'commits': {}}) print("Updating git dump from " + rawList['newest-entry']) - searchDate - datetime.timedelta(days=1) for repo in cfg['git']['repos']: print(' working on ' + repo['name']) @@ -636,7 +631,7 @@ def get_git(cfg): row = json.loads(x.replace("\", "/")) row['repo'] = repo['name'] key = repo['name'] + '_' + row['hash'] - if not key in rawList['commits']: + if key not in rawList['commits']: row['date'] = row['date'][:-6] rawList['commits'][key] = row x = row['date'].split(' ')[:2] @@ -691,7 +686,7 @@ def runCfg(platform): homeDir = '/home/esc-mentoring/esc' cfg = util_load_file(homeDir + '/config.json') - if cfg == None: + if cfg is None: exit(-1) cfg['homedir'] = homeDir + '/' cfg['platform'] = platform diff --git a/esc-reporting/esc-report.py b/esc-reporting/esc-report.py index 8f830426..959076b4 100755 --- a/esc-reporting/esc-report.py +++ b/esc-reporting/esc-report.py @@ -32,13 +32,9 @@ import common import sys -import csv -import io import os -import operator import datetime import json -import xmltodict from subprocess import check_call @@ -73,7 +69,7 @@ def util_check_mail(xmail): mail = xmail.lower() if mail in statList['aliases']: mail = statList['aliases'][mail] - if not mail in statList['people']: + if mail not in statList['people']: return None else: return mail @@ -249,9 +245,8 @@ def report_esc_prototype(): x1 = statList['data']['esc']['QAstat']['opened'] x2 = statList['diff']['esc']['QAstat']['opened'] x3 = statList['data']['esc']['QAstat']['closed'] - x4 = statList['diff']['esc']['QAstat']['closed'] txt = ' {:+d} {:+d} ({:+d}) overall) many thanks to the top bug squashers: '.format( - x1, -x2, -x3, x4, x1 - x3, x2 - x4) + x1, -x2, -x3) x = statList['escList']['QAstat']['top15_squashers'] for name, count in [(k, x[k]) for k in sorted(x, key=x.get, reverse=True)][0:10]: txt += ' {:<23} {} '.format(name, count) @@ -710,41 +705,6 @@ def report_myfunc(): return None - -def DUMP_report() : - global cfg, statList - return - tot = len(statList['list']['easyHacks_comments']) - print('duming {} easyHacks with more than 5 comments:'.format(tot)) - x = 0 - for id in statList['list']['easyHacks_comments']: - if x%10 == 0: - print('dumping {} of {}'.format(x, tot)) - x += 1 - bug = get_bug(id) - fileName = homeDir + 'bz_comments/bug_' + str(id) + '.json' - try: - fp = open(fileName, 'w') - json.dump(bug, fp, ensure_ascii=False, indent=4, sort_keys=True) - except: - print("could not dump "+fileName) - fp.close() - os.remove(fileName) - exit(-1) - fp.close() - fileName = homeDir + 'bz_comments/comment_' + str(id) + '.json' - try: - fp = open(fileName, 'w') - json.dump(bug['long_desc'], fp, ensure_ascii=False, indent=4, sort_keys=True) - except: - print("could not dump "+fileName) - fp.close() - os.remove(fileName) - exit(-1) - fp.close() - - - def runCfg(platform): global cfg if 'esc_homedir' in os.environ: @@ -775,56 +735,56 @@ def runReport(): xMail = [] try: x = report_bug_metrics() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_bug_metrics failed with ' + str(e)) pass try: x = report_day_mentoring() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_day_mentoring failed with ' + str(e)) pass try: x = report_mentoring() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_mentoring failed with ' + str(e)) pass try: x = report_documentation() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_documentation failed with ' + str(e)) pass try: x = report_ui() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_ui failed with ' + str(e)) pass try: x = report_qa() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_qa failed with ' + str(e)) pass try: x = report_myfunc() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_myfunc failed with ' + str(e)) pass try: x = report_esc_prototype() - if not x is None: + if x is not None: xMail.append(x) except Exception as e: common.util_errorMail(cfg, 'esc-report', 'ERROR: report_esc_prototype failed with ' + str(e)) @@ -839,7 +799,7 @@ def runReport(): error = common.sendMail(cfg, i['mail'], i['title'], text, i['attach']) if error: - common.util_errorMail(cfg, 'esc-report', 'ERROR: mailing failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: mailing failed with ' + str(error)) if __name__ == '__main__': diff --git a/esc-reporting/esc-tocsv.py b/esc-reporting/esc-tocsv.py index fe576d5e..46abb668 100755 --- a/esc-reporting/esc-tocsv.py +++ b/esc-reporting/esc-tocsv.py @@ -15,13 +15,9 @@ import sys -import csv -import io import os -import operator import datetime import json -import xmltodict def util_load_data_file(fileName): @@ -124,7 +120,7 @@ def loadWeekGenerateCSV(argv): email = row['author-email'].lower() if email in statList['aliases']: email = statList['aliases'][email] - if not email in statList['people']: + if email not in statList['people']: raise Exception('email cannot be found!') week = int(((xDate - startDate).days / 7)) x = (xDate - startDate).days @@ -143,9 +139,9 @@ def loadWeekGenerateCSV(argv): weekSum['contributor3TOT'].append(email) xType1 = xType + '1' - if not email in weekSum[xType1][week]: + if email not in weekSum[xType1][week]: weekSum[xType1][week].append(email) - elif not email in weekSum[xType][week]: + elif email not in weekSum[xType][week]: weekSum[xType][week].append(email) committerSum = 0 @@ -172,7 +168,6 @@ def loadWeekGenerateCSV(argv): csv['trend']['contributor'][i] += stats2016['data']['trend']['contributor']['owner']['1year'][ent] i = 1 - type1 = True for week in stats: csv['git']['committer']['week'][i] = week['data']['commits']['committer']['1week']['owner'] csv['git']['committer']['sum'][i] = csv['git']['committer']['week'][i] diff --git a/esc-reporting/license-analyze.py b/esc-reporting/license-analyze.py index 8e8b36e8..a9f4d421 100755 --- a/esc-reporting/license-analyze.py +++ b/esc-reporting/license-analyze.py @@ -22,12 +22,6 @@ -import sys -import csv -import io -import os -import operator -import datetime import collections @@ -194,14 +188,14 @@ def load_wiki(homeDir): def checkConsistency(aliases, domain, license): for dMail in domain: - if not dMail in license: + if dMail not in license: print('>>> domain-map ' + dMail + ' not in licensePersonal !') if dMail in aliases: print('>>> domain-map ' + dMail + ' used as aliaes in aliases !') for entry in aliases: if entry in license: print('>>> aliases ' + entry + ' alias is licensed !') - if not aliases[entry] in license: + if aliases[entry] not in license: print('>>> aliases ' + aliases[entry] + ' target is not licensed !') @@ -216,10 +210,10 @@ def checkWiki(homedir, license, aliases, wiki): email = aliases[email] if email in license: license[email]['inWiki'] = True - continue; + continue if data['name'] in names: license[names[data['name']]]['inWiki'] = True - continue; + continue print("wiki entry missing license: " + str(data)) todo = {} for i in license: