diff options
| author | Trevor Gamblin <tgamblin@baylibre.com> | 2023-10-16 15:44:56 -0400 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-10-17 11:41:34 +0100 |
| commit | 9d137188ad03c111ff8df7396b6b3dfd59307ac0 (patch) | |
| tree | 6dd7227dec950282973d21e9cfd20b5e505f6bb1 /meta/lib/patchtest/patch.py | |
| parent | 790aa2096f7c6be92f994a1f8ec22d3bef91f337 (diff) | |
| download | poky-9d137188ad03c111ff8df7396b6b3dfd59307ac0.tar.gz | |
patchtest: add supporting modules
Add modules that support core patchtest functionality to
meta/lib/patchtest. These include classes and functions for handling
repository and patch objects, parsing the patchtest CLI arguments, and
other utilities.
(From OE-Core rev: 499cdad7a16f6cc256837069c7add294132127a4)
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/patchtest/patch.py')
| -rw-r--r-- | meta/lib/patchtest/patch.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/meta/lib/patchtest/patch.py b/meta/lib/patchtest/patch.py new file mode 100644 index 0000000000..c0e7d579eb --- /dev/null +++ b/meta/lib/patchtest/patch.py | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # patchtestpatch: PatchTestPatch class which abstracts a patch file | ||
| 5 | # | ||
| 6 | # Copyright (C) 2016 Intel Corporation | ||
| 7 | # | ||
| 8 | # This program is free software; you can redistribute it and/or modify | ||
| 9 | # it under the terms of the GNU General Public License version 2 as | ||
| 10 | # published by the Free Software Foundation. | ||
| 11 | # | ||
| 12 | # This program is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License along | ||
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | # | ||
| 21 | |||
| 22 | import logging | ||
| 23 | import utils | ||
| 24 | |||
| 25 | logger = logging.getLogger('patchtest') | ||
| 26 | |||
| 27 | class PatchTestPatch(object): | ||
| 28 | MERGE_STATUS_INVALID = 'INVALID' | ||
| 29 | MERGE_STATUS_NOT_MERGED = 'NOTMERGED' | ||
| 30 | MERGE_STATUS_MERGED_SUCCESSFULL = 'PASS' | ||
| 31 | MERGE_STATUS_MERGED_FAIL = 'FAIL' | ||
| 32 | MERGE_STATUS = (MERGE_STATUS_INVALID, | ||
| 33 | MERGE_STATUS_NOT_MERGED, | ||
| 34 | MERGE_STATUS_MERGED_SUCCESSFULL, | ||
| 35 | MERGE_STATUS_MERGED_FAIL) | ||
| 36 | |||
| 37 | def __init__(self, path, forcereload=False): | ||
| 38 | self._path = path | ||
| 39 | self._forcereload = forcereload | ||
| 40 | |||
| 41 | self._contents = None | ||
| 42 | self._branch = None | ||
| 43 | self._merge_status = PatchTestPatch.MERGE_STATUS_NOT_MERGED | ||
| 44 | |||
| 45 | @property | ||
| 46 | def contents(self): | ||
| 47 | if self._forcereload or (not self._contents): | ||
| 48 | logger.debug('Reading %s contents' % self._path) | ||
| 49 | try: | ||
| 50 | with open(self._path, newline='') as _f: | ||
| 51 | self._contents = _f.read() | ||
| 52 | except IOError: | ||
| 53 | logger.warn("Reading the mbox %s failed" % self.resource) | ||
| 54 | return self._contents | ||
| 55 | |||
| 56 | @property | ||
| 57 | def path(self): | ||
| 58 | return self._path | ||
| 59 | |||
| 60 | @property | ||
| 61 | def branch(self): | ||
| 62 | if not self._branch: | ||
| 63 | self._branch = utils.get_branch(self._path) | ||
| 64 | return self._branch | ||
| 65 | |||
| 66 | def setmergestatus(self, status): | ||
| 67 | self._merge_status = status | ||
| 68 | |||
| 69 | def getmergestatus(self): | ||
| 70 | return self._merge_status | ||
| 71 | |||
| 72 | merge_status = property(getmergestatus, setmergestatus) | ||
| 73 | |||
