Add a tool to change pdfjs tags in whiteboard (#1278)

This commit is contained in:
calixteman 2022-01-28 15:36:38 +01:00 коммит произвёл GitHub
Родитель dfa6c3cc83
Коммит d5c923cc59
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 172 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,76 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import json
import re
from collections import Counter
from auto_nag.bzcleaner import BzCleaner
TAG_PATTERN = re.compile(r"(\[pdfjs[^\]]*\])")
class PdfJsTagChange(BzCleaner):
def __init__(self):
super(PdfJsTagChange, self).__init__()
with open("extra/pdfjs_tags.json", "r") as In:
self.map = json.load(In)
self.autofix_whiteboard = {}
self.stats = Counter()
def description(self):
return "Change pdfjs tags"
def handle_bug(self, bug, data):
bugid = str(bug["id"])
whiteboard = bug["whiteboard"]
def repl(m):
old = m.group(1)[1:-1]
new = self.map.get(old, old)
if new:
self.stats[new] += 1
return f"[{new}]" if new else ""
new_whiteboard = re.sub(TAG_PATTERN, repl, whiteboard)
if new_whiteboard == whiteboard:
return None
self.autofix_whiteboard[bugid] = {
"whiteboard": new_whiteboard,
}
return None
def get_bz_params(self, date):
params = {
"include_fields": ["whiteboard"],
"resolution": "---",
"f1": "product",
"o1": "equals",
"v1": "Firefox",
"f2": "component",
"o2": "equals",
"v2": "PDF Viewer",
"f3": "status_whiteboard",
"o3": "casesubstring",
"v3": "pdfjs",
}
return params
def get_autofix_change(self):
return self.autofix_whiteboard
def get_bugs(self, date="today", bug_ids=[]):
bugs = super(PdfJsTagChange, self).get_bugs(date=date, bug_ids=bug_ids)
# with open("pdfjs_tags_stats.csv", "w") as Out:
# for key, val in self.stats.items():
# Out.write(f"{key}, {val}\n")
return bugs
if __name__ == "__main__":
PdfJsTagChange().run()

96
extra/pdfjs_tags.json Normal file
Просмотреть файл

@ -0,0 +1,96 @@
{
"pdfjs": "",
"pdfjs-c-annotations": "pdfjs-annotations",
"pdfjs-c-broken": "pdfjs-pdf-broken",
"pdfjs-c-feature": "pdfjs-feature",
"pdfjs-c-ff-integration": "pdfjs-integration",
"pdfjs-c-font-conversion": "pdfjs-font-conversion",
"pdfjs-c-font-windows": "pdfjs-font-windows",
"pdfjs-c-forms": "pdfjs-form-acroform",
"pdfjs-c-image-quality": "pdfjs-image-quality",
"pdfjs-c-integration": "pdfjs-integration",
"pdfjs-c-network": "pdfjs-network",
"pdfjs-c-other": "",
"pdfjs-c-patterns": "pdfjs-pattern",
"pdfjs-c-performance": "pdfjs-performance",
"pdfjs-c-printing": "pdfjs-printing",
"pdfjs-c-rendering": "pdfjs-rendering",
"pdfjs-c-smask": "pdfjs-smask",
"pdfjs-c-testing": "pdfjs-testing",
"pdfjs-c-text-selection": "pdfjs-text-selection",
"pdfjs-c-ux": "pdfjs-ux",
"pdfjs-d-accessibility": "pdfjs-accessibility",
"pdfjs-d-adobe-plugin": "",
"pdfjs-d-annoations": "pdfjs-annotations",
"pdfjs-d-annotations": "pdfjs-annotations",
"pdfjs-d-blend-mode": "pdfjs-blend-mode",
"pdfjs-d-cjk": "pdfjs-cjk",
"pdfjs-d-cmyk-color-conversion": "pdfjs-cmyk-color-conversion",
"pdfjs-d-console-spill": "pdfjs-console-spill",
"pdfjs-d-corrupt-pdf": "pdfjs-corrupted-pdf",
"pdfjs-d-corrupt-pdf???": "pdfjs-corrupted-pdf",
"pdfjs-d-corrupted": "pdfjs-corrupted-pdf",
"pdfjs-d-corrupted-pdf": "pdfjs-corrupted-pdf",
"pdfjs-d-crypt": "pdfjs-crypt",
"pdfjs-d-encoding-rn": "pdfjs-encoding-rn",
"pdfjs-d-fdf-support": "pdfjs-fdf-support",
"pdfjs-d-font-cjk": "pdfjs-cjk",
"pdfjs-d-font-conversion": "pdfjs-font-conversion",
"pdfjs-d-font-linux": "pdfjs-font-linux",
"pdfjs-d-font-osx": "pdfjs-font-osx",
"pdfjs-d-font-windows": "pdfjs-font-windows",
"pdfjs-d-font-wont-sanitize": "pdfjs-font-wont-sanitize",
"pdfjs-d-form-xfa": "pdfjs-form-xfa",
"pdfjs-d-gfx": "pdfjs-gfx",
"pdfjs-d-good-beginner-bug": "pdfjs-good-beginner-bug",
"pdfjs-d-gradient-extend": "pdfjs-gradient-extend",
"pdfjs-d-graphics-primitives": "pdfjs-graphics-primitives",
"pdfjs-d-hwa-off": "pdfjs-hwa-off",
"pdfjs-d-hwa-on": "pdfjs-hwa-on",
"pdfjs-d-image-conversion": "pdfjs-image-conversion",
"pdfjs-d-image-quality": "pdfjs-image-quality",
"pdfjs-d-inline-image": "pdfjs-inline-image",
"pdfjs-d-intermittent-failure": "pdfjs-intermittent-failure",
"pdfjs-d-javascript": "pdfjs-javascript",
"pdfjs-d-jbig2": "pdfjs-image-jbig2",
"pdfjs-d-jpeg": "pdfjs-imagejpeg",
"pdfjs-d-jpx": "pdfjs-image-jpx",
"pdfjs-d-layers": "pdfjs-layers",
"pdfjs-d-linux": "",
"pdfjs-d-mmtype": "pdfjs-mmtype",
"pdfjs-d-need-info": "",
"pdfjs-d-non-standard-font": "pdfjs-non-standard-font",
"pdfjs-d-non-standard-fonts": "pdfjs-non-standard-font",
"pdfjs-d-not-enough-info": "pdfjs-not-enough-info",
"pdfjs-d-opentype": "pdfjs-font-opentype",
"pdfjs-d-os-linux": "",
"pdfjs-d-pattern": "pdfjs-pattern",
"pdfjs-d-printer-specific": "pdfjs-printer-specific",
"pdfjs-d-printing": "pdfjs-printing",
"pdfjs-d-shading-pattern": "pdfjs-shading-pattern",
"pdfjs-d-skia": "pdfjs-skia",
"pdfjs-d-smask": "pdfjs-smask",
"pdfjs-d-standard-font": "pdfjs-standard-font",
"pdfjs-d-text-mode": "pdfjs-text-mode",
"pdfjs-d-text-search": "pdfjs-text-search",
"pdfjs-d-text-selection": "pdfjs-text-selection",
"pdfjs-d-tiling-type": "pdfjs-tiling-type",
"pdfjs-d-trans-group": "pdfjs-trans-group",
"pdfjs-d-triage-needed": "pdfjs-triage-needed",
"pdfjs-d-windows": "",
"pdfjs-d-xfa-support": "pdfjs-form-xfa",
"pdfjs-d-zoom": "pdfjs-zoom",
"pdfjs-f-fixed-upsteam": "pdfjs-fixed-upstream",
"pdfjs-f-fixed-upstream": "pdfjs-fixed-upstream",
"pdfjs-f-font-conversion": "pdfjs-font-conversion",
"pdfjs-f-font-linux": "pdfjs-font-linux",
"pdfjs-f-good-beginner-bug": "pdfjs-good-beginner-bug",
"pdfjs-f-hwa-off": "pdfjs-hwa-off",
"pdfjs-f-need-info": "",
"pdfjs-f-needinfo": "",
"pdfjs-f-regression": "",
"pdfjs-f-ux-wanted": "pdfjs-ux-wanted",
"pdfjs-image-jpx": "pdfjs-image-jpx",
"pdfjs-image-quality": "pdfjs-image-quality",
"pdfjs-need-info": ""
}