From d6ede9c73b44062d8831a08f522d519591bf29c2 Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Tue, 24 Sep 2024 07:54:59 -0400 Subject: patchtest: mbox.py: new data implementation Consolidate and improve some objects: - absorb utils.py functionality - repo.py: use mbox.py - repo.py: remove some cruft - utils.py: replace with logs.py - utils.py: delete - patch.py: delete - scripts/patchtest: use logging directly - general cleanup (From OE-Core rev: d4fbdb1d15f281b236137d63710c73bca8911a36) Signed-off-by: Trevor Gamblin Signed-off-by: Richard Purdie --- meta/lib/patchtest/utils.py | 61 --------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 meta/lib/patchtest/utils.py (limited to 'meta/lib/patchtest/utils.py') diff --git a/meta/lib/patchtest/utils.py b/meta/lib/patchtest/utils.py deleted file mode 100644 index 8eddf3e85f..0000000000 --- a/meta/lib/patchtest/utils.py +++ /dev/null @@ -1,61 +0,0 @@ -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- -# -# utils: common methods used by the patchtest framework -# -# Copyright (C) 2016 Intel Corporation -# -# SPDX-License-Identifier: GPL-2.0-only -# - -import os -import subprocess -import logging -import re -import mailbox - -def logger_create(name): - logger = logging.getLogger(name) - loggerhandler = logging.StreamHandler() - loggerhandler.setFormatter(logging.Formatter("%(message)s")) - logger.addHandler(loggerhandler) - logger.setLevel(logging.INFO) - return logger - -def valid_branch(branch): - """ Check if branch is valid name """ - lbranch = branch.lower() - - invalid = lbranch.startswith('patch') or \ - lbranch.startswith('rfc') or \ - lbranch.startswith('resend') or \ - re.search(r'^v\d+', lbranch) or \ - re.search(r'^\d+/\d+', lbranch) - - return not invalid - -def get_branch(path): - """ Get the branch name from mbox """ - fullprefix = "" - mbox = mailbox.mbox(path) - - if len(mbox): - subject = mbox[0]['subject'] - if subject: - pattern = re.compile(r"(\[.*\])", re.DOTALL) - match = pattern.search(subject) - if match: - fullprefix = match.group(1) - - branch, branches, valid_branches = None, [], [] - - if fullprefix: - prefix = fullprefix.strip('[]') - branches = [ b.strip() for b in prefix.split(',')] - valid_branches = [b for b in branches if valid_branch(b)] - - if len(valid_branches): - branch = valid_branches[0] - - return branch - -- cgit v1.2.3-54-g00ecf