diff options
author | Trevor Gamblin <tgamblin@baylibre.com> | 2024-09-24 07:54:59 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-09-30 17:00:50 +0100 |
commit | d6ede9c73b44062d8831a08f522d519591bf29c2 (patch) | |
tree | 17711c77f409da9d7ed38361c9551e6bb6f967dd /meta/lib/patchtest/utils.py | |
parent | bb0f1625d7655d04c6df3c144e488f676ff2f762 (diff) | |
download | poky-d6ede9c73b44062d8831a08f522d519591bf29c2.tar.gz |
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 <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/patchtest/utils.py')
-rw-r--r-- | meta/lib/patchtest/utils.py | 61 |
1 files changed, 0 insertions, 61 deletions
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 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | # | ||
4 | # utils: common methods used by the patchtest framework | ||
5 | # | ||
6 | # Copyright (C) 2016 Intel Corporation | ||
7 | # | ||
8 | # SPDX-License-Identifier: GPL-2.0-only | ||
9 | # | ||
10 | |||
11 | import os | ||
12 | import subprocess | ||
13 | import logging | ||
14 | import re | ||
15 | import mailbox | ||
16 | |||
17 | def logger_create(name): | ||
18 | logger = logging.getLogger(name) | ||
19 | loggerhandler = logging.StreamHandler() | ||
20 | loggerhandler.setFormatter(logging.Formatter("%(message)s")) | ||
21 | logger.addHandler(loggerhandler) | ||
22 | logger.setLevel(logging.INFO) | ||
23 | return logger | ||
24 | |||
25 | def valid_branch(branch): | ||
26 | """ Check if branch is valid name """ | ||
27 | lbranch = branch.lower() | ||
28 | |||
29 | invalid = lbranch.startswith('patch') or \ | ||
30 | lbranch.startswith('rfc') or \ | ||
31 | lbranch.startswith('resend') or \ | ||
32 | re.search(r'^v\d+', lbranch) or \ | ||
33 | re.search(r'^\d+/\d+', lbranch) | ||
34 | |||
35 | return not invalid | ||
36 | |||
37 | def get_branch(path): | ||
38 | """ Get the branch name from mbox """ | ||
39 | fullprefix = "" | ||
40 | mbox = mailbox.mbox(path) | ||
41 | |||
42 | if len(mbox): | ||
43 | subject = mbox[0]['subject'] | ||
44 | if subject: | ||
45 | pattern = re.compile(r"(\[.*\])", re.DOTALL) | ||
46 | match = pattern.search(subject) | ||
47 | if match: | ||
48 | fullprefix = match.group(1) | ||
49 | |||
50 | branch, branches, valid_branches = None, [], [] | ||
51 | |||
52 | if fullprefix: | ||
53 | prefix = fullprefix.strip('[]') | ||
54 | branches = [ b.strip() for b in prefix.split(',')] | ||
55 | valid_branches = [b for b in branches if valid_branch(b)] | ||
56 | |||
57 | if len(valid_branches): | ||
58 | branch = valid_branches[0] | ||
59 | |||
60 | return branch | ||
61 | |||