blob: 6071eecc817182233eb67903cf8455448222042d [file] [log] [blame]
Brad Bishop8ffe1e42016-02-11 16:15:40 -05001# 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
17
Brad Bishop91ae8f92016-09-08 21:21:44 -040018def org_dot_openbmc_match(name, sep='.'):
19 matches = [
20 ['org', 'openbmc'],
21 ['xyz', 'openbmc-project'],
22 ]
23 return any(
24 [x in name for x in [ sep.join(y) for y in matches]])
Brad Bishop8ffe1e42016-02-11 16:15:40 -050025
26
27class ListMatch(object):
28 def __init__(self, l):
29 self.l = l
30
31 def __call__(self, match):
32 return match in self.l
33
34
35def find_case_insensitive(value, lst):
36 return next((x for x in lst if x.lower() == value.lower()), None)
37
38
39def makelist(data):
40 if isinstance(data, list):
41 return data
42 elif data:
43 return [data]
44 else:
45 return []