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