from __future__ import annotations import re from enum import Enum import logging from typing import Dict, Any, List, Set, Tuple, Optional import json from agithub import Issue, GitHub, Comment, GitHubError from . import config from . import lilac from .util import annotate_maints, Maintainer logger = logging.getLogger(__name__) IssueType = Enum('IssueType', 'PackageRequest OutOfDate Orphaning Official Error Other') _ParseState = Enum('_ParseState', 'init issuetype packages') _TypeDescMap = { '软件打包请求': IssueType.PackageRequest, '过期软件包': IssueType.OutOfDate, '弃置软件包': IssueType.Orphaning, '软件包被官方仓库收录': IssueType.Official, '打包错误': IssueType.Error, '其它': IssueType.Other, } _PkgPattern = re.compile(r'\w[\w.+-]*\w?') _CANT_PARSE_NEW = '''\ Lilac cannot parse this issue. Did you follow the template? Please update and I'll reopen this. Lilac 无法解析此问题报告。你按照模板填写了吗?请更新,然后我会重新打开这个问题。''' _CANT_PARSE_EDITED = '''\ Lilac still cannot parse this issue, please check against the template. Please update and I'll reopen this. Lilac 依旧无法解析此问题报告,请对照模板检查。请更新,然后我会重新打开这个问题。''' def parse_issue_text(text: str) -> Tuple[Optional[IssueType], List[str]]: st = _ParseState.init skipping = False issuetype = None packages = [] for line in text.splitlines(): if line.endswith('-->'): skipping = False continue elif line.startswith('