diff options
Diffstat (limited to 'meta/lib/patchtest/patterns.py')
-rw-r--r-- | meta/lib/patchtest/patterns.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/meta/lib/patchtest/patterns.py b/meta/lib/patchtest/patterns.py new file mode 100644 index 0000000000..ba97a4ffe9 --- /dev/null +++ b/meta/lib/patchtest/patterns.py | |||
@@ -0,0 +1,92 @@ | |||
1 | # common pyparsing variables | ||
2 | # | ||
3 | # Copyright (C) 2016 Intel Corporation | ||
4 | # | ||
5 | # SPDX-License-Identifier: GPL-2.0-only | ||
6 | |||
7 | import pyparsing | ||
8 | |||
9 | # general | ||
10 | colon = pyparsing.Literal(":") | ||
11 | line_start = pyparsing.LineStart() | ||
12 | line_end = pyparsing.LineEnd() | ||
13 | at = pyparsing.Literal("@") | ||
14 | lessthan = pyparsing.Literal("<") | ||
15 | greaterthan = pyparsing.Literal(">") | ||
16 | opensquare = pyparsing.Literal("[") | ||
17 | closesquare = pyparsing.Literal("]") | ||
18 | inappropriate = pyparsing.CaselessLiteral("Inappropriate") | ||
19 | submitted = pyparsing.CaselessLiteral("Submitted") | ||
20 | |||
21 | # word related | ||
22 | nestexpr = pyparsing.nestedExpr(opener='[', closer=']') | ||
23 | inappropriateinfo = pyparsing.Literal("Inappropriate") + nestexpr | ||
24 | submittedinfo = pyparsing.Literal("Submitted") + nestexpr | ||
25 | word = pyparsing.Word(pyparsing.alphas) | ||
26 | worddot = pyparsing.Word(pyparsing.alphas+".") | ||
27 | |||
28 | # metadata | ||
29 | |||
30 | metadata_lic = 'LICENSE' | ||
31 | invalid_license = 'PATCHTESTINVALID' | ||
32 | metadata_chksum = 'LIC_FILES_CHKSUM' | ||
33 | license_var = 'LICENSE' | ||
34 | closed = 'CLOSED' | ||
35 | lictag_re = pyparsing.AtLineStart("License-Update:") | ||
36 | lic_chksum_added = pyparsing.AtLineStart("+" + metadata_chksum) | ||
37 | lic_chksum_removed = pyparsing.AtLineStart("-" + metadata_chksum) | ||
38 | add_mark = pyparsing.Regex('\\+ ') | ||
39 | patch_max_line_length = 200 | ||
40 | metadata_src_uri = 'SRC_URI' | ||
41 | metadata_summary = 'SUMMARY' | ||
42 | cve_check_ignore_var = 'CVE_CHECK_IGNORE' | ||
43 | cve_status_var = 'CVE_STATUS' | ||
44 | |||
45 | # mbox | ||
46 | auh_email = 'auh@yoctoproject.org' | ||
47 | |||
48 | invalid_submitters = [pyparsing.Regex("^Upgrade Helper.+"), | ||
49 | pyparsing.Regex(auh_email), | ||
50 | pyparsing.Regex("uh@not\.set"), | ||
51 | pyparsing.Regex("\S+@example\.com")] | ||
52 | |||
53 | mbox_bugzilla = pyparsing.Regex('\[\s?YOCTO.*\]') | ||
54 | mbox_bugzilla_validation = pyparsing.Regex('\[(\s?YOCTO\s?#\s?(\d+)\s?,?)+\]') | ||
55 | mbox_revert_shortlog_regex = pyparsing.Regex('Revert\s+".*"') | ||
56 | mbox_shortlog_maxlength = 90 | ||
57 | |||
58 | # patch | ||
59 | |||
60 | cve = pyparsing.Regex("CVE\-\d{4}\-\d+") | ||
61 | cve_payload_tag = pyparsing.Regex("\+CVE:(\s+CVE\-\d{4}\-\d+)+") | ||
62 | upstream_status_regex = pyparsing.AtLineStart("+" + "Upstream-Status") | ||
63 | |||
64 | # shortlog | ||
65 | |||
66 | shortlog_target = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables.replace(':',''))) | ||
67 | shortlog_summary = pyparsing.OneOrMore(pyparsing.Word(pyparsing.printables)) | ||
68 | shortlog = line_start + shortlog_target + colon + shortlog_summary + line_end | ||
69 | |||
70 | # signed-off-bys | ||
71 | |||
72 | email_pattern = pyparsing.Regex(r"(?P<user>[A-Za-z0-9._%+-]+)@(?P<hostname>[A-Za-z0-9.-]+)\.(?P<domain>[A-Za-z]{2,})") | ||
73 | |||
74 | signed_off_by_prefix = pyparsing.Literal("Signed-off-by:") | ||
75 | signed_off_by_name = pyparsing.Regex('\S+.*(?= <)') | ||
76 | signed_off_by_email = lessthan + email_pattern + greaterthan | ||
77 | signed_off_by = pyparsing.AtLineStart(signed_off_by_prefix + signed_off_by_name + signed_off_by_email) | ||
78 | patch_signed_off_by = pyparsing.AtLineStart("+" + signed_off_by_prefix + signed_off_by_name + signed_off_by_email) | ||
79 | |||
80 | # upstream-status | ||
81 | |||
82 | upstream_status_literal_valid_status = ["Pending", "Backport", "Denied", "Inappropriate", "Submitted"] | ||
83 | upstream_status_nonliteral_valid_status = ["Pending", "Backport", "Denied", "Inappropriate [reason]", "Submitted [where]"] | ||
84 | |||
85 | upstream_status_valid_status = pyparsing.Or( | ||
86 | [pyparsing.Literal(status) for status in upstream_status_literal_valid_status] | ||
87 | ) | ||
88 | |||
89 | upstream_status_prefix = pyparsing.Literal("Upstream-Status") | ||
90 | upstream_status = line_start + upstream_status_prefix + colon + upstream_status_valid_status | ||
91 | upstream_status_inappropriate_info = line_start + upstream_status_prefix + colon + inappropriateinfo | ||
92 | upstream_status_submitted_info = line_start + upstream_status_prefix + colon + submittedinfo | ||