From 4c378fc89566a329d0974bbcfefc7405779bc919 Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Tue, 24 Sep 2024 07:55:01 -0400 Subject: patchtest: simplify, rename modules - simplify base.py, data.py - move some leftover regex patterns to patterns.py - remove pyparsing path logic, since this is no longer needed - rename PatchTestInput class to PatchtestParser - data.py: rename to patchtest_parser.py - patterns.py: rename to patchtest_patterns.py - move PatchTestDataStore to test_metadata.py since that's the only place it's used - remove unused logger code (From OE-Core rev: 1e971b05b036b0b1eb0bdbd9b26b54d06e74294c) Signed-off-by: Trevor Gamblin Signed-off-by: Richard Purdie --- meta/lib/patchtest/patchtest_patterns.py | 96 ++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 meta/lib/patchtest/patchtest_patterns.py (limited to 'meta/lib/patchtest/patchtest_patterns.py') diff --git a/meta/lib/patchtest/patchtest_patterns.py b/meta/lib/patchtest/patchtest_patterns.py new file mode 100644 index 0000000000..8c2e192fc9 --- /dev/null +++ b/meta/lib/patchtest/patchtest_patterns.py @@ -0,0 +1,96 @@ +# common pyparsing variables +# +# Copyright (C) 2016 Intel Corporation +# +# SPDX-License-Identifier: GPL-2.0-only + +import pyparsing +import re + +# general +colon = pyparsing.Literal(":") +line_start = pyparsing.LineStart() +line_end = pyparsing.LineEnd() +lessthan = pyparsing.Literal("<") +greaterthan = pyparsing.Literal(">") +inappropriate = pyparsing.CaselessLiteral("Inappropriate") +submitted = pyparsing.CaselessLiteral("Submitted") + +# word related +nestexpr = pyparsing.nestedExpr(opener='[', closer=']') +inappropriateinfo = pyparsing.Literal("Inappropriate") + nestexpr +submittedinfo = pyparsing.Literal("Submitted") + nestexpr +word = pyparsing.Word(pyparsing.alphas) +worddot = pyparsing.Word(pyparsing.alphas+".") + +# metadata + +metadata_lic = 'LICENSE' +invalid_license = 'PATCHTESTINVALID' +metadata_chksum = 'LIC_FILES_CHKSUM' +license_var = 'LICENSE' +closed = 'CLOSED' +lictag_re = pyparsing.AtLineStart("License-Update:") +lic_chksum_added = pyparsing.AtLineStart("+" + metadata_chksum) +lic_chksum_removed = pyparsing.AtLineStart("-" + metadata_chksum) +add_mark = pyparsing.Regex('\\+ ') +patch_max_line_length = 200 +metadata_src_uri = "SRC_URI" +metadata_summary = "SUMMARY" +cve_check_ignore_var = "CVE_CHECK_IGNORE" +cve_status_var = "CVE_STATUS" +endcommit_messages_regex = re.compile( + r"\(From \w+-\w+ rev:|(?[A-Za-z0-9._%+-]+)@(?P[A-Za-z0-9.-]+)\.(?P[A-Za-z]{2,})") + +signed_off_by_prefix = pyparsing.Literal("Signed-off-by:") +signed_off_by_name = pyparsing.Regex('\S+.*(?= <)') +signed_off_by_email = lessthan + email_pattern + greaterthan +signed_off_by = pyparsing.AtLineStart(signed_off_by_prefix + signed_off_by_name + signed_off_by_email) +patch_signed_off_by = pyparsing.AtLineStart("+" + signed_off_by_prefix + signed_off_by_name + signed_off_by_email) + +# upstream-status + +upstream_status_literal_valid_status = ["Pending", "Backport", "Denied", "Inappropriate", "Submitted"] +upstream_status_nonliteral_valid_status = ["Pending", "Backport", "Denied", "Inappropriate [reason]", "Submitted [where]"] + +upstream_status_valid_status = pyparsing.Or( + [pyparsing.Literal(status) for status in upstream_status_literal_valid_status] +) + +upstream_status_prefix = pyparsing.Literal("Upstream-Status") +upstream_status = line_start + upstream_status_prefix + colon + upstream_status_valid_status +upstream_status_inappropriate_info = line_start + upstream_status_prefix + colon + inappropriateinfo +upstream_status_submitted_info = line_start + upstream_status_prefix + colon + submittedinfo -- cgit v1.2.3-54-g00ecf