Brad Bishop | 8ffe1e4 | 2016-02-11 16:15:40 -0500 | [diff] [blame] | 1 | # Contributors Listed Below - COPYRIGHT 2016 |
| 2 | # [+] International Business Machines Corp. |
| 3 | # |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 14 | # implied. See the License for the specific language governing |
| 15 | # permissions and limitations under the License. |
| 16 | |
Brad Bishop | aea38c6 | 2018-01-30 13:00:26 -0500 | [diff] [blame] | 17 | |
Brad Bishop | b00a989 | 2016-09-19 10:58:46 -0400 | [diff] [blame] | 18 | def org_dot_openbmc_match_strings(sep='.', prefix=''): |
Brad Bishop | 91ae8f9 | 2016-09-08 21:21:44 -0400 | [diff] [blame] | 19 | matches = [ |
| 20 | ['org', 'openbmc'], |
Brad Bishop | 25af4ba | 2016-09-15 15:37:02 -0400 | [diff] [blame] | 21 | ['xyz', 'openbmc_project'], |
Brad Bishop | 91ae8f9 | 2016-09-08 21:21:44 -0400 | [diff] [blame] | 22 | ] |
Brad Bishop | 25af4ba | 2016-09-15 15:37:02 -0400 | [diff] [blame] | 23 | |
Brad Bishop | b00a989 | 2016-09-19 10:58:46 -0400 | [diff] [blame] | 24 | return [prefix + sep.join(y) for y in matches] |
Brad Bishop | 25af4ba | 2016-09-15 15:37:02 -0400 | [diff] [blame] | 25 | |
| 26 | |
Brad Bishop | b00a989 | 2016-09-19 10:58:46 -0400 | [diff] [blame] | 27 | def org_dot_openbmc_match(name, sep='.', prefix=''): |
| 28 | names = org_dot_openbmc_match_strings(sep=sep, prefix=prefix) |
Brad Bishop | 91ae8f9 | 2016-09-08 21:21:44 -0400 | [diff] [blame] | 29 | return any( |
Brad Bishop | bf72047 | 2016-09-19 10:34:23 -0400 | [diff] [blame] | 30 | [x in name or name in x for x in names]) |
Brad Bishop | 8ffe1e4 | 2016-02-11 16:15:40 -0500 | [diff] [blame] | 31 | |
| 32 | |
Brad Bishop | 8ffe1e4 | 2016-02-11 16:15:40 -0500 | [diff] [blame] | 33 | def find_case_insensitive(value, lst): |
| 34 | return next((x for x in lst if x.lower() == value.lower()), None) |
| 35 | |
| 36 | |
| 37 | def makelist(data): |
| 38 | if isinstance(data, list): |
| 39 | return data |
| 40 | elif data: |
| 41 | return [data] |
| 42 | else: |
| 43 | return [] |